lazy man's mocking
This commit is contained in:
parent
1a17043924
commit
2436571768
@ -15,10 +15,8 @@ struct SentenceInfo
|
||||
{
|
||||
for (auto info = infoArray; info->name; ++info) // nullptr name marks end of info array
|
||||
if (propertyName == info->name) return info->value;
|
||||
return *(int*)0xcccc = 0; // gives better error message than alternatives
|
||||
return *(int*)0xDEAD = 0; // gives better error message than alternatives
|
||||
}
|
||||
|
||||
inline static InfoForExtension DUMMY[2] = { { "text number", 1 } };
|
||||
};
|
||||
|
||||
struct SKIP {};
|
||||
|
@ -41,14 +41,16 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
|
||||
TEST(
|
||||
{
|
||||
InfoForExtension nonConsole[] = { { "text number", 1 }, {} };
|
||||
|
||||
std::wstring repeatedChars = L"aaaaaaaaaaaabbbbbbcccdddaabbbcccddd";
|
||||
ProcessSentence(repeatedChars, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(repeatedChars, { nonConsole });
|
||||
assert(repeatedChars.find(L"aaaabbcd") == 0);
|
||||
|
||||
std::wstring empty = L"", one = L" ", normal = L"This is a normal sentence. はい";
|
||||
ProcessSentence(empty, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(one, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(normal, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(empty, { nonConsole });
|
||||
ProcessSentence(one, { nonConsole });
|
||||
ProcessSentence(normal, { nonConsole });
|
||||
assert(empty == L"" && one == L" " && normal == L"This is a normal sentence. はい");
|
||||
}
|
||||
);
|
||||
|
@ -77,20 +77,22 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
|
||||
TEST(
|
||||
{
|
||||
InfoForExtension nonConsole[] = { { "text number", 1 }, {} };
|
||||
|
||||
std::wstring cyclicRepeats = L"Name: '_abcdefg_abcdefg_abcdefg_abcdefg_abcdefg'";
|
||||
std::wstring buildupRepeats = L"Name: '__a_ab_abc_abcd_abcde_abcdef_abcdefg'";
|
||||
std::wstring breakdownRepeats = L"Name: '_abcdefg_abcdef_abcde_abcd_abc_ab_a_'";
|
||||
ProcessSentence(cyclicRepeats, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(buildupRepeats, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(breakdownRepeats, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(cyclicRepeats, { nonConsole });
|
||||
ProcessSentence(buildupRepeats, { nonConsole });
|
||||
ProcessSentence(breakdownRepeats, { nonConsole });
|
||||
assert(cyclicRepeats == L"Name: '_abcdefg'");
|
||||
assert(buildupRepeats == L"Name: '_abcdefg'");
|
||||
assert(breakdownRepeats == L"Name: '_abcdefg'");
|
||||
|
||||
std::wstring empty = L"", one = L" ", normal = L"This is a normal sentence. はい";
|
||||
ProcessSentence(empty, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(one, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(normal, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(empty, { nonConsole });
|
||||
ProcessSentence(one, { nonConsole });
|
||||
ProcessSentence(normal, { nonConsole });
|
||||
assert(empty == L"" && one == L" " && normal == L"This is a normal sentence. はい");
|
||||
}
|
||||
);
|
||||
|
@ -35,17 +35,19 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
|
||||
TEST(
|
||||
{
|
||||
InfoForExtension nonConsole[] = { { "text number", 1 }, {} };
|
||||
|
||||
std::wstring cyclicRepeats = L"_abcde_abcdef_abcdefg_abcdefg_abcdefg_abcdefg_abcdefg";
|
||||
std::wstring buildupRepeats = L"__a_ab_abc_abcd_abcde_abcdef_abcdefg";
|
||||
ProcessSentence(cyclicRepeats, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(buildupRepeats, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(cyclicRepeats, { nonConsole });
|
||||
ProcessSentence(buildupRepeats, { nonConsole });
|
||||
assert(cyclicRepeats == L"_abcdefg");
|
||||
assert(buildupRepeats == L"_abcdefg");
|
||||
|
||||
std::wstring empty = L"", one = L" ", normal = L"This is a normal sentence. はい";
|
||||
ProcessSentence(empty, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(one, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(normal, { SentenceInfo::DUMMY });
|
||||
ProcessSentence(empty, { nonConsole });
|
||||
ProcessSentence(one, { nonConsole });
|
||||
ProcessSentence(normal, { nonConsole });
|
||||
assert(empty == L"" && one == L" " && normal == L"This is a normal sentence. はい");
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user