Moved the testing source to the yaml-reader folder.

This commit is contained in:
Jesse Beder
2008-07-14 05:18:25 +00:00
parent 2e2c489e29
commit 2eab1e025e
11 changed files with 13 additions and 192 deletions

View File

@@ -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;
}
}
}

View File

@@ -1,10 +0,0 @@
#include <string>
namespace YAML
{
namespace Test {
void RunAll();
bool Inout(const std::string& file);
}
}

View File

@@ -1,5 +0,0 @@
%YAML 1.2
%TAG ! !howdy
---
- basic node
- ! yeah baby

View File

@@ -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?

View File

@@ -1,8 +0,0 @@
---
- "basic node"
- !<!howdy> "yeah baby"
---
- "basic node"
- !<!<!howdy>> "yeah baby"

View File

@@ -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 ]

View File

@@ -1,13 +0,0 @@
---
just a scalar
---
and another scalar
---
now an end document
...
---
and now two
...
...
---
and that's it

View File

@@ -166,11 +166,11 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\main.cpp"
RelativePath=".\yaml-reader\main.cpp"
>
</File>
<File
RelativePath=".\src\tests.cpp"
RelativePath=".\yaml-reader\tests.cpp"
>
</File>
</Filter>
@@ -180,7 +180,7 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\src\tests.h"
RelativePath=".\yaml-reader\tests.h"
>
</File>
</Filter>
@@ -190,23 +190,23 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\tests\directives.yaml"
RelativePath=".\yaml-reader\tests\directives.yaml"
>
</File>
<File
RelativePath=".\tests\mixed.yaml"
RelativePath=".\yaml-reader\tests\mixed.yaml"
>
</File>
<File
RelativePath=".\tests\scalars.yaml"
RelativePath=".\yaml-reader\tests\scalars.yaml"
>
</File>
<File
RelativePath=".\tests\simple.yaml"
RelativePath=".\yaml-reader\tests\simple.yaml"
>
</File>
<File
RelativePath=".\test.yaml"
RelativePath=".\yaml-reader\test.yaml"
>
</File>
</Filter>

View File

@@ -2,6 +2,9 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
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
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yamlcpp", "yamlcpp.vcproj", "{3104AB4E-CD31-4F47-95E9-0E8D9374E15D}"
EndProject

View File

@@ -41,6 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -105,6 +106,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"