-
Notifications
You must be signed in to change notification settings - Fork 4
Adding new functions to Dictionaries. #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
VendorDictionary, DependentDictionary.
…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.
… Dictionaries class.
…ion fixed in Dictionaries class.
…indByName, vendorFindbyCode, attributeValueFindByName, attributeValueFindByCode to Dictionaries_Tests.
src/attribute.cpp
Outdated
| size_t i = 0; | ||
| for (const auto& t : tok) | ||
| { | ||
| ipAddr[i] = static_cast<uint8_t>(std::stoul(t)); |
There was a problem hiding this comment.
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++]
src/dictionaries.cpp
Outdated
|
|
||
| bool BasicDictionary::findByName(const std::string& name) const | ||
| { | ||
| if (!m_reverseDict.count(name)) |
There was a problem hiding this comment.
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.
src/dictionaries.cpp
Outdated
| 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); |
There was a problem hiding this comment.
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?
tests/dictionaries_tests.cpp
Outdated
| BOOST_CHECK_EQUAL(b.findByName("def"), false); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(TestFindByCode) |
There was a problem hiding this comment.
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.
src/dictionaries.cpp
Outdated
| 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; |
There was a problem hiding this comment.
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;?
class DependentDictionary.
Functions for searching by name, by code added to classes BasicDictionary, VendorDictionary, DependentDictionary, Dictionaries. Tests for these functions added.