本文整理汇总了C++中FileStream::CanWrite方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStream::CanWrite方法的具体用法?C++ FileStream::CanWrite怎么用?C++ FileStream::CanWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStream
的用法示例。
在下文中一共展示了FileStream::CanWrite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteToFile
void JUnitOutput::WriteToFile(const Uri& URI,
const TestResultCollector& Results)
{
// ensure that a new log will be written
File output;
output.SetLocation(URI);
output.Delete();
FileStream out;
out.Open(URI, FileAccessMode::Write, FileAccessPriority::DelayReadWrite);
if (out.CanWrite())
{
//start suites
String tag("<testsuites>\n", sizeof("<testsuites>\n"));
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
for(UInt32 i = 0; i<Results.TestResults().Count(); ++i)
{
//start a suite
tag=String::Format(String("<testsuite error=\"%u\" failures=\"%u\" hostname=\"RadonFramework-TestEnvoirement\" name=\"%s\" tests=\"%u\" time=\"%.3f\" timestamp=\"%s\" id=\"%u\" package=\"%u\">\n",sizeof(
"<testsuite error=\"%u\" failures=\"%u\" hostname=\"RadonFramework-TestEnvoirement\" name=\"%s\" tests=\"%u\" time=\"%.3f\" timestamp=\"%s\" id=\"%u\" package=\"%u\">\n")),
Results.TestResults()[i].TestsWithError,
Results.TestResults()[i].TestsWithFailure,
Results.TestResults()[i].SuiteName.c_str(),
Results.TestResults()[i].TestResults.Count(),
Results.TestResults()[i].TotalTime,
"2007-11-02T23:13:49",
0,
0);
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0 ,tag.Length());
for(UInt32 j = 0; j<Results.TestResults()[i].TestResults.Count(); ++j)
{
//start testcase
tag=String::Format(String("<testcase classname=\"%s\" name=\"%s\" time=\"%d\">\n", sizeof(
"<testcase classname=\"%s\" name=\"%s\" time=\"%d\">\n")),
"",
Results.TestResults()[i].TestResults[j].Name().c_str(),
Results.TestResults()[i].TestResults[j].TimeRequired().Ticks());
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
// test failed
if (!Results.TestResults()[i].TestResults[j].Passed())
{
tag=String::Format(String("<error message=\"%s\" type=\"%s\">%s\n", sizeof(
"<error message=\"%s\" type=\"%s\">%s\n")),
"",
"",
"");
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
tag="</error>\n";
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
}
// test raise an exception
if (Results.TestResults()[i].TestResults[j].Error())
{
tag=String::Format(String("<failure message=\"%s\" type=\"%s\">%s\n",sizeof(
"<failure message=\"%s\" type=\"%s\">%s\n")),
"",
"",
"");
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
tag="</failure>\n";
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
}
//end testcase
tag="</testcase>\n";
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
}
//end the suite
tag="</testsuite>\n";
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
}
//end suites
tag="</testsuites>\n";
out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
}
}