@@ -118,6 +118,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hash.cpp" />
|
||||
<ClCompile Include="math.cpp" />
|
||||
<ClCompile Include="parser.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
|
@@ -36,6 +36,9 @@
|
||||
<ClCompile Include="unicode.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="hash.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h">
|
||||
|
67
UnitTests/hash.cpp
Normal file
67
UnitTests/hash.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
SPDX-License-Identifier: MIT
|
||||
Copyright © 2023 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
using namespace std;
|
||||
#ifdef _WIN32
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace Microsoft {
|
||||
namespace VisualStudio {
|
||||
namespace CppUnitTestFramework {
|
||||
static std::wstring ToString(const stdex::md5_t& q)
|
||||
{
|
||||
stdex::hex_enc enc;
|
||||
wstring str;
|
||||
enc.encode(str, &q, sizeof(q));
|
||||
return str;
|
||||
}
|
||||
|
||||
static std::wstring ToString(const stdex::sha1_t& q)
|
||||
{
|
||||
stdex::hex_enc enc;
|
||||
wstring str;
|
||||
enc.encode(str, &q, sizeof(q));
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace UnitTests
|
||||
{
|
||||
TEST_CLASS(hash)
|
||||
{
|
||||
public:
|
||||
TEST_METHOD(crc32)
|
||||
{
|
||||
stdex::crc32_hash h;
|
||||
static const char data[] = "This is a test.";
|
||||
h.hash(data, sizeof(data) - sizeof(*data));
|
||||
h.finalize();
|
||||
Assert::AreEqual<stdex::crc32_t>(0xc6c3c95d, h);
|
||||
}
|
||||
|
||||
TEST_METHOD(md5)
|
||||
{
|
||||
stdex::md5_hash h;
|
||||
static const char data[] = "This is a test.";
|
||||
h.hash(data, sizeof(data) - sizeof(*data));
|
||||
h.finalize();
|
||||
Assert::AreEqual<stdex::md5_t>({0x12,0x0e,0xa8,0xa2,0x5e,0x5d,0x48,0x7b,0xf6,0x8b,0x5f,0x70,0x96,0x44,0x00,0x19}, h);
|
||||
}
|
||||
|
||||
TEST_METHOD(sha1)
|
||||
{
|
||||
stdex::sha1_hash h;
|
||||
static const char data[] = "This is a test.";
|
||||
h.hash(data, sizeof(data) - sizeof(*data));
|
||||
h.finalize();
|
||||
Assert::AreEqual<stdex::sha1_t>({0xaf,0xa6,0xc8,0xb3,0xa2,0xfa,0xe9,0x57,0x85,0xdc,0x7d,0x96,0x85,0xa5,0x78,0x35,0xd7,0x03,0xac,0x88}, h);
|
||||
}
|
||||
};
|
||||
}
|
@@ -340,7 +340,6 @@ namespace UnitTests
|
||||
}
|
||||
|
||||
{
|
||||
std::locale locale_slSI("sl_SI");
|
||||
sgml_space_cp space(false, locale_slSI);
|
||||
sgml_iban p(make_shared_no_delete(&space), locale_slSI);
|
||||
Assert::IsTrue(p.match("SI56023120015226972", 0, SIZE_MAX));
|
||||
@@ -367,7 +366,6 @@ namespace UnitTests
|
||||
}
|
||||
|
||||
{
|
||||
std::locale locale_slSI("sl_SI");
|
||||
sgml_space_cp space(false, locale_slSI);
|
||||
sgml_creditor_reference p(make_shared_no_delete(&space), locale_slSI);
|
||||
Assert::IsTrue(p.match("RF18539007547034", 0, SIZE_MAX));
|
||||
@@ -391,7 +389,6 @@ namespace UnitTests
|
||||
}
|
||||
|
||||
{
|
||||
std::locale locale_slSI("sl_SI");
|
||||
sgml_space_cp space(false, locale_slSI);
|
||||
sgml_si_reference p(make_shared_no_delete(&space), locale_slSI);
|
||||
Assert::IsTrue(p.match("SI121234567890120", 0, SIZE_MAX));
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdex/compat.hpp>
|
||||
#include <stdex/errno.hpp>
|
||||
#include <stdex/exception.hpp>
|
||||
#include <stdex/hash.hpp>
|
||||
#include <stdex/hex.hpp>
|
||||
#include <stdex/idrec.hpp>
|
||||
#include <stdex/interval.hpp>
|
||||
|
Reference in New Issue
Block a user