-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include <includejs/engine.h> | ||
|
||
TEST(IncludeJS_Engine, from_json_object) { | ||
includejs::Engine engine; | ||
|
||
auto json = engine.context().from_json("{ \"key\": null }"); | ||
|
||
EXPECT_TRUE(json.is_object()); | ||
auto json_object = json.to_map(); | ||
EXPECT_EQ(json_object.size(), 1); | ||
EXPECT_TRUE(json_object.at("key").is_null()); | ||
} | ||
|
||
TEST(IncludeJS_Engine, from_json_array) { | ||
includejs::Engine engine; | ||
|
||
auto json = engine.context().from_json("[2]"); | ||
|
||
EXPECT_TRUE(json.is_array()); | ||
auto json_array = json.to_vector(); | ||
EXPECT_EQ(json_array.size(), 1); | ||
EXPECT_TRUE(json_array.at(0).is_number()); | ||
} | ||
|
||
TEST(IncludeJS_Engine, from_json_failure) { | ||
includejs::Engine engine; | ||
|
||
EXPECT_THAT([&] { engine.context().from_json("<div>"); }, | ||
testing::ThrowsMessage<std::invalid_argument>( | ||
testing::HasSubstr("Invalid JSON string"))); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.