forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
22652739de
commit
a86e0e294d
3 changed files with 28 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "base/bwt.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
using namespace base;
|
||||
|
@ -64,4 +65,26 @@ UNIT_TEST(RevBWT_Smoke)
|
|||
TEST_EQUAL(s, RevRevBWT(s), ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(RevBWT_AllBytes)
|
||||
{
|
||||
int kSeed = 42;
|
||||
int kMin = 1;
|
||||
int kMax = 10;
|
||||
|
||||
mt19937 engine(kSeed);
|
||||
uniform_int_distribution<int> uid(kMin, kMax);
|
||||
|
||||
string s;
|
||||
for (size_t i = 0; i < 256; ++i)
|
||||
{
|
||||
auto const count = uid(engine);
|
||||
ASSERT_GREATER_OR_EQUAL(count, kMin, ());
|
||||
ASSERT_LESS_OR_EQUAL(count, kMax, ());
|
||||
for (int j = 0; j < count; ++j)
|
||||
s.push_back(static_cast<uint8_t>(i));
|
||||
}
|
||||
shuffle(s.begin(), s.end(), engine);
|
||||
TEST_EQUAL(s, RevRevBWT(s), ());
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -29,6 +29,7 @@ class FirstColumn
|
|||
public:
|
||||
FirstColumn(size_t n, uint8_t const * s) : m_n(n), m_starts({})
|
||||
{
|
||||
m_starts.fill(0);
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
++m_starts[s[i]];
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ struct SkewWrapper
|
|||
return 0;
|
||||
}
|
||||
|
||||
size_t MaxValue() const { return static_cast<size_t>(numeric_limits<uint8_t>::max()) + 1; }
|
||||
|
||||
size_t const m_n;
|
||||
uint8_t const * const m_s;
|
||||
};
|
||||
|
@ -241,8 +243,8 @@ namespace base
|
|||
{
|
||||
void Skew(size_t n, uint8_t const * s, size_t * sa)
|
||||
{
|
||||
auto const maxValue = static_cast<size_t>(numeric_limits<uint8_t>::max());
|
||||
RawSkew(n, maxValue, SkewWrapper(n, s), sa);
|
||||
SkewWrapper wrapper(n, s);
|
||||
RawSkew(n, wrapper.MaxValue(), wrapper, sa);
|
||||
}
|
||||
|
||||
void Skew(string const & s, vector<size_t> & sa)
|
||||
|
|
Loading…
Add table
Reference in a new issue