Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
ebf14ec8
Commit
ebf14ec8
authored
Mar 23, 2014
by
Jesse Beder
Browse files
Factored out HandlerTest as a base class
parent
066b71a7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
53 deletions
+37
-53
test/handler_test.h
test/handler_test.h
+32
-0
test/integration/handler_spec_test.cpp
test/integration/handler_spec_test.cpp
+3
-26
test/integration/handler_test.cpp
test/integration/handler_test.cpp
+2
-27
No files found.
test/handler_test.h
0 → 100644
View file @
ebf14ec8
#include "mock_event_handler.h"
#include "yaml-cpp/yaml.h" // IWYU pragma: keep
#include "gmock/gmock.h"
#include "gtest/gtest.h"
using
::
testing
::
InSequence
;
using
::
testing
::
NiceMock
;
using
::
testing
::
StrictMock
;
namespace
YAML
{
class
HandlerTest
:
public
::
testing
::
Test
{
protected:
void
Parse
(
const
std
::
string
&
example
)
{
std
::
stringstream
stream
(
example
);
Parser
parser
(
stream
);
while
(
parser
.
HandleNextDocument
(
handler
))
{
}
}
void
IgnoreParse
(
const
std
::
string
&
example
)
{
std
::
stringstream
stream
(
example
);
Parser
parser
(
stream
);
while
(
parser
.
HandleNextDocument
(
nice_handler
))
{
}
}
InSequence
sequence
;
StrictMock
<
MockEventHandler
>
handler
;
NiceMock
<
MockEventHandler
>
nice_handler
;
};
}
test/integration/handler_spec_test.cpp
View file @
ebf14ec8
#include "
mock_event_
handler.h"
#include "handler
_test
.h"
#include "specexamples.h" // IWYU pragma: keep
#include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/yaml.h" // IWYU pragma: keep
#include "gmock/gmock.h"
#include "gtest/gtest.h"
using
::
testing
::
_
;
using
::
testing
::
InSequence
;
using
::
testing
::
NiceMock
;
using
::
testing
::
StrictMock
;
#define EXPECT_THROW_PARSER_EXCEPTION(statement, message) \
ASSERT_THROW(statement, ParserException); \
...
...
@@ -23,26 +19,7 @@ using ::testing::StrictMock;
namespace
YAML
{
namespace
{
class
HandlerSpecTest
:
public
::
testing
::
Test
{
protected:
void
Parse
(
const
std
::
string
&
example
)
{
std
::
stringstream
stream
(
example
);
Parser
parser
(
stream
);
while
(
parser
.
HandleNextDocument
(
handler
))
{
}
}
void
IgnoreParse
(
const
std
::
string
&
example
)
{
std
::
stringstream
stream
(
example
);
Parser
parser
(
stream
);
while
(
parser
.
HandleNextDocument
(
nice_handler
))
{
}
}
InSequence
sequence
;
StrictMock
<
MockEventHandler
>
handler
;
NiceMock
<
MockEventHandler
>
nice_handler
;
};
typedef
HandlerTest
HandlerSpecTest
;
TEST_F
(
HandlerSpecTest
,
Ex2_1_SeqScalars
)
{
EXPECT_CALL
(
handler
,
OnDocumentStart
(
_
));
...
...
test/integration/handler_test.cpp
View file @
ebf14ec8
#include "
mock_event_
handler.h"
#include "handler
_test
.h"
#include "specexamples.h" // IWYU pragma: keep
#include "yaml-cpp/eventhandler.h"
#include "yaml-cpp/yaml.h" // IWYU pragma: keep
#include "gmock/gmock.h"
#include "gtest/gtest.h"
using
::
testing
::
_
;
using
::
testing
::
InSequence
;
using
::
testing
::
NiceMock
;
using
::
testing
::
StrictMock
;
#define EXPECT_THROW_PARSER_EXCEPTION(statement, message) \
ASSERT_THROW(statement, ParserException); \
...
...
@@ -23,27 +19,6 @@ using ::testing::StrictMock;
namespace
YAML
{
namespace
{
class
HandlerTest
:
public
::
testing
::
Test
{
protected:
void
Parse
(
const
std
::
string
&
example
)
{
std
::
stringstream
stream
(
example
);
Parser
parser
(
stream
);
while
(
parser
.
HandleNextDocument
(
handler
))
{
}
}
void
IgnoreParse
(
const
std
::
string
&
example
)
{
std
::
stringstream
stream
(
example
);
Parser
parser
(
stream
);
while
(
parser
.
HandleNextDocument
(
nice_handler
))
{
}
}
InSequence
sequence
;
StrictMock
<
MockEventHandler
>
handler
;
NiceMock
<
MockEventHandler
>
nice_handler
;
};
TEST_F
(
HandlerTest
,
NoEndOfMapFlow
)
{
EXPECT_THROW_PARSER_EXCEPTION
(
IgnoreParse
(
"---{header: {id: 1"
),
ErrorMsg
::
END_OF_MAP_FLOW
);
...
...
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