Skip to content

Commit

Permalink
name-component: rename fromEscapedString() to fromUri()
Browse files Browse the repository at this point in the history
Consistent with toUri()

Change-Id: Ia8ca75be9068b06840e2847f0128ffc7a4cd57af
  • Loading branch information
Pesa committed Feb 12, 2024
1 parent 334516a commit 8e047e1
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 99 deletions.
4 changes: 2 additions & 2 deletions ndn-cxx/name-component.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand Down Expand Up @@ -136,7 +136,7 @@ parseUriEscapedValue(uint32_t type, std::string_view input)
}

Component
Component::fromEscapedString(std::string_view input)
Component::fromUri(std::string_view input)
{
size_t equalPos = input.find('=');
if (equalPos == std::string_view::npos) {
Expand Down
24 changes: 16 additions & 8 deletions ndn-cxx/name-component.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand Down Expand Up @@ -204,30 +204,38 @@ class Component : public Block, private boost::less_than_comparable<Component>

public: // encoding and URI
/**
* @brief Fast encoding or block size estimation
* @brief Prepend wire encoding to @p encoder.
*/
template<encoding::Tag TAG>
size_t
wireEncode(EncodingImpl<TAG>& encoder) const;

/**
* @brief Encode to a wire format
* @brief Encode to TLV wire format.
*/
const Block&
wireEncode() const;

/**
* @brief Decode from the wire format
* @brief Decode from TLV wire format.
*/
void
wireDecode(const Block& wire);

/**
* @brief Decode NameComponent from a URI component.
* @throw Error URI component does not represent a valid NameComponent.
* @brief Construct a NameComponent from its string representation in NDN URI format.
* @throw Error The input string does not represent a valid NameComponent in NDN URI format.
* @sa https://docs.named-data.net/NDN-packet-spec/0.3/name.html#ndn-uri-scheme
*/
static Component
fromEscapedString(std::string_view input);
fromUri(std::string_view input);

[[deprecated("use fromUri")]]
static Component
fromEscapedString(std::string_view input)
{
return Component::fromUri(input);
}

/**
* @brief Write `*this` to the output stream, escaping characters according to the NDN URI format.
Expand All @@ -237,7 +245,7 @@ class Component : public Block, private boost::less_than_comparable<Component>
toUri(std::ostream& os, UriFormat format = UriFormat::DEFAULT) const;

/**
* @brief Convert `*this` by escaping characters according to the NDN URI format.
* @brief Convert `*this` to a string by escaping characters according to the NDN URI format.
* @sa https://docs.named-data.net/NDN-packet-spec/0.3/name.html#ndn-uri-scheme
*/
std::string
Expand Down
2 changes: 1 addition & 1 deletion ndn-cxx/name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Name::Name(std::string_view uri)
// Unescape the components.
while (!uri.empty()) {
auto component = uri.substr(0, uri.find('/'));
append(Component::fromEscapedString(component));
append(Component::fromUri(component));
if (component.size() + 1 >= uri.size()) {
// We reached the end of the string.
return;
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/interest.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,8 @@ BOOST_AUTO_TEST_CASE(MatchesData)
interest = makeInterest(data->getFullName());
BOOST_CHECK_EQUAL(interest->matchesData(*data), true);

setNameComponent(*interest, -1,
name::Component::fromEscapedString("sha256digest=00000000000000000000000000"
"00000000000000000000000000000000000000"));
setNameComponent(*interest, -1, name::Component::fromUri("sha256digest=00000000000000000000000000"
"00000000000000000000000000000000000000"));
BOOST_CHECK_EQUAL(interest->matchesData(*data), false); // violates implicit digest
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/meta-info.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand Down Expand Up @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(EncodeDecode)
BOOST_CHECK_EQUAL(a.getType(), tlv::ContentType_Blob);
BOOST_CHECK_EQUAL(a.getFreshnessPeriod(), 0_ms);
BOOST_REQUIRE(a.getFinalBlock().has_value());
BOOST_CHECK_EQUAL(*a.getFinalBlock(), name::Component::fromEscapedString("221=A"));
BOOST_CHECK_EQUAL(*a.getFinalBlock(), name::Component::fromUri("221=A"));
BOOST_CHECK_NE(a.wireEncode(), b.wireEncode());

b.setType(a.getType());
Expand Down
139 changes: 70 additions & 69 deletions tests/unit/name-component.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,45 +63,46 @@ BOOST_AUTO_TEST_CASE(Generic)
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), "8=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), "ndn-cxx");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(comp), "ndn-cxx");
BOOST_CHECK_EQUAL(Component::fromEscapedString("ndn-cxx"), comp);
BOOST_CHECK_EQUAL(Component::fromEscapedString("8=ndn-cxx"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("ndn-cxx"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("8=ndn-cxx"sv), comp);

comp.wireDecode("0800"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "...");
BOOST_CHECK_EQUAL(Component::fromEscapedString("..."), comp);
BOOST_CHECK_EQUAL(Component::fromEscapedString("8=..."), comp);
BOOST_CHECK_EQUAL(Component::fromEscapedString(".%2E."), comp);
BOOST_CHECK_EQUAL(Component::fromUri("..."), comp);
BOOST_CHECK_EQUAL(Component::fromUri("8=..."sv), comp);
BOOST_CHECK_EQUAL(Component::fromUri(".%2E."sv), comp);

comp.wireDecode("0801 2E"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "....");
BOOST_CHECK_EQUAL(Component::fromEscapedString("...."), comp);
BOOST_CHECK_EQUAL(Component::fromEscapedString("%2E..%2E"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("...."), comp);
BOOST_CHECK_EQUAL(Component::fromUri("%2E..%2E"sv), comp);

comp.wireDecode("0803 2E412E"_block);
BOOST_CHECK_EQUAL(comp.toUri(), ".A.");
BOOST_CHECK_EQUAL(Component::fromEscapedString(".A."), comp);
BOOST_CHECK_EQUAL(Component::fromUri(".A."sv), comp);

comp.wireDecode("0807 666F6F25626172"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "foo%25bar");
BOOST_CHECK_EQUAL(Component::fromEscapedString("foo%25bar"), comp);
BOOST_CHECK_EQUAL(Component::fromEscapedString("8=foo%25bar"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("foo%25bar"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("8=foo%25bar"sv), comp);

comp.wireDecode("0804 2D2E5F7E"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "-._~");
BOOST_CHECK_EQUAL(Component::fromEscapedString("-._~"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("-._~"sv), comp);

comp.wireDecode("0803 393D41"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "9%3DA");
BOOST_CHECK_EQUAL(Component::fromEscapedString("9%3DA"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("9%3DA"sv), comp);

comp = Component(":/?#[]@");
BOOST_CHECK_EQUAL(comp.toUri(), "%3A%2F%3F%23%5B%5D%40");
BOOST_CHECK_EQUAL(Component::fromEscapedString("%3A%2F%3F%23%5B%5D%40"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("%3A%2F%3F%23%5B%5D%40"sv), comp);

BOOST_CHECK_THROW(Component::fromEscapedString(""), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("."), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString(".."), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("8="), Component::Error);
BOOST_CHECK_THROW(Component::fromUri(""), Component::Error);
BOOST_CHECK_THROW(Component::fromUri(""sv), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("."sv), Component::Error);
BOOST_CHECK_THROW(Component::fromUri(".."sv), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("8="sv), Component::Error);
}

static void
Expand All @@ -119,21 +120,21 @@ testSha256Component(uint32_t type, const std::string& uriPrefix)

BOOST_CHECK_EQUAL(comp.type(), type);
BOOST_CHECK_EQUAL(comp.toUri(), uriPrefix + hexLower);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::CANONICAL), to_string(type) + "=" + hexPctCanonical);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::CANONICAL), std::to_string(type) + "=" + hexPctCanonical);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ALTERNATE), uriPrefix + hexLower);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), to_string(type) + "=" + hexPctCanonical);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), std::to_string(type) + "=" + hexPctCanonical);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), uriPrefix + hexLower);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(comp), uriPrefix + hexLower);
BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(uriPrefix + hexLower));
BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(uriPrefix + hexUpper));
BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(to_string(type) + "=" + hexPct));
BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(to_string(type) + "=" + hexPctCanonical));
BOOST_CHECK_EQUAL(comp, Component::fromUri(uriPrefix + hexLower));
BOOST_CHECK_EQUAL(comp, Component::fromUri(uriPrefix + hexUpper));
BOOST_CHECK_EQUAL(comp, Component::fromUri(std::to_string(type) + "=" + hexPct));
BOOST_CHECK_EQUAL(comp, Component::fromUri(std::to_string(type) + "=" + hexPctCanonical));

