move tests into the same dir as the main files
parent
7fbeb215d7
commit
88074dacf0
@ -1,47 +1,19 @@
|
||||
#include "Internal.h"
|
||||
#include "MiscUtils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "MiscUtils.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
int compare_result(const vector<string> &expect, const vector<string> &result)
|
||||
{
|
||||
if (result == expect)
|
||||
{
|
||||
cout << "ok\n";
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
cout << "not ok\n";
|
||||
auto e = expect.begin();
|
||||
auto r = result.begin();
|
||||
cout << "# " << setw(20) << left << "Expected" << " " << left << "Got\n";
|
||||
while (e < expect.end() || r < result.end())
|
||||
{
|
||||
cout
|
||||
<< "# "
|
||||
<< setw(20) << left << ":" + (e < expect.end() ? *e++ : "") + ":"
|
||||
<< " "
|
||||
<< setw(20) << left << ":" + (r < result.end() ? *r++ : "") + ":"
|
||||
<< "\n";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
TEST(MiscUtils, wordwrap) {
|
||||
std::vector<std::string> result;
|
||||
|
||||
int main()
|
||||
{
|
||||
int fails = 0;
|
||||
#define TEST_WORDWRAP(label, expect, args) \
|
||||
{ \
|
||||
vector<string> result; \
|
||||
cout << label << "... "; \
|
||||
word_wrap args; \
|
||||
fails += compare_result(expect, result); \
|
||||
}
|
||||
word_wrap(&result, "123", 3);
|
||||
ASSERT_EQ(result.size(), 1);
|
||||
|
||||
TEST_WORDWRAP("Short line, no wrap", vector<string>({"12345"}), (&result, "12345", 15));
|
||||
result.clear();
|
||||
word_wrap(&result, "12345", 3);
|
||||
ASSERT_EQ(result.size(), 2);
|
||||
|
||||
return fails == 0 ? 0 : 1;
|
||||
result.clear();
|
||||
word_wrap(&result, "1234567", 3);
|
||||
ASSERT_EQ(result.size(), 3);
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
file(GLOB_RECURSE TEST_SOURCES
|
||||
LIST_DIRECTORIES false
|
||||
*test.cpp)
|
||||
dfhack_test(test-library "${TEST_SOURCES}")
|
@ -1,19 +0,0 @@
|
||||
|
||||
#include "MiscUtils.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <string>
|
||||
|
||||
TEST(MiscUtils, wordwrap) {
|
||||
std::vector<std::string> result;
|
||||
|
||||
word_wrap(&result, "123", 3);
|
||||
ASSERT_EQ(result.size(), 1);
|
||||
|
||||
result.clear();
|
||||
word_wrap(&result, "12345", 3);
|
||||
ASSERT_EQ(result.size(), 2);
|
||||
|
||||
result.clear();
|
||||
word_wrap(&result, "1234567", 3);
|
||||
ASSERT_EQ(result.size(), 3);
|
||||
}
|
Loading…
Reference in New Issue