mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Set the eol style to native for all files.
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
#include "yaml.h"
|
||||
#include "tests.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib, "yamlcppd.lib")
|
||||
#else
|
||||
#pragma comment(lib, "yamlcpp.lib")
|
||||
#endif // _DEBUG
|
||||
#endif // _MSC_VER
|
||||
|
||||
void run()
|
||||
{
|
||||
std::ifstream fin("tests/test.yaml");
|
||||
|
||||
try {
|
||||
YAML::Parser parser(fin);
|
||||
parser.PrintTokens(std::cout);
|
||||
} catch(YAML::Exception&) {
|
||||
std::cout << "Error parsing the yaml!\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
bool verbose = false;
|
||||
for(int i=1;i<argc;i++) {
|
||||
if(strcmp(argv[i], "-v") == 0)
|
||||
verbose = true;
|
||||
}
|
||||
|
||||
#ifdef WINDOWS
|
||||
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);
|
||||
#endif // WINDOWS
|
||||
Test::RunAll(verbose);
|
||||
run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include "yaml.h"
|
||||
#include "tests.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib, "yamlcppd.lib")
|
||||
#else
|
||||
#pragma comment(lib, "yamlcpp.lib")
|
||||
#endif // _DEBUG
|
||||
#endif // _MSC_VER
|
||||
|
||||
void run()
|
||||
{
|
||||
std::ifstream fin("tests/test.yaml");
|
||||
|
||||
try {
|
||||
YAML::Parser parser(fin);
|
||||
parser.PrintTokens(std::cout);
|
||||
} catch(YAML::Exception&) {
|
||||
std::cout << "Error parsing the yaml!\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
bool verbose = false;
|
||||
for(int i=1;i<argc;i++) {
|
||||
if(strcmp(argv[i], "-v") == 0)
|
||||
verbose = true;
|
||||
}
|
||||
|
||||
#ifdef WINDOWS
|
||||
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);
|
||||
#endif // WINDOWS
|
||||
Test::RunAll(verbose);
|
||||
run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,88 +1,88 @@
|
||||
#include "yaml.h"
|
||||
#include "tests.h"
|
||||
#include "parser.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
namespace Test
|
||||
{
|
||||
// runs all the tests on all data we have
|
||||
void RunAll(bool verbose)
|
||||
{
|
||||
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(!Inout(files[i], verbose)) {
|
||||
std::cout << "Inout test failed on " << files[i] << "\n";
|
||||
passed = false;
|
||||
} else
|
||||
std::cout << "Inout test passed: " << files[i] << "\n";
|
||||
}
|
||||
|
||||
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, bool verbose)
|
||||
{
|
||||
std::ifstream fin(file.c_str());
|
||||
|
||||
try {
|
||||
// read and output
|
||||
YAML::Parser parser(fin);
|
||||
if(!parser)
|
||||
return false;
|
||||
|
||||
YAML::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(YAML::ParserException& e) {
|
||||
std::cout << file << " (line " << e.line + 1 << ", col " << e.column + 1 << "): " << e.msg << std::endl;
|
||||
|
||||
if(verbose) {
|
||||
std::cout << "Token queue:\n";
|
||||
std::ifstream f(file.c_str());
|
||||
YAML::Parser p(f);
|
||||
p.PrintTokens(std::cout);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#include "yaml.h"
|
||||
#include "tests.h"
|
||||
#include "parser.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
namespace Test
|
||||
{
|
||||
// runs all the tests on all data we have
|
||||
void RunAll(bool verbose)
|
||||
{
|
||||
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(!Inout(files[i], verbose)) {
|
||||
std::cout << "Inout test failed on " << files[i] << "\n";
|
||||
passed = false;
|
||||
} else
|
||||
std::cout << "Inout test passed: " << files[i] << "\n";
|
||||
}
|
||||
|
||||
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, bool verbose)
|
||||
{
|
||||
std::ifstream fin(file.c_str());
|
||||
|
||||
try {
|
||||
// read and output
|
||||
YAML::Parser parser(fin);
|
||||
if(!parser)
|
||||
return false;
|
||||
|
||||
YAML::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(YAML::ParserException& e) {
|
||||
std::cout << file << " (line " << e.line + 1 << ", col " << e.column + 1 << "): " << e.msg << std::endl;
|
||||
|
||||
if(verbose) {
|
||||
std::cout << "Token queue:\n";
|
||||
std::ifstream f(file.c_str());
|
||||
YAML::Parser p(f);
|
||||
p.PrintTokens(std::cout);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <string>
|
||||
|
||||
namespace Test {
|
||||
void RunAll(bool verbose);
|
||||
bool Inout(const std::string& file, bool verbose);
|
||||
}
|
||||
#include <string>
|
||||
|
||||
namespace Test {
|
||||
void RunAll(bool verbose);
|
||||
bool Inout(const std::string& file, bool verbose);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
%YAML 1.2
|
||||
%TAG ! !howdy
|
||||
---
|
||||
- basic node
|
||||
%YAML 1.2
|
||||
%TAG ! !howdy
|
||||
---
|
||||
- basic node
|
||||
- ! yeah baby
|
@@ -1,32 +1,32 @@
|
||||
- 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?
|
||||
- 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,35 +1,35 @@
|
||||
- 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,
|
||||
- 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 +1,13 @@
|
||||
---
|
||||
just a scalar
|
||||
---
|
||||
and another scalar
|
||||
---
|
||||
now an end document
|
||||
...
|
||||
---
|
||||
and now two
|
||||
...
|
||||
...
|
||||
---
|
||||
---
|
||||
just a scalar
|
||||
---
|
||||
and another scalar
|
||||
---
|
||||
now an end document
|
||||
...
|
||||
---
|
||||
and now two
|
||||
...
|
||||
...
|
||||
---
|
||||
and that's it
|
@@ -1,3 +1,3 @@
|
||||
- it's just
|
||||
- one thing
|
||||
- after another
|
||||
- it's just
|
||||
- one thing
|
||||
- after another
|
||||
|
Reference in New Issue
Block a user