Files
textmate/Frameworks/selection/tests/t_all_words.cc
Allan Odgaard 9894969e67 Initial commit
2012-08-09 16:25:56 +02:00

27 lines
855 B
C++

#include <buffer/buffer.h>
#include <selection/selection.h>
#include <text/format.h>
class AllWordsTests : public CxxTest::TestSuite
{
std::string all_words (ng::buffer_t const& buf)
{
std::vector<std::string> res;
citerate(range, ng::all_words(buf))
res.push_back(buf.substr(range->first.index, range->last.index));
return text::join(res, ", ");
}
public:
void test_all_words ()
{
TS_ASSERT_EQUALS(all_words("foo_bar"), "foo_bar");
TS_ASSERT_EQUALS(all_words("foo-bar"), "foo, bar");
TS_ASSERT_EQUALS(all_words(" foo-bar"), "foo, bar");
TS_ASSERT_EQUALS(all_words(" foo-bar "), "foo, bar");
TS_ASSERT_EQUALS(all_words("Ac̄̌count—æblegrød"), "Ac̄̌count, æblegrød");
TS_ASSERT_EQUALS(all_words("南野 繁弘.\n"), "南野, 繁弘");
TS_ASSERT_EQUALS(all_words("Surrogate: “𠻵”.\n"), "Surrogate, 𠻵");
}
};