mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 17:04:12 +08:00
small refactor
This commit is contained in:
parent
e494ebc077
commit
551d5ba49d
@ -130,7 +130,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
TEST(
|
||||
{
|
||||
std::wstring test = L"こんにちは";
|
||||
ProcessSentence(test, SentenceInfo{ SentenceInfo::DUMMY });
|
||||
ProcessSentence(test, { SentenceInfo::DUMMY });
|
||||
assert(test.find(L"Hello") != std::wstring::npos);
|
||||
}
|
||||
);
|
||||
|
@ -166,7 +166,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
TEST(
|
||||
{
|
||||
std::wstring test = L"こんにちは";
|
||||
ProcessSentence(test, SentenceInfo{ SentenceInfo::DUMMY });
|
||||
ProcessSentence(test, { SentenceInfo::DUMMY });
|
||||
assert(test.find(L"Hello") != std::wstring::npos);
|
||||
}
|
||||
);
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
using InternetHandle = AutoHandle<Functor<WinHttpCloseHandle>>;
|
||||
|
||||
std::optional<std::wstring> ReceiveHttpRequest(HINTERNET request)
|
||||
inline std::optional<std::wstring> ReceiveHttpRequest(HINTERNET request)
|
||||
{
|
||||
WinHttpReceiveResponse(request, NULL);
|
||||
std::string data;
|
||||
@ -17,14 +17,14 @@ std::optional<std::wstring> ReceiveHttpRequest(HINTERNET request)
|
||||
if (!dwSize) break;
|
||||
std::vector<char> buffer(dwSize);
|
||||
WinHttpReadData(request, buffer.data(), dwSize, &dwDownloaded);
|
||||
data += std::string(buffer.data(), dwDownloaded);
|
||||
data.append(buffer.data(), dwDownloaded);
|
||||
} while (dwSize > 0);
|
||||
|
||||
if (data.empty()) return {};
|
||||
return StringToWideString(data);
|
||||
}
|
||||
|
||||
void Escape(std::wstring& text)
|
||||
inline void Escape(std::wstring& text)
|
||||
{
|
||||
for (int i = 0; i < text.size(); ++i)
|
||||
{
|
||||
|
@ -61,11 +61,10 @@ TEST(
|
||||
RemoveCyclicRepeats(cyclicRepeats);
|
||||
assert(cyclicRepeats == L"abcdefg");
|
||||
|
||||
InfoForExtension tester{ "hook address", 0 };
|
||||
std::wstring empty = L"", one = L" ", normal = L"This is a normal sentence. はい";
|
||||
ProcessSentence(empty, { &tester });
|
||||
ProcessSentence(one, { &tester });
|
||||
ProcessSentence(normal, { &tester });
|
||||
ProcessSentence(empty, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(one, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(normal, { SentenceInfo::DUMMY });
|
||||
assert(empty == L"" && one == L" " && normal == L"This is a normal sentence. はい");
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user