diff options
author | Yury Melnichek <melnichek@gmail.com> | 2012-06-27 01:46:45 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:40:16 +0300 |
commit | 72d04eba89493bbd0d80673b38ae4c7e707b169c (patch) | |
tree | 3b42a9bfad18202d4132c4293bc7aaed04810b61 /coding | |
parent | 3f35ce220c8ea553d621a9046e3682b216699ce1 (diff) |
Fix trie unit test.
Diffstat (limited to 'coding')
-rw-r--r-- | coding/coding_tests/trie_test.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/coding/coding_tests/trie_test.cpp b/coding/coding_tests/trie_test.cpp index 3fc60ae2b5..96f11eb9da 100644 --- a/coding/coding_tests/trie_test.cpp +++ b/coding/coding_tests/trie_test.cpp @@ -187,8 +187,8 @@ UNIT_TEST(TrieBuilder_Build) { vector<KeyValuePair> v; if (i0 >= 0) v.push_back(KeyValuePair(possibleStrings[i0], i0)); - if (i1 >= 0) v.push_back(KeyValuePair(possibleStrings[i1], i1)); - if (i2 >= 0) v.push_back(KeyValuePair(possibleStrings[i2], i2)); + if (i1 >= 0) v.push_back(KeyValuePair(possibleStrings[i1], i1 + 10)); + if (i2 >= 0) v.push_back(KeyValuePair(possibleStrings[i2], i2 + 100)); vector<string> vs; for (size_t i = 0; i < v.size(); ++i) vs.push_back(string(v[i].m_key.begin(), v[i].m_key.end())); @@ -213,9 +213,12 @@ UNIT_TEST(TrieBuilder_Build) sort(f.m_v.begin(), f.m_v.end()); TEST_EQUAL(v, f.m_v, ()); - int maxEdgeValue = 0; + uint32_t expectedMaxEdgeValue = 0; + for (size_t i = 0; i < v.size(); ++i) + expectedMaxEdgeValue = max(expectedMaxEdgeValue, v[i].m_value); + uint32_t maxEdgeValue = 0; for (uint32_t i = 0; i < root->m_edge.size(); ++i) - maxEdgeValue = max(maxEdgeValue, static_cast<int>(root->m_edge[i].m_value.m_data[0])); - TEST_EQUAL(maxEdgeValue, max(max(0, i0), max(i1, i2)), ()); + maxEdgeValue = max(maxEdgeValue, static_cast<uint32_t>(root->m_edge[i].m_value.m_data[0])); + TEST_EQUAL(maxEdgeValue, expectedMaxEdgeValue, (v, f.m_v)); } } |