예제 #1
0
// Split the target string into its pointer and its qualifier(s)
void FUStringConversion::SplitTarget(const fm::string& target, fm::string& pointer, fm::string& qualifier)
{
	size_t splitIndex = target.find_first_of("([.");
	if (splitIndex != fm::string::npos)
	{
		pointer = target.substr(0, splitIndex);
		qualifier = target.substr(splitIndex);
	}
	else
	{
		pointer = target;
		qualifier.clear();
	}
}
예제 #2
0
TESTSUITE_TEST(1, StringTemplate)
	// Not looking to verify all the combinations,
	// but I do want to exercise all the basic functionality.
	fm::string a("TEST1"), b(a), c("TEST2"), d("VIRUSES", 5), e(3, 'C'), f("abc", 10);
	
	PassIf(d.length() == 5);
	PassIf(f.length() == 10);
	PassIf(IsEquivalent(a, "TEST1"));
	PassIf(a == b);
	PassIf(IsEquivalent(a, b));
	PassIf(a[0] == 'T');
	PassIf(IsEquivalent(d, "VIRUS"));
	PassIf(IsEquivalent(e, "CCC"));
	PassIf(a.length() == 5);
	PassIf(a.substr(0, 4) == c.substr(0, 4));
	FailIf(a == c);
	PassIf(a < c);

	e.append("4");
	b.append(a);
	PassIf(IsEquivalent(e, "CCC4"));
	PassIf(IsEquivalent(b, "TEST1TEST1"));
	PassIf(b.find("TEST1", 0) == 0);
	PassIf(b.find("TEST1", 2) == 5);
	PassIf(b.find("TEST1", 5) == 5);
	PassIf(b.find("TEST1", 7) == fm::string::npos);
	FailIf(c.find("TEST1") != fm::string::npos);
	PassIf(IsEquivalent(a.c_str(), "TEST1"));
	PassIf(d.find_first_of("RST") == 2);
	PassIf(c.find_last_of("T") == 3);