mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Moved the testing source to the yaml-reader folder.
This commit is contained in:
@@ -1,81 +0,0 @@
|
|||||||
#include "tests.h"
|
|
||||||
#include "parser.h"
|
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace YAML
|
|
||||||
{
|
|
||||||
namespace Test
|
|
||||||
{
|
|
||||||
// runs all the tests on all data we have
|
|
||||||
void RunAll()
|
|
||||||
{
|
|
||||||
std::vector <std::string> files;
|
|
||||||
files.push_back("tests/simple.yaml");
|
|
||||||
files.push_back("tests/mixed.yaml");
|
|
||||||
files.push_back("tests/scalars.yaml");
|
|
||||||
files.push_back("tests/directives.yaml");
|
|
||||||
|
|
||||||
bool passed = true;
|
|
||||||
for(unsigned i=0;i<files.size();i++) {
|
|
||||||
if(!YAML::Test::Inout(files[i])) {
|
|
||||||
std::cout << "Inout test failed on " << files[i] << std::endl;
|
|
||||||
passed = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passed)
|
|
||||||
std::cout << "All tests passed!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// loads the given YAML file, outputs it, and then loads the outputted file,
|
|
||||||
// outputs again, and makes sure that the two outputs are the same
|
|
||||||
bool Inout(const std::string& file)
|
|
||||||
{
|
|
||||||
std::ifstream fin(file.c_str());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// read and output
|
|
||||||
Parser parser(fin);
|
|
||||||
if(!parser)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Node doc;
|
|
||||||
parser.GetNextDocument(doc);
|
|
||||||
|
|
||||||
std::stringstream out;
|
|
||||||
out << doc;
|
|
||||||
// and save
|
|
||||||
std::string firstTry = out.str();
|
|
||||||
|
|
||||||
// and now again
|
|
||||||
parser.Load(out);
|
|
||||||
if(!parser)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
parser.GetNextDocument(doc);
|
|
||||||
std::stringstream out2;
|
|
||||||
out2 << doc;
|
|
||||||
// and save
|
|
||||||
std::string secondTry = out2.str();
|
|
||||||
|
|
||||||
// now compare
|
|
||||||
if(firstTry == secondTry)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
std::ofstream fout("tests/out.yaml");
|
|
||||||
fout << "---\n";
|
|
||||||
fout << firstTry << std::endl;
|
|
||||||
fout << "---\n";
|
|
||||||
fout << secondTry << std::endl;
|
|
||||||
} catch(ParserException& e) {
|
|
||||||
std::cout << file << " (line " << e.line + 1 << ", col " << e.column + 1 << "): " << e.msg << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
10
src/tests.h
10
src/tests.h
@@ -1,10 +0,0 @@
|
|||||||
#include <string>
|
|
||||||
|
|
||||||
namespace YAML
|
|
||||||
{
|
|
||||||
namespace Test {
|
|
||||||
void RunAll();
|
|
||||||
|
|
||||||
bool Inout(const std::string& file);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,5 +0,0 @@
|
|||||||
%YAML 1.2
|
|
||||||
%TAG ! !howdy
|
|
||||||
---
|
|
||||||
- basic node
|
|
||||||
- ! yeah baby
|
|
@@ -1,32 +0,0 @@
|
|||||||
- the main thing is a sequence
|
|
||||||
- here's a key: value
|
|
||||||
and another: value
|
|
||||||
- let's inline: [1, 2, 3]
|
|
||||||
and an inline map: {key: value, 243: 101}
|
|
||||||
- and multiple indents:
|
|
||||||
- here's
|
|
||||||
- a
|
|
||||||
- list
|
|
||||||
and another:
|
|
||||||
- list
|
|
||||||
- of
|
|
||||||
- things
|
|
||||||
- maybe now:
|
|
||||||
let's: get
|
|
||||||
pretty:
|
|
||||||
deep: here
|
|
||||||
in:
|
|
||||||
the: nesting
|
|
||||||
just: to
|
|
||||||
confuse:
|
|
||||||
the: heck
|
|
||||||
out:
|
|
||||||
- of
|
|
||||||
- the: parser
|
|
||||||
if:
|
|
||||||
- we
|
|
||||||
- can
|
|
||||||
- do: that
|
|
||||||
what: do
|
|
||||||
you: think?
|
|
||||||
|
|
@@ -1,8 +0,0 @@
|
|||||||
---
|
|
||||||
- "basic node"
|
|
||||||
- !<!howdy> "yeah baby"
|
|
||||||
|
|
||||||
---
|
|
||||||
- "basic node"
|
|
||||||
- !<!<!howdy>> "yeah baby"
|
|
||||||
|
|
@@ -1,35 +0,0 @@
|
|||||||
- normal scalar, but
|
|
||||||
over several lines
|
|
||||||
- |
|
|
||||||
literal scalar - so we can draw ASCII:
|
|
||||||
|
|
||||||
- -
|
|
||||||
| - |
|
|
||||||
------
|
|
||||||
- >
|
|
||||||
and a folded scalar... so we
|
|
||||||
can just keep writing various
|
|
||||||
things. And if we want to keep indentation:
|
|
||||||
|
|
||||||
we just indent a little
|
|
||||||
see, this stays indented
|
|
||||||
- >-
|
|
||||||
Here's a folded scalar
|
|
||||||
that gets chomped.
|
|
||||||
- |-
|
|
||||||
And here's a literal scalar
|
|
||||||
that gets chomped.
|
|
||||||
- >2
|
|
||||||
Here's a folded scalar
|
|
||||||
that starts with some indentation.
|
|
||||||
- ::vector
|
|
||||||
- ": - ()"
|
|
||||||
- Up, up, and away!
|
|
||||||
- -123
|
|
||||||
- http://example.com/foo#bar
|
|
||||||
# Inside flow collection:
|
|
||||||
- [ ::vector,
|
|
||||||
": - ()",
|
|
||||||
"Up, up and away!",
|
|
||||||
-123,
|
|
||||||
http://example.com/foo#bar ]
|
|
@@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
just a scalar
|
|
||||||
---
|
|
||||||
and another scalar
|
|
||||||
---
|
|
||||||
now an end document
|
|
||||||
...
|
|
||||||
---
|
|
||||||
and now two
|
|
||||||
...
|
|
||||||
...
|
|
||||||
---
|
|
||||||
and that's it
|
|
@@ -166,11 +166,11 @@
|
|||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\main.cpp"
|
RelativePath=".\yaml-reader\main.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\tests.cpp"
|
RelativePath=".\yaml-reader\tests.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\tests.h"
|
RelativePath=".\yaml-reader\tests.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -190,23 +190,23 @@
|
|||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\tests\directives.yaml"
|
RelativePath=".\yaml-reader\tests\directives.yaml"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\tests\mixed.yaml"
|
RelativePath=".\yaml-reader\tests\mixed.yaml"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\tests\scalars.yaml"
|
RelativePath=".\yaml-reader\tests\scalars.yaml"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\tests\simple.yaml"
|
RelativePath=".\yaml-reader\tests\simple.yaml"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\test.yaml"
|
RelativePath=".\yaml-reader\test.yaml"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@@ -2,6 +2,9 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
# Visual Studio 2008
|
# Visual Studio 2008
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yaml-reader", "yaml-reader.vcproj", "{E8CC0D8A-D784-4A6B-B78B-ACEA13F9FB0B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yaml-reader", "yaml-reader.vcproj", "{E8CC0D8A-D784-4A6B-B78B-ACEA13F9FB0B}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{3104AB4E-CD31-4F47-95E9-0E8D9374E15D} = {3104AB4E-CD31-4F47-95E9-0E8D9374E15D}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yamlcpp", "yamlcpp.vcproj", "{3104AB4E-CD31-4F47-95E9-0E8D9374E15D}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yamlcpp", "yamlcpp.vcproj", "{3104AB4E-CD31-4F47-95E9-0E8D9374E15D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="include"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@@ -105,6 +106,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
|
AdditionalIncludeDirectories="include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
|
Reference in New Issue
Block a user