CHECK_COMP_ERR(comp.wireDecode(Block(type, fromHex("A791806951F25C4D"))), "TLV-LENGTH must be 32");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix), "TLV-LENGTH must be 32");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "a791806951f25c4d"), "TLV-LENGTH must be 32");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "foo"), "invalid hex encoding");
CHECK_COMP_ERR(Component::fromEscapedString(boost::to_upper_copy(uriPrefix) + hexLower), "Unknown TLV-TYPE");
CHECK_COMP_ERR(Component::fromUri(uriPrefix), "TLV-LENGTH must be 32");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + "a791806951f25c4d"), "TLV-LENGTH must be 32");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + "foo"), "invalid hex encoding");
CHECK_COMP_ERR(Component::fromUri(boost::to_upper_copy(uriPrefix) + hexLower), "Unknown TLV-TYPE");
}

BOOST_AUTO_TEST_CASE(ImplicitDigest)
Expand All @@ -154,32 +155,32 @@ testDecimalComponent(uint32_t type, const std::string& uriPrefix)
BOOST_CHECK_EQUAL(comp.isNumber(), true);
const auto compUri = uriPrefix + "42";
BOOST_CHECK_EQUAL(comp.toUri(), compUri);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::CANONICAL), to_string(type) + "=%2A");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::CANONICAL), std::to_string(type) + "=%2A");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ALTERNATE), compUri);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), to_string(type) + "=%2A");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), std::to_string(type) + "=%2A");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), compUri);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(comp), compUri);
BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(compUri));
BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(to_string(type) + "=%2A"));
BOOST_CHECK_EQUAL(comp, Component::fromUri(compUri));
BOOST_CHECK_EQUAL(comp, Component::fromUri(std::to_string(type) + "=%2A"));
BOOST_CHECK_EQUAL(comp, Component::fromNumber(42, type));

