diff options
author | eldritch horrors <pennae@lix.systems> | 2024-05-02 01:25:46 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-07-11 11:39:18 +0000 |
commit | df8851f286a407c46ea9107ca403888291f1afbe (patch) | |
tree | 568fbfaac2d35b968498fa3eb267c862e28c0b71 /tests | |
parent | 014410cbf0bda9c0fcdaf5f894120883cdc805ce (diff) |
libutil: rewrite RewritingSink as source
the rewriting sink was just broken. when given a rewrite set that
contained a key that is also a proper infix of another key it was
possible to produce an incorrectly rewritten result if the writer
used the wrong block size. fixing this duplicates rewriteStrings,
to avoid this we'll rewrite rewriteStrings to use RewritingSource
in a new mode that'll allow rewrites we had previously forbidden.
Change-Id: I57fa0a9a994e654e11d07172b8e31d15f0b7e8c0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/libutil/references.cc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/unit/libutil/references.cc b/tests/unit/libutil/references.cc index be2b59051..a914e6c70 100644 --- a/tests/unit/libutil/references.cc +++ b/tests/unit/libutil/references.cc @@ -25,11 +25,8 @@ class RewriteTest : public ::testing::TestWithParam<RewriteParams> { TEST_P(RewriteTest, IdentityRewriteIsIdentity) { RewriteParams param = GetParam(); - StringSink rewritten; - auto rewriter = RewritingSink(param.rewrites, rewritten); - rewriter(param.originalString); - rewriter.flush(); - ASSERT_EQ(rewritten.s, param.finalString); + StringSource src{param.originalString}; + ASSERT_EQ(RewritingSource(param.rewrites, src).drain(), param.finalString); } INSTANTIATE_TEST_CASE_P( @@ -38,7 +35,8 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values( RewriteParams{ "foooo", "baroo", {{"foo", "bar"}, {"bar", "baz"}}}, RewriteParams{ "foooo", "bazoo", {{"fou", "bar"}, {"foo", "baz"}}}, - RewriteParams{ "foooo", "foooo", {}} + RewriteParams{ "foooo", "foooo", {}}, + RewriteParams{ "babb", "bbbb", {{"ab", "aa"}, {"babb", "bbbb"}}} ) ); |