1
0
mirror of synced 2024-09-24 03:28:24 +02:00
ImHex/tests/helpers/source/utils.cpp
gudzpoz eca5fb894f
feat: Added LEB128 in data inspector (#615)
* feat: Added LEB128 in data inspector

* feat: Added support for editing LEB128 values

* Moved LEB functions from utils.cpp to crypto.cpp

* Added placeholders for translations

* Made DataInspector::impl::Entry.maxSize mandatory

* Fixed undefined leftshifting behaviour
2022-08-01 13:20:20 +02:00

33 lines
1.0 KiB
C++

#include <hex/test/tests.hpp>
#include <hex/helpers/utils.hpp>
using namespace std::literals::string_literals;
TEST_SEQUENCE("SplitStringAtChar") {
const std::string TestString = "Hello|World|ABCD|Test|";
const std::vector<std::string> TestSplitVector = { "Hello", "World", "ABCD", "Test", "" };
TEST_ASSERT(hex::splitString(TestString, "|") == TestSplitVector);
TEST_SUCCESS();
};
TEST_SEQUENCE("SplitStringAtString") {
const std::string TestString = "Hello|DELIM|World|DELIM|ABCD|DELIM|Test|DELIM|";
const std::vector<std::string> TestSplitVector = { "Hello", "World", "ABCD", "Test", "" };
TEST_ASSERT(hex::splitString(TestString, "|DELIM|") == TestSplitVector);
TEST_SUCCESS();
};
TEST_SEQUENCE("ExtractBits") {
TEST_ASSERT(hex::extract(11, 4, 0xAABBU) == 0xAB);
TEST_ASSERT(hex::extract(15, 0, 0xAABBU) == 0xAABB);
TEST_ASSERT(hex::extract(35, 20, 0x8899AABBCCDDEEFFU) == 0xBCCD);
TEST_ASSERT(hex::extract(20, 35, 0x8899AABBCCDDEEFFU) == 0xBCCD);
TEST_SUCCESS();
};