diff options
| author | aprudaev <[email protected]> | 2022-02-10 16:49:58 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:49:58 +0300 | 
| commit | 29e66fe2ab37743577f88e6ab770defc4e6c1002 (patch) | |
| tree | 332323481b37f79cf521451582f724fb13a7143a /library/cpp/codecs/ut | |
| parent | 66f1a2f0600877a21fcc76f83c52904a58425f78 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/codecs/ut')
| -rw-r--r-- | library/cpp/codecs/ut/codecs_ut.cpp | 66 | 
1 files changed, 33 insertions, 33 deletions
diff --git a/library/cpp/codecs/ut/codecs_ut.cpp b/library/cpp/codecs/ut/codecs_ut.cpp index caf6089aef7..ea9490b9a6f 100644 --- a/library/cpp/codecs/ut/codecs_ut.cpp +++ b/library/cpp/codecs/ut/codecs_ut.cpp @@ -864,7 +864,7 @@ class TCodecsTest: public TTestBase {      UNIT_TEST(TestHuffman)      UNIT_TEST(TestZStdDict)      UNIT_TEST(TestCompTable) -    UNIT_TEST(TestHuffmanLearnByFreqs) +    UNIT_TEST(TestHuffmanLearnByFreqs)       UNIT_TEST(TestSolar)      UNIT_TEST(TestPFor)      UNIT_TEST(TestRegistry) @@ -1194,60 +1194,60 @@ private:          DoTestSimpleCodec<NCodecs::TCompTableCodec>();      } -    void TestHuffmanLearnByFreqs() { -        using namespace NCodecs; - +    void TestHuffmanLearnByFreqs() {  +        using namespace NCodecs;  +           TVector<TBuffer> data; - +           for (auto& textValue : TextValues) {              data.emplace_back(textValue, strlen(textValue)); -        } - +        }  +           TVector<TBuffer> outLearn; - -        { -            THuffmanCodec codec; -            static_cast<ICodec&>(codec).Learn(data.begin(), data.end()); - -            for (ui32 i = 0; i < data.size(); ++i) { +  +        {  +            THuffmanCodec codec;  +            static_cast<ICodec&>(codec).Learn(data.begin(), data.end());  +  +            for (ui32 i = 0; i < data.size(); ++i) {                   outLearn.emplace_back();                  codec.Encode(AsStrBuf(data[i]), outLearn[i]); -            } -        } - +            }  +        }  +           TVector<TBuffer> outLearnByFreqs; - -        { -            THuffmanCodec codec; +  +        {  +            THuffmanCodec codec;               std::pair<char, ui64> freqs[256]; - +               for (size_t i = 0; i < Y_ARRAY_SIZE(freqs); ++i) { -                freqs[i].first = (char)i; -                freqs[i].second = 0; -            } - +                freqs[i].first = (char)i;  +                freqs[i].second = 0;  +            }  +               for (auto& textValue : TextValues) {                  size_t len = strlen(textValue);                  for (size_t j = 0; j < len; ++j) {                      ++freqs[(ui32)(0xFF & textValue[j])].second;                  } -            } - +            }  +               codec.LearnByFreqs(TArrayRef<std::pair<char, ui64>>(freqs, Y_ARRAY_SIZE(freqs))); - -            for (ui32 i = 0; i < data.size(); ++i) { +  +            for (ui32 i = 0; i < data.size(); ++i) {                   outLearnByFreqs.emplace_back();                  codec.Encode(AsStrBuf(data[i]), outLearnByFreqs[i]); -            } -        } - +            }  +        }  +           UNIT_ASSERT_EQUAL(outLearn.size(), outLearnByFreqs.size());          const size_t sz = outLearn.size();          for (size_t n = 0; n < sz; ++n) {              UNIT_ASSERT_EQUAL(AsStrBuf(outLearn[n]), AsStrBuf(outLearnByFreqs[n]));          } -    } - +    }  +       void TestSolar() {          using namespace NCodecs;          {  | 