const Component comp2(type, fromHex("010203")); // TLV-VALUE is *not* a NonNegativeInteger
BOOST_CHECK_EQUAL(comp2.type(), type);
BOOST_CHECK_EQUAL(comp2.isNumber(), false);
const auto comp2Uri = to_string(type) + "=%01%02%03";
const auto comp2Uri = std::to_string(type) + "=%01%02%03";
BOOST_CHECK_EQUAL(comp2.toUri(), comp2Uri);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(comp2), comp2Uri);
BOOST_CHECK_EQUAL(comp2, Component::fromEscapedString(comp2Uri));

CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix), "invalid format");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "foo"), "invalid format");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "00"), "invalid format");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "-1"), "invalid format");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "9.3"), "invalid format");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + " 84"), "invalid format");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "0xAF"), "invalid format");
CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "18446744073709551616"), "out of range");
CHECK_COMP_ERR(Component::fromEscapedString(boost::to_upper_copy(uriPrefix) + "42"), "Unknown TLV-TYPE");
BOOST_CHECK_EQUAL(comp2, Component::fromUri(comp2Uri));

CHECK_COMP_ERR(Component::fromUri(uriPrefix), "invalid format");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + "foo"), "invalid format");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + "00"), "invalid format");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + "-1"), "invalid format");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + "9.3"), "invalid format");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + " 84"), "invalid format");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + "0xAF"), "invalid format");
CHECK_COMP_ERR(Component::fromUri(uriPrefix + "18446744073709551616"), "out of range");
CHECK_COMP_ERR(Component::fromUri(boost::to_upper_copy(uriPrefix) + "42"), "Unknown TLV-TYPE");
}

BOOST_AUTO_TEST_CASE(Segment)
Expand Down Expand Up @@ -217,17 +218,17 @@ BOOST_AUTO_TEST_CASE(Keyword)
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ALTERNATE), "32=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), "32=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), "32=ndn-cxx");
BOOST_CHECK_EQUAL(Component::fromEscapedString("32=ndn-cxx"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("32=ndn-cxx"sv), comp);

comp.wireDecode("2000"_block);
BOOST_CHECK_EQUAL(comp.type(), tlv::KeywordNameComponent);
BOOST_CHECK_EQUAL(comp.isKeyword(), true);
BOOST_CHECK_EQUAL(comp.toUri(), "32=...");
BOOST_CHECK_EQUAL(Component::fromEscapedString("32=..."), comp);
BOOST_CHECK_EQUAL(Component::fromUri("32=..."sv), comp);

BOOST_CHECK_THROW(Component::fromEscapedString("32="), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("32=."), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("32=.."), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("32="sv), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("32=."sv), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("32=.."sv), Component::Error);
}

