MCPcopy Create free account
hub / github.com/catboost/catboost / TestIterPartial

Function TestIterPartial

util/random/shuffle_ut.cpp:49–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48 template <typename... A>
49 static void TestIterPartial(A&&... args) {
50 TString s0, s1;
51
52 auto f = [&](int shuffledSize) {
53 auto b = s1.begin();
54 auto e = s1.end();
55
56 PartialShuffle(b, e, shuffledSize, args...);
57 };
58
59 s1 = "";
60 f(0);
61
62 s1 = "01";
63 f(1);
64
65 s1 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.;?!";
66 s0 = s1.copy();
67 f(2);
68 size_t matchesCount = 0;
69 for (size_t i = 0; i < s0.size(); ++i) {
70 matchesCount += (s0[i] == s1[i]);
71 }
72
73 UNIT_ASSERT(matchesCount >= s1.size() - 4); // partial shuffle doesn't make non-necessary swaps.
74
75 s1 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.;?!";
76 s0 = s1.copy();
77 f(64);
78
79 UNIT_ASSERT(s0 != s1); // if partial shuffle does work, chances it will fail are 1 to 64!.
80 }
81
82 Y_UNIT_TEST(TestShuffle) {
83 TestRange();

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 6

PartialShuffleFunction · 0.85
fFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
copyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected