Skip to content

Commit

Permalink
Add value initialization tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Jun 15, 2015
1 parent 2e80bf6 commit df840a1
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 21 deletions.
1 change: 1 addition & 0 deletions Makefile.in
Expand Up @@ -5,6 +5,7 @@ OUT_DIR = bin/
SOURCES = \
test/src/map/main.cpp \
test/src/array/main.cpp \
test/src/value/main.cpp \
test/src/parser/main.cpp \
test/src/odr/main.cpp
OBJECTS = ${SOURCES:.cpp=.cpp.o}
Expand Down
56 changes: 56 additions & 0 deletions test/include/value/ctor.hpp
@@ -0,0 +1,56 @@
/*
Copyright © 2015 Jesse 'Jeaye' Wilkerson
See licensing at:
http://opensource.org/licenses/BSD-3-Clause
File: test/include/value/ctor.hpp
Author: Jesse 'Jeaye' Wilkerson
*/

#include <jeayeson/jeayeson.hpp>
#include <jest/jest.hpp>

namespace jeayeson
{
struct value_ctor_test{};
using value_ctor_group = jest::group<value_ctor_test>;
static value_ctor_group const value_ctor_obj{ "value ctor" };
}

namespace jest
{
template <> template <>
void jeayeson::value_ctor_group::test<0>() /* initializer_list for map */
{
json_value vm
{
{ "bool", true },
{ "int", 3 },
{ "real", 3.145 },
{ "str", "This is a str" },
{ "null", json_null{} },
{ "nullptr", nullptr },
{
"map",
{
{ "sub", 42 },
{ "arr_int", { 0, 1, 2, 3, 4 } },
{ "arr_str", { "0", "1", "2", "3", "4" } },
}
},
};
expect(vm.get_type() == json_value::type::map);
expect_equal(vm.as<json_map>().size(), 7ul);
}

template <> template <>
void jeayeson::value_ctor_group::test<1>() /* initializer_list for array */
{
json_value vm
{
"str0", "str1", "str2"
};
expect(vm.get_type() == json_value::type::array);
expect_equal(vm.as<json_array>().size(), 3ul);
}
}
20 changes: 0 additions & 20 deletions test/src/map/main.cpp
Expand Up @@ -23,24 +23,4 @@ int main()
{
jest::worker const j{};
return j();

/* TODO: Make sure all this shit is tested. */
json_value vm
{
{ "bool", true },
{ "int", 3 },
{ "real", 3.145 },
{ "str", "This is a str" },
{ "null", json_null{} },
{ "nullptr", nullptr },
{
"map",
{
{ "sub", 42 },
{ "arr_int", { 0, 1, 2, 3, 4 } },
{ "arr_str", { "0", "1", "2", "3", "4" } },
}
},
};
std::cout << vm << std::endl;
}
2 changes: 1 addition & 1 deletion test/src/value/main.cpp
Expand Up @@ -10,7 +10,7 @@
#include <jeayeson/jeayeson.hpp>
#include <jest/jest.hpp>

#include "map/ctor.hpp"
#include "value/ctor.hpp"

int main()
{
Expand Down

0 comments on commit df840a1

Please sign in to comment.