BOOST_AUTO_TEST_CASE(OtherType)
Expand All @@ -239,21 +240,21 @@ BOOST_AUTO_TEST_CASE(OtherType)
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ALTERNATE), "9=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), "9=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), "9=ndn-cxx");
BOOST_CHECK_EQUAL(Component::fromEscapedString("9=ndn-cxx"), comp);
BOOST_CHECK_EQUAL(Component::fromUri("9=ndn-cxx"sv), comp);

comp.wireDecode("FDFFFF00"_block);
BOOST_CHECK_EQUAL(comp.type(), 0xFFFF);
BOOST_CHECK_EQUAL(comp.toUri(), "65535=...");
BOOST_CHECK_EQUAL(Component::fromEscapedString("65535=..."), comp);
BOOST_CHECK_EQUAL(Component::fromUri("65535=..."sv), comp);

comp.wireDecode("FD576501 2E"_block);
BOOST_CHECK_EQUAL(comp.type(), 0x5765);
BOOST_CHECK_EQUAL(comp.toUri(), "22373=....");
BOOST_CHECK_EQUAL(Component::fromEscapedString("22373=...."), comp);
BOOST_CHECK_EQUAL(Component::fromUri("22373=...."sv), comp);

BOOST_CHECK_THROW(Component::fromEscapedString("3="), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("3=."), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("3=.."), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("3="sv), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("3=."sv), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("3=.."sv), Component::Error);
}

BOOST_AUTO_TEST_CASE(InvalidType)
Expand All @@ -262,21 +263,21 @@ BOOST_AUTO_TEST_CASE(InvalidType)
BOOST_CHECK_THROW(comp.wireDecode(Block{}), Component::Error);
BOOST_CHECK_THROW(comp.wireDecode("FE0001000001 80"_block), Component::Error);

BOOST_CHECK_THROW(Component::fromEscapedString("0=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("65536=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("4294967296=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("-1=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("+=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("0x1=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("Z=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("09=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("0x3=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("+9=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString(" 9=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("9 =A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("9.0=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromEscapedString("9E0=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("0=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("65536=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("4294967296=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("-1=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("+=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("0x1=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("Z=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("09=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("0x3=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("+9=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri(" 9=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("9 =A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("9.0=A"), Component::Error);
BOOST_CHECK_THROW(Component::fromUri("9E0=A"), Component::Error);
}

BOOST_AUTO_TEST_SUITE_END() // Decode
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/name.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@ BOOST_AUTO_TEST_CASE(AppendTypedComponent)
BOOST_TEST(number == 11676);

name.appendKeyword({0xab, 0xcd, 0xef});
BOOST_TEST(name.at(-1) == Component::fromEscapedString("32=%AB%CD%EF"sv));
BOOST_TEST(name.at(-1) == Component::fromUri("32=%AB%CD%EF"sv));

name.appendKeyword("test-keyword");
BOOST_TEST(name.at(-1) == Component::fromEscapedString("32=test-keyword"sv));
BOOST_TEST(name.at(-1) == Component::fromUri("32=test-keyword"sv));
}

BOOST_AUTO_TEST_CASE(EraseComponent)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/prefix-announcement.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2023 Regents of the University of California.
* Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
Expand Down Expand Up @@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(DecodeBad)

// Name has no "32=PA" keyword
Data data1 = makePrefixAnnData();
setNameComponent(data1, -3, name::Component::fromEscapedString("32=not-PA"));
setNameComponent(data1, -3, name::Component::fromUri("32=not-PA"));
BOOST_CHECK_EXCEPTION(PrefixAnnouncement{data1}, tlv::Error, [] (const auto& e) {
return e.what() == "Data is not a prefix announcement: wrong name structure"s;
});
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/security/key-chain.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ BOOST_AUTO_TEST_CASE(DefaultsFromCert)
BOOST_AUTO_TEST_CASE(Options)
{
MakeCertificateOptions opts;
opts.issuerId = name::Component::fromEscapedString("ISSUER");
opts.issuerId = name::Component::fromUri("ISSUER");
opts.version = 41218268;
opts.freshnessPeriod = 321_s;
opts.validity.emplace(time::fromIsoString("20060702T150405"),
Expand Down
Loading

0 comments on commit 8e047e1

Please sign in to comment.