Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
43226891
Commit
43226891
authored
Sep 10, 2011
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started Node tests (for the new API Node)
parent
2d06df47
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
+76
-0
test/new-api/nodetests.cpp
+57
-0
test/nodetests.h
+13
-0
test/tests.cpp
+6
-0
No files found.
test/new-api/nodetests.cpp
0 → 100644
View file @
43226891
#include "nodetests.h"
#include "yaml-cpp/yaml.h"
namespace
{
struct
TEST
{
TEST
()
:
ok
(
false
)
{}
TEST
(
bool
ok_
)
:
ok
(
ok_
)
{}
TEST
(
const
char
*
error_
)
:
ok
(
false
),
error
(
error_
)
{}
bool
ok
;
std
::
string
error
;
};
}
#define YAML_ASSERT(cond) do { if(!(cond)) return " Assert failed: " #cond; } while(false)
namespace
Test
{
namespace
Node
{
TEST
SimpleScalar
()
{
YAML
::
Node
node
=
YAML
::
Node
(
"Hello, World!"
);
YAML_ASSERT
(
node
.
Type
()
==
YAML
::
NodeType
::
Scalar
);
YAML_ASSERT
(
node
.
as
<
std
::
string
>
()
==
"Hello, World!"
);
return
true
;
}
}
void
RunNodeTest
(
TEST
(
*
test
)(),
const
std
::
string
&
name
,
int
&
passed
,
int
&
total
)
{
TEST
ret
;
try
{
ret
=
test
();
}
catch
(...)
{
ret
.
ok
=
false
;
}
if
(
ret
.
ok
)
{
passed
++
;
}
else
{
std
::
cout
<<
"Node test failed: "
<<
name
<<
"
\n
"
;
if
(
ret
.
error
!=
""
)
std
::
cout
<<
ret
.
error
<<
"
\n
"
;
}
total
++
;
}
bool
RunNodeTests
()
{
int
passed
=
0
;
int
total
=
0
;
RunNodeTest
(
&
Node
::
SimpleScalar
,
"simple scalar"
,
passed
,
total
);
std
::
cout
<<
"Node tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
return
passed
==
total
;
}
}
test/nodetests.h
0 → 100644
View file @
43226891
#ifndef NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
namespace
Test
{
bool
RunNodeTests
();
}
#endif // NODETESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A6666
test/tests.cpp
View file @
43226891
#include "tests.h"
#include "tests.h"
#include "emittertests.h"
#include "emittertests.h"
#include "nodetests.h"
#include "parsertests.h"
#include "parsertests.h"
#include "spectests.h"
#include "spectests.h"
#include "yaml-cpp/yaml.h"
#include "yaml-cpp/yaml.h"
...
@@ -21,6 +22,11 @@ namespace Test
...
@@ -21,6 +22,11 @@ namespace Test
if
(
!
RunSpecTests
())
if
(
!
RunSpecTests
())
passed
=
false
;
passed
=
false
;
#ifndef YAML_CPP_OLD_API
if
(
!
RunNodeTests
())
passed
=
false
;
#endif
if
(
passed
)
if
(
passed
)
std
::
cout
<<
"All tests passed!
\n
"
;
std
::
cout
<<
"All tests passed!
\n
"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment