コード例 #1
0
ファイル: FUTestBed.cpp プロジェクト: DaDummy/fcolladaCE
bool FUTestBed::RunTestbed(FUTestSuite* headTestSuite)
{
	if (headTestSuite == NULL) return false;

	testPassed = testFailed = 0;

	RunTestSuite(headTestSuite);

	if (isVerbose)
	{
		fileOut.WriteLine("---------------------------------");
		fileOut.WriteLine("Tests passed: %u.", (uint32) testPassed);
		fileOut.WriteLine("Tests failed: %u.", (uint32) testFailed);
		fileOut.WriteLine("");
		fileOut.Flush();

#ifdef _WIN32
		char sz[1024];
		snprintf(sz, 1024, "Testbed score: [%zu/%zu]", testPassed, testFailed + testPassed);
		sz[1023] = 0;

		size_t returnCode = IDOK;
		returnCode = MessageBox(NULL, TO_FSTRING(sz).c_str(), FC("Testbed"), MB_OKCANCEL);
		if (returnCode == IDCANCEL)
		{
			const fm::string filenameUtf8 = FUStringConversion::ToString(filename);
			snprintf(sz, 1024, "write %s ", filenameUtf8.c_str());
			sz[1023] = 0;
			system(sz);
			return false;
		}
#endif
	}
	return true;
}
コード例 #2
0
ファイル: FUStringConversion.cpp プロジェクト: righnatios/0ad
// 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();
	}
}
コード例 #3
0
ファイル: FAXColladaParser.cpp プロジェクト: tweakoz/orkid
	// Calculate the target pointer for a targetable node
	void CalculateNodeTargetPointer(xmlNode* target, fm::string& pointer)
	{
		if (target != NULL)
		{
			// The target node should have either a subid or an id
			if (HasNodeProperty(target, DAE_ID_ATTRIBUTE))
			{
				pointer = ReadNodeId(target);
				return;
			}
			else if (!HasNodeProperty(target, DAE_SID_ATTRIBUTE))
			{
				pointer.clear();
				return;
			}
	
			// Generate a list of parent nodes up to the first properly identified parent
			xmlNodeList traversal;
			traversal.reserve(16);
			traversal.push_back(target);
			xmlNode* current = target->parent;
			while (current != NULL)
			{
				traversal.push_back(current);
				if (HasNodeProperty(current, DAE_ID_ATTRIBUTE)) break;
				current = current->parent;
			}
	
			// The top parent should have the ID property
			FUSStringBuilder builder;
			intptr_t nodeCount = (intptr_t) traversal.size();
			builder.append(ReadNodeId(traversal[nodeCount - 1]));
			if (builder.empty()) { pointer.clear(); return; }
	
			// Build up the target string
			for (intptr_t i = nodeCount - 2; i >= 0; --i)
			{
				xmlNode* node = traversal[i];
				fm::string subId = ReadNodeProperty(node, DAE_SID_ATTRIBUTE);
				if (!subId.empty())
				{
					builder.append('/');
					builder.append(subId);
				}
			}
	
			pointer = builder.ToString();
		}
		else pointer.clear();
	}
コード例 #4
0
ファイル: FUDaeEnum.cpp プロジェクト: BSVino/fcolladaCE
	Interpolation FromString(const fm::string& value)
	{
		if (value == DAE_STEP_INTERPOLATION) return STEP;
		else if (value == DAE_LINEAR_INTERPOLATION) return LINEAR;
		else if (value == DAE_BEZIER_INTERPOLATION) return BEZIER;
		else if (value == DAE_TCB_INTERPOLATION) return TCB;
		else if (value.empty()) return BEZIER; // COLLADA 1.4.1, p4.92: application defined

		else return UNKNOWN;
	}
コード例 #5
0
ファイル: FCDExtra.cpp プロジェクト: Cousken/3DEngine
void FCDENode::CleanName(fm::string& n)
{
	size_t length = n.length();
	if (length == 0) return;

	// First character must be alphabetic or the underscore.
	if (n[0] != '_' && !(n[0] >= 'a' && n[0] <= 'z') && !(n[0] >= 'A' && n[0] <= 'Z'))
	{
		n[0] = '_';
	}

	// Other characters must be alpha-numeric or the underscore.
	for (size_t i = 1; i < length; ++i)
	{
		char& c = n[i];
		if (c != '_' && !(c >= 'a' && c <= 'z') && !(c >= 'A' && c <= 'Z') && !(c >= '0' && c <= '9'))
		{
			c = '_';
		}
	}
}
コード例 #6
0
ファイル: FUStringTest.cpp プロジェクト: Cousken/3DEngine
	PassIf(IsEquivalent("My alter-ego", "My alter-ego"));
	
	FailIf(IsEquivalent("MY ALTER-EGO", "My alter-ego")); // should not be case-sensitive.
	FailIf(IsEquivalent("Utopia", "Utopian"));
	FailIf(IsEquivalent(fm::string("Greatness"), "Great"));
	FailIf(IsEquivalent("Il est", "Il  est"));
	PassIf(IsEquivalent("Prometheian", "Prometheian\0\0\0")); // This is the only difference allowed between two strings.

	fm::string sz1 = "Test1";
	fm::string sz2("Test1");
	PassIf(IsEquivalent(sz1, sz2)); // Extra verification in case the compiler optimizes out the string differences above.

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");
コード例 #7
0
ファイル: FUDaeWriter.cpp プロジェクト: tweakoz/orkid
	void AddNodeSid(xmlNode* node, fm::string& subId)
	{
		subId = AddNodeSid(node, subId.c_str());
	}