Skip to content

Adding new functions to Dictionaries.#65

Open
HelenMamontova wants to merge 17 commits intomadf:mainfrom
HelenMamontova:initial
Open

Adding new functions to Dictionaries.#65
HelenMamontova wants to merge 17 commits intomadf:mainfrom
HelenMamontova:initial

Conversation

@HelenMamontova
Copy link
Collaborator

Functions for searching by name, by code added to classes BasicDictionary, VendorDictionary, DependentDictionary, Dictionaries. Tests for these functions added.

…icDictionary, VendorDictionary, DependentDictionary.
…onaryTests, VendorDictionaryTests, DependentDictionaryTests.
attributeType. Functions attributeFindByName, attributeFindByCode,
vendorFindByName, vendorFindbyCode, attributeValueFindByName,
attributeValueFindByCode added to Dictionaries class.
…ype.

Functions attributeFindByName, attributeFindByCode, vendorFindByName, vendorFindbyCode,
attributeValueFindByName, attributeValueFindByCode definitions added to Dictionaries class.
…indByName, vendorFindbyCode, attributeValueFindByName, attributeValueFindByCode to Dictionaries_Tests.
size_t i = 0;
for (const auto& t : tok)
{
ipAddr[i] = static_cast<uint8_t>(std::stoul(t));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of separate ++i you can use ipAddr[i++]


bool BasicDictionary::findByName(const std::string& name) const
{
if (!m_reverseDict.count(name))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead all this code you can just

return m_reverseDict.count(name) > 0;

Same below.

bool DependentDictionary::findByName(const std::string& dependencyName, const std::string& name) const
{
std::pair<const std::string&, const std::string&> key = {dependencyName, name};
auto it = m_reverseDict.find(key);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use count here?

BOOST_CHECK_EQUAL(b.findByName("def"), false);
}

BOOST_AUTO_TEST_CASE(TestFindByCode)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can combine TestFindByName and TestFindByCode into a single test case. They use the same data and the assertions themselves are independent.

…case TestsFindByNameAndFindByCode in suites BasicDictionaryTests, VendorDictionaryTests, DependentDictionaryTests. The test cases for TestAttributeValueFindByName, TestAttributeValueFindByCode combined into a singl test case TestsAttributeValueFindByNameAndAttributeValueFindByCode in cuite DictionariesTests.
…ombined into a singl test case TestsAttributeFindByNameAndAttributeFindByCode in cuite DictionariesTests.
…d into a singl test case TestsVendorFindByNameAndVendorFindByCode in cuite DictionariesTests.
bool DependentDictionary::findByName(const std::string& dependencyName, const std::string& name) const
{
std::pair<const std::string&, const std::string&> key = {dependencyName, name};
return m_reverseDict.count(key) > 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to do it like this:

return m_reverseDict.count({dependencyName, name}) > 0;

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants