mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Tweaked node iterator tests
This commit is contained in:
@@ -332,18 +332,24 @@ namespace Test
|
|||||||
int seq[] = {1, 3, 5, 7};
|
int seq[] = {1, 3, 5, 7};
|
||||||
int i=0;
|
int i=0;
|
||||||
for(YAML::const_iterator it=node.begin();it!=node.end();++it) {
|
for(YAML::const_iterator it=node.begin();it!=node.end();++it) {
|
||||||
|
YAML_ASSERT(i < 4);
|
||||||
int x = seq[i++];
|
int x = seq[i++];
|
||||||
YAML_ASSERT(it->as<int>() == x);
|
YAML_ASSERT(it->as<int>() == x);
|
||||||
}
|
}
|
||||||
|
YAML_ASSERT(i == 4);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST IterateMap()
|
TEST IterateMap()
|
||||||
{
|
{
|
||||||
YAML::Node node = YAML::Load("{a: A, b: B, c: C}");
|
YAML::Node node = YAML::Load("{a: A, b: B, c: C}");
|
||||||
|
int i=0;
|
||||||
for(YAML::const_iterator it=node.begin();it!=node.end();++it) {
|
for(YAML::const_iterator it=node.begin();it!=node.end();++it) {
|
||||||
|
YAML_ASSERT(i < 3);
|
||||||
|
i++;
|
||||||
YAML_ASSERT(it->first.as<char>() + 'A' - 'a' == it->second.as<char>());
|
YAML_ASSERT(it->first.as<char>() + 'A' - 'a' == it->second.as<char>());
|
||||||
}
|
}
|
||||||
|
YAML_ASSERT(i == 3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user