mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Added api sketch
This commit is contained in:
10
test/CMakeLists.txt
Normal file
10
test/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
file(GLOB test_headers [a-z]*.h)
|
||||
file(GLOB test_sources [a-z]*.cpp)
|
||||
|
||||
add_executable(run-tests
|
||||
${test_sources}
|
||||
${test_headers}
|
||||
)
|
||||
target_link_libraries(run-tests yaml-cpp)
|
||||
|
||||
add_test(yaml-reader-test run-tests)
|
1077
test/emittertests.cpp
Normal file
1077
test/emittertests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
13
test/emittertests.h
Normal file
13
test/emittertests.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace Test {
|
||||
bool RunEmitterTests();
|
||||
}
|
||||
|
||||
#endif // EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
7
test/main.cpp
Normal file
7
test/main.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "tests.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
Test::RunAll();
|
||||
return 0;
|
||||
}
|
1161
test/parsertests.cpp
Normal file
1161
test/parsertests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
13
test/parsertests.h
Normal file
13
test/parsertests.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace Test {
|
||||
bool RunParserTests();
|
||||
}
|
||||
|
||||
#endif // PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
2445
test/spectests.cpp
Normal file
2445
test/spectests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
13
test/spectests.h
Normal file
13
test/spectests.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace Test {
|
||||
bool RunSpecTests();
|
||||
}
|
||||
|
||||
#endif // SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
29
test/tests.cpp
Normal file
29
test/tests.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "tests.h"
|
||||
#include "emittertests.h"
|
||||
#include "parsertests.h"
|
||||
#include "spectests.h"
|
||||
#include "yaml-cpp/yaml.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
namespace Test
|
||||
{
|
||||
void RunAll()
|
||||
{
|
||||
bool passed = true;
|
||||
if(!RunParserTests())
|
||||
passed = false;
|
||||
|
||||
if(!RunEmitterTests())
|
||||
passed = false;
|
||||
|
||||
if(!RunSpecTests())
|
||||
passed = false;
|
||||
|
||||
if(passed)
|
||||
std::cout << "All tests passed!\n";
|
||||
}
|
||||
}
|
||||
|
53
test/tests.h
Normal file
53
test/tests.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
#define TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||
|
||||
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Test {
|
||||
void RunAll();
|
||||
|
||||
namespace Parser {
|
||||
// scalar tests
|
||||
void SimpleScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void MultiLineScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void LiteralScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void FoldedScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void ChompedFoldedScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void ChompedLiteralScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void FoldedScalarWithIndent(std::string& inputScalar, std::string& desiredOutput);
|
||||
void ColonScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void QuotedScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void CommaScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void DashScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
void URLScalar(std::string& inputScalar, std::string& desiredOutput);
|
||||
|
||||
// misc tests
|
||||
bool SimpleSeq();
|
||||
bool SimpleMap();
|
||||
bool FlowSeq();
|
||||
bool FlowMap();
|
||||
bool FlowMapWithOmittedKey();
|
||||
bool FlowMapWithOmittedValue();
|
||||
bool FlowMapWithSoloEntry();
|
||||
bool FlowMapEndingWithSoloEntry();
|
||||
bool QuotedSimpleKeys();
|
||||
bool CompressedMapAndSeq();
|
||||
bool NullBlockSeqEntry();
|
||||
bool NullBlockMapKey();
|
||||
bool NullBlockMapValue();
|
||||
bool SimpleAlias();
|
||||
bool AliasWithNull();
|
||||
bool AnchorInSimpleKey();
|
||||
bool AliasAsSimpleKey();
|
||||
bool ExplicitDoc();
|
||||
bool MultipleDocs();
|
||||
bool ExplicitEndDoc();
|
||||
bool MultipleDocsWithSomeExplicitIndicators();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
Reference in New Issue
Block a user