12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include <iostream>
- #include <string.h>
- #include <gtest/gtest.h>
- #include <ScHex.h>
- #include <ScReader.h>
-
- #define TEST_Hex(FUNCTION) do { \
- FUNCTION("", "", 0); \
- FUNCTION("42", "\x42", 1); \
- FUNCTION("42 00 FF AA 24", "\x42\x00\xff\xaa\x24", 5); \
- FUNCTION("00 01 02 03 04 05 06 FF", "\x00\x01\x02\x03\x04\x05\x06\xff", 8); \
- } while (0)
-
- #define TEST_byteArrayToString(STR, DATA, SIZE) \
- EXPECT_EQ(STR, ScHex::byteArrayToString(ScByteArray((BYTE*)memcpy(new BYTE[SIZE], DATA, SIZE), SIZE)))
-
- TEST(Hex, ByteArrayToString)
- {
- TEST_Hex(TEST_byteArrayToString);
- }
-
- #define TEST_stringToByteArray(STR, DATA, SIZE) do { \
- auto bytes = ScHex::stringToByteArray(STR); \
- EXPECT_EQ(SIZE, bytes.getSize()); \
- EXPECT_EQ(0, memcmp(bytes.getData(), DATA, SIZE)); \
- } while (0)
-
- TEST(Hex, StringToByteArray)
- {
- TEST_Hex( TEST_stringToByteArray);
- }
-
- int main(int argc, char* argv[])
- {
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-
- /*std::cout << ScReader::establishContext() << std::endl;
- auto readers = ScReader::getReaders();
- for (auto reader : readers)
- {
- std::cout << reader->getName() << " ";
- std::cout << reader->connect() << " ";
- std::cout << reader->disconnect();
- std::cout << std::endl;
- }
- std::cout << ScReader::freeContext() << std::endl;
- return 0;*/
- }
|