Skip to content

Commit

Permalink
Removed unused library code and added a test case to improve coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
JusticeRage committed Jun 30, 2017
1 parent 9d68586 commit 303b7cf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ script:
- bin/manalyze --version
- bin/manalyze-tests
after_success:
- coveralls --exclude external/yara --exclude test --gcov gcov-4.8
- coveralls --exclude external/yara --exclude test --exclude plugins/plugin_virustotal/json_spirit --gcov gcov-4.8
33 changes: 0 additions & 33 deletions include/manacommons/utf8/checked.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,39 +230,6 @@ namespace utf8
return result;
}

template <typename u16bit_iterator, typename octet_iterator>
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
{
while (start != end) {
uint32_t cp = utf8::next(start, end);
if (cp > 0xffff) { //make a surrogate pair
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
}
else
*result++ = static_cast<uint16_t>(cp);
}
return result;
}

template <typename octet_iterator, typename u32bit_iterator>
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
{
while (start != end)
result = utf8::append(*(start++), result);

return result;
}

template <typename octet_iterator, typename u32bit_iterator>
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
{
while (start != end)
(*result++) = utf8::next(start, end);

return result;
}

// The iterator class
template <typename octet_iterator>
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
Expand Down
4 changes: 4 additions & 0 deletions test/pe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ BOOST_AUTO_TEST_CASE(parse_testfile)
mana::PE pe("testfiles/manatest.exe");
BOOST_CHECK_EQUAL(pe.get_filesize(), 16360);
BOOST_ASSERT(pe.is_valid());
BOOST_ASSERT(pe.get_path());
BOOST_CHECK_EQUAL(*pe.get_path(), "testfiles/manatest.exe");
mana::PE pe2("testfiles/manatest2.exe");
BOOST_CHECK_EQUAL(pe2.get_filesize(), 72704);
BOOST_ASSERT(pe2.is_valid());
BOOST_ASSERT(pe2.get_path());
BOOST_CHECK_EQUAL(*pe2.get_path(), "testfiles/manatest2.exe");
}

// ----------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions test/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,29 @@ BOOST_AUTO_TEST_CASE(interpret_versioninfo)
check_pair<std::string>(string_table[7], "ProductVersion", "1.0.0.0");
}

// ----------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE(interpret_icon)
{
mana::PE pe("testfiles/manatest2.exe");
auto resources = pe.get_resources();
for (auto it = resources->begin(); it != resources->end(); ++it)
{
if (*(*it)->get_type() == "RT_GROUP_ICON")
{
auto res = (*it)->icon_extract("testfiles/icon.ico", *pe.get_resources());
break;
}
}

auto h = hash::hash_file(*hash::ALL_DIGESTS.at(ALL_DIGESTS_SHA1), "testfiles/icon.ico");
BOOST_ASSERT(fs::exists("testfiles/icon.ico"));
fs::remove("testfiles/icon.ico");
BOOST_ASSERT(h);
BOOST_CHECK_EQUAL(*h, "ef6952d242906001e0d3269e5df0d8e22f3c56d1");

}

// ----------------------------------------------------------------------------
BOOST_AUTO_TEST_SUITE_END()
// ----------------------------------------------------------------------------

0 comments on commit 303b7cf

Please sign in to comment.