Fixed emitting colon at end of scalar bug

This commit is contained in:
Jesse Beder 2010-12-03 21:52:04 +00:00
parent 99089bf218
commit 337cb553d0
3 changed files with 26 additions and 3 deletions

View File

@ -5,8 +5,8 @@ project (YAML_CPP)
set(LIB_TYPE SHARED)
if(IPHONE)
set(CMAKE_OSX_SYSROOT iphoneos4.0)
set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT))
set(CMAKE_OSX_SYSROOT iphoneos4.2)
set(CMAKE_OSX_ARCHITECTURES "armv6;armv7")
set(LIB_TYPE)
endif(IPHONE)

View File

@ -58,7 +58,13 @@ namespace YAML
template<>
inline bool RegEx::IsValidSource<StringCharSource>(const StringCharSource&source) const
{
return source || m_op == REGEX_EMPTY;
switch(m_op) {
case REGEX_MATCH:
case REGEX_RANGE:
return source;
default:
return true;
}
}
template <typename Source>

View File

@ -726,6 +726,21 @@ namespace Test
out << YAML::Binary("", 0);
desiredOutput = "--- !!binary \"\"";
}
void ColonAtEndOfScalar(YAML::Emitter& out, std::string& desiredOutput)
{
out << "a:";
desiredOutput = "--- \"a:\"";
}
void ColonAsScalar(YAML::Emitter& out, std::string& desiredOutput)
{
out << YAML::BeginMap;
out << YAML::Key << "apple" << YAML::Value << ":";
out << YAML::Key << "banana" << YAML::Value << ":";
out << YAML::EndMap;
desiredOutput = "---\napple: \":\"\nbanana: \":\"";
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// incorrect emitting
@ -916,6 +931,8 @@ namespace Test
RunEmitterTest(&Emitter::Binary, "binary", passed, total);
RunEmitterTest(&Emitter::LongBinary, "long binary", passed, total);
RunEmitterTest(&Emitter::EmptyBinary, "empty binary", passed, total);
RunEmitterTest(&Emitter::ColonAtEndOfScalar, "colon at end of scalar", passed, total);
RunEmitterTest(&Emitter::ColonAsScalar, "colon as scalar", passed, total);
RunEmitterErrorTest(&Emitter::ExtraEndSeq, "extra EndSeq", passed, total);
RunEmitterErrorTest(&Emitter::ExtraEndMap, "extra EndMap", passed, total);