Skip to content
Snippets Groups Projects
Commit 7ba95d1b authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

add json export test (still WIP)

parent c42f3fe2
No related branches found
No related tags found
1 merge request!315Fix/read variable size matrices and optionals
...@@ -106,6 +106,25 @@ armarx_add_test( ...@@ -106,6 +106,25 @@ armarx_add_test(
${Simox_INCLUDE_DIR} ${Simox_INCLUDE_DIR}
) )
######################
# ARON JSON EXPORT TEST
######################
armarx_add_test(
TEST_NAME
aronJsonExportTest
TEST_FILE
aronJsonExportTest.cpp
LIBS
SimoxUtility # Simox::SimoxUtility
ArmarXCore
RobotAPI::aron
ARON_FILES
aron/OptionalTest.xml
aron/MatrixTest.xml
INCLUDE_DIRECTORIES
${Simox_INCLUDE_DIR}
)
######################## ########################
# ARON RANDOMIZED TEST # # ARON RANDOMIZED TEST #
######################## ########################
......
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::aron
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#define BOOST_TEST_MODULE RobotAPI::ArmarXLibraries::aron
#define ARMARX_BOOST_TEST
// STD/STL
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <fstream>
// Test
#include <RobotAPI/Test.h>
// ArmarX
#include <ArmarXCore/libraries/cppgen/CppMethod.h>
#include <ArmarXCore/libraries/cppgen/CppClass.h>
#include <RobotAPI/libraries/aron/core/Exception.h>
// Aron
#include <RobotAPI/libraries/aron/core/data/variant/All.h>
#include <RobotAPI/libraries/aron/core/type/variant/All.h>
#include <RobotAPI/libraries/aron/core/data/rw/writer/nlohmannJSON/NlohmannJSONWriter.h>
#include <RobotAPI/libraries/aron/core/data/rw/reader/nlohmannJSON/NlohmannJSONReader.h>
#include <RobotAPI/libraries/aron/core/type/rw/writer/nlohmannJSON/NlohmannJSONWriter.h>
#include <RobotAPI/libraries/aron/core/type/rw/reader/nlohmannJSON/NlohmannJSONReader.h>
// Generated File
#include <RobotAPI/libraries/aron/codegeneration/test/aron/MatrixTest.aron.generated.h>
#include <RobotAPI/libraries/aron/codegeneration/test/aron/OptionalTest.aron.generated.h>
using namespace armarx;
using namespace aron;
BOOST_AUTO_TEST_CASE(AronJsonExportTest)
{
std::cout << "Aron json export test" << std::endl;
OptionalTest clazz;
{
auto t = clazz.ToAronType();
auto type_writer = type::writer::NlohmannJSONWriter();
auto type_json = clazz.writeType(type_writer);
std::ofstream type_ofs("/tmp/aronJsonExportTestType.json");
type_ofs << type_json.dump(2);
auto data_writer = data::writer::NlohmannJSONWriter();
auto data_json = clazz.write(data_writer);
std::ofstream data_ofs("/tmp/aronJsonExportTestData.json");
data_ofs << data_json.dump(2);
}
// Try to read data again
auto data_reader = data::reader::NlohmannJSONReader();
std::ifstream data_ifs("/tmp/aronJsonExportTestData.json");
auto data_json = nlohmann::json::parse(data_ifs);
clazz.read(data_reader, data_json);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment