William Cheng ae430a8c14
[cpp][tiny] rename generator, update samples (#9560)
* rename generator, update samples

* add doc

* update readme
2021-05-25 23:55:16 +08:00

140 lines
1.6 KiB
C++

#include "ApiResponse.h"
using namespace Tiny;
#include <string>
#include <list>
#include <unity.h>
#include "bourne/json.hpp"
void test_ApiResponse_code_is_assigned_from_json()
{
bourne::json input =
{
"code", 1
};
ApiResponse obj(input.dump());
TEST_ASSERT_EQUAL_INT(1, obj.getCode());
}
void test_ApiResponse_type_is_assigned_from_json()
{
bourne::json input =
{
"type", "hello"
};
ApiResponse obj(input.dump());
TEST_ASSERT_EQUAL_STRING("hello", obj.getType().c_str());
}
void test_ApiResponse_message_is_assigned_from_json()
{
bourne::json input =
{
"message", "hello"
};
ApiResponse obj(input.dump());
TEST_ASSERT_EQUAL_STRING("hello", obj.getMessage().c_str());
}
void test_ApiResponse_code_is_converted_to_json()
{
bourne::json input =
{
"code", 1
};
ApiResponse obj(input.dump());
bourne::json output = bourne::json::object();
output = obj.toJson();
TEST_ASSERT(input["code"] == output["code"]);
}
void test_ApiResponse_type_is_converted_to_json()
{
bourne::json input =
{
"type", "hello"
};
ApiResponse obj(input.dump());
bourne::json output = bourne::json::object();
output = obj.toJson();
TEST_ASSERT(input["type"] == output["type"]);
}
void test_ApiResponse_message_is_converted_to_json()
{
bourne::json input =
{
"message", "hello"
};
ApiResponse obj(input.dump());
bourne::json output = bourne::json::object();
output = obj.toJson();
TEST_ASSERT(input["message"] == output["message"]);
}