gorealis v2 refactor (#5)
* Changing default timeout for start maintenance. * Upgrading dependencies to gorealis v2 and thrift 0.12.0 * Refactored to update to gorealis v2.
This commit is contained in:
parent
ad4dd9606e
commit
6ab5c9334d
1335 changed files with 137431 additions and 61530 deletions
153
vendor/git.apache.org/thrift.git/compiler/cpp/tests/CMakeLists.txt
generated
vendored
Normal file
153
vendor/git.apache.org/thrift.git/compiler/cpp/tests/CMakeLists.txt
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
project(thrift_compiler_tests)
|
||||
|
||||
set(THRIFT_COMPILER_SOURCE_DIR
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
# don't generate ZERO_CHECK
|
||||
set(CMAKE_SUPPRESS_REGENERATION true)
|
||||
|
||||
configure_file(${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/thrift/version.h)
|
||||
if(MSVC)
|
||||
# The winflexbison generator outputs some macros that conflict with the Visual Studio 2010 copy of stdint.h
|
||||
# This might be fixed in later versions of Visual Studio, but an easy solution is to include stdint.h first
|
||||
if(HAVE_STDINT_H)
|
||||
add_definitions(-D__STDC_LIMIT_MACROS)
|
||||
add_definitions(/FI"stdint.h")
|
||||
endif(HAVE_STDINT_H)
|
||||
endif()
|
||||
|
||||
find_package(FLEX REQUIRED)
|
||||
find_package(BISON REQUIRED)
|
||||
|
||||
# create directory for thrifty and thriftl
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thrift/)
|
||||
|
||||
# Create flex and bison files and build the lib parse static library
|
||||
BISON_TARGET(thrifty ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/thrifty.yy ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.cc)
|
||||
FLEX_TARGET(thriftl ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/thriftl.ll ${CMAKE_CURRENT_BINARY_DIR}/thrift/thriftl.cc)
|
||||
ADD_FLEX_BISON_DEPENDENCY(thriftl thrifty)
|
||||
|
||||
set(parse_SOURCES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.cc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/thrift/thriftl.cc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.hh
|
||||
)
|
||||
|
||||
add_library(parse STATIC ${parse_SOURCES})
|
||||
|
||||
# Thrift compiler tests
|
||||
set(thrift_compiler_tests
|
||||
)
|
||||
|
||||
# you can add some files manually there
|
||||
set(thrift_compiler_tests_manual_SOURCES
|
||||
# tests file to avoid main in every test file
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tests_main.cc
|
||||
)
|
||||
|
||||
# set variable for tests sources - will be filled later
|
||||
set(thrift_compiler_tests_SOURCES
|
||||
)
|
||||
|
||||
set(thrift_compiler_SOURCES
|
||||
${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/logging.cc # we use logging instead of main to avoid breaking compillation (2 main v)
|
||||
${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/audit/t_audit.cpp
|
||||
${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/common.cc
|
||||
${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/generate/t_generator.cc
|
||||
${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/parse/t_typedef.cc
|
||||
${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/parse/parse.cc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/thrift/version.h
|
||||
)
|
||||
|
||||
# This macro adds an option THRIFT_COMPILER_${NAME}
|
||||
# that allows enabling or disabling certain languages
|
||||
macro(THRIFT_ADD_COMPILER name description initial)
|
||||
string(TOUPPER "THRIFT_COMPILER_${name}" enabler)
|
||||
set(src "${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/generate/t_${name}_generator.cc")
|
||||
option(${enabler} ${description} ${initial})
|
||||
if(${enabler})
|
||||
list(APPEND thrift_compiler_SOURCES ${src})
|
||||
file(GLOB thrift_compiler_tests_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${name}/*.c*"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${name}/*.thrift"
|
||||
)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# The following compiler with unit tests can be enabled or disabled
|
||||
THRIFT_ADD_COMPILER(c_glib "Enable compiler for C with Glib" OFF)
|
||||
THRIFT_ADD_COMPILER(cpp "Enable compiler for C++" OFF)
|
||||
THRIFT_ADD_COMPILER(java "Enable compiler for Java" OFF)
|
||||
THRIFT_ADD_COMPILER(as3 "Enable compiler for ActionScript 3" OFF)
|
||||
THRIFT_ADD_COMPILER(dart "Enable compiler for Dart" OFF)
|
||||
THRIFT_ADD_COMPILER(haxe "Enable compiler for Haxe" OFF)
|
||||
THRIFT_ADD_COMPILER(csharp "Enable compiler for C#" OFF)
|
||||
THRIFT_ADD_COMPILER(netcore "Enable compiler for .NET Core" ON)
|
||||
THRIFT_ADD_COMPILER(py "Enable compiler for Python 2.0" OFF)
|
||||
THRIFT_ADD_COMPILER(rb "Enable compiler for Ruby" OFF)
|
||||
THRIFT_ADD_COMPILER(perl "Enable compiler for Perl" OFF)
|
||||
THRIFT_ADD_COMPILER(php "Enable compiler for PHP" OFF)
|
||||
THRIFT_ADD_COMPILER(erl "Enable compiler for Erlang" OFF)
|
||||
THRIFT_ADD_COMPILER(cocoa "Enable compiler for Cocoa Objective-C" OFF)
|
||||
THRIFT_ADD_COMPILER(swift "Enable compiler for Cocoa Swift" OFF)
|
||||
THRIFT_ADD_COMPILER(st "Enable compiler for Smalltalk" OFF)
|
||||
THRIFT_ADD_COMPILER(ocaml "Enable compiler for OCaml" OFF)
|
||||
THRIFT_ADD_COMPILER(hs "Enable compiler for Haskell" OFF)
|
||||
THRIFT_ADD_COMPILER(xsd "Enable compiler for XSD" OFF)
|
||||
THRIFT_ADD_COMPILER(html "Enable compiler for HTML Documentation" OFF)
|
||||
THRIFT_ADD_COMPILER(js "Enable compiler for JavaScript" OFF)
|
||||
THRIFT_ADD_COMPILER(json "Enable compiler for JSON" OFF)
|
||||
THRIFT_ADD_COMPILER(javame "Enable compiler for Java ME" OFF)
|
||||
THRIFT_ADD_COMPILER(delphi "Enable compiler for Delphi" OFF)
|
||||
THRIFT_ADD_COMPILER(go "Enable compiler for Go" OFF)
|
||||
THRIFT_ADD_COMPILER(d "Enable compiler for D" OFF)
|
||||
THRIFT_ADD_COMPILER(lua "Enable compiler for Lua" OFF)
|
||||
THRIFT_ADD_COMPILER(gv "Enable compiler for GraphViz" OFF)
|
||||
THRIFT_ADD_COMPILER(rs "Enable compiler for Rust" OFF)
|
||||
THRIFT_ADD_COMPILER(xml "Enable compiler for XML" OFF)
|
||||
|
||||
# Thrift is looking for include files in the src directory
|
||||
# we also add the current binary directory for generated files
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${THRIFT_COMPILER_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/catch)
|
||||
|
||||
add_library(thrift_compiler ${thrift_compiler_SOURCES})
|
||||
|
||||
#link parse lib to thrift_compiler lib
|
||||
target_link_libraries(thrift_compiler parse)
|
||||
|
||||
# add tests executable
|
||||
add_executable(thrift_compiler_tests ${thrift_compiler_tests_manual_SOURCES} ${thrift_compiler_tests_SOURCES})
|
||||
|
||||
# if generates for Visual Studio set thrift_compiler_tests as default project
|
||||
if(MSVC)
|
||||
set_property(TARGET thrift_compiler_tests PROPERTY VS_STARTUP_PROJECT thrift_compiler_tests)
|
||||
endif()
|
||||
|
||||
set_target_properties(thrift_compiler_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY bin/)
|
||||
set_target_properties(thrift_compiler_tests PROPERTIES OUTPUT_NAME thrift_compiler_tests)
|
||||
|
||||
target_link_libraries(thrift_compiler_tests thrift_compiler)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME ThriftTests COMMAND thrift_compiler_tests)
|
88
vendor/git.apache.org/thrift.git/compiler/cpp/tests/README.md
generated
vendored
Normal file
88
vendor/git.apache.org/thrift.git/compiler/cpp/tests/README.md
generated
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
# Build and run compiler tests using CMake
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
- [Build and run compiler tests using CMake](#build-and-run-compiler-tests-using-cmake)
|
||||
- [General information](#general-information)
|
||||
- [How to add your tests](#how-to-add-your-tests)
|
||||
- [Build and run tests on Unix-like systems](#build-and-run-tests-on-unix-like-systems)
|
||||
- [Prerequisites:](#prerequisites)
|
||||
- [Build and run test with CMake](#build-and-run-test-with-cmake)
|
||||
- [Build and run tests on Windows](#build-and-run-tests-on-windows)
|
||||
- [Prerequisites:](#prerequisites-1)
|
||||
- [Generation of VS project with CMake, build and run on Windows](#generation-of-vs-project-with-cmake-build-and-run-on-windows)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
## General information
|
||||
|
||||
Added generic way to cover code by tests for many languages (you just need to make a correct header file for generator for your language - example in **netcore** implementation)
|
||||
|
||||
At current moment these tests use free Catch library (https://github.com/catchorg/Catch2/tree/Catch1.x) for easy test creation and usage.
|
||||
Decision to use it was because of simplicity, easy usage, one header file to use, stable community and growing interest (https://cpp.libhunt.com/project/googletest-google/vs/catch?rel=cmp-cmp)
|
||||
|
||||
Also, maybe, later it will be migrated to Catch2 (https://github.com/philsquared/Catch) - depends on need to support legacy compilers (c++98)
|
||||
|
||||
## How to add your tests
|
||||
|
||||
- Open **CMakeLists.txt**
|
||||
- Set **On** to call of **THRIFT_ADD_COMPILER** for your language
|
||||
|
||||
``` cmake
|
||||
THRIFT_ADD_COMPILER(netcore "Enable compiler for .NET Core" ON)
|
||||
```
|
||||
|
||||
- Create folder with name specified in list of languages in **CMakeLists.txt**
|
||||
- Create tests in folder for your language (with extensions like *.c* - cc, cpp, etc)
|
||||
- Don't forget to add include of catch.hpp in your test file
|
||||
``` C
|
||||
#include "../catch/catch.hpp"
|
||||
```
|
||||
|
||||
- If you need - add files manually to **thrift_compiler_tests_manual_SOURCES** in **CMakeLists.txt** similar to
|
||||
|
||||
``` cmake
|
||||
# you can add some files manually there
|
||||
set(thrift_compiler_tests_manual_SOURCES
|
||||
# tests file to avoid main in every test file
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tests_main.cc
|
||||
)
|
||||
```
|
||||
|
||||
- Run **cmake** with arguments for your environment and compiler
|
||||
- Enjoy
|
||||
|
||||
## Build and run tests on Unix-like systems
|
||||
|
||||
### Prerequisites:
|
||||
- Install CMake - <https://cmake.org/download/>
|
||||
- Install winflexbison - <https://sourceforge.net/projects/winflexbison/>
|
||||
|
||||
### Build and run test with CMake
|
||||
|
||||
- Run commands in command line in current directory:
|
||||
|
||||
```
|
||||
mkdir cmake-vs && cd cmake-vs
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest -C Debug -V
|
||||
```
|
||||
|
||||
## Build and run tests on Windows
|
||||
|
||||
### Prerequisites:
|
||||
- Install CMake - <https://cmake.org/download/>
|
||||
- Install winflexbison - <https://sourceforge.net/projects/winflexbison/>
|
||||
- Install VS2017 Community Edition - <https://www.visualstudio.com/vs/whatsnew/> (ensure that you installed workload "Desktop Development with C++" for VS2017)
|
||||
|
||||
### Generation of VS project with CMake, build and run on Windows
|
||||
- Run commands in command line in current directory (ensure that VS installed):
|
||||
|
||||
```
|
||||
mkdir cmake-vs
|
||||
cd cmake-vs
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest -C Debug -V
|
||||
```
|
11508
vendor/git.apache.org/thrift.git/compiler/cpp/tests/catch/catch.hpp
generated
vendored
Normal file
11508
vendor/git.apache.org/thrift.git/compiler/cpp/tests/catch/catch.hpp
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
339
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_functional_tests.cc
generated
vendored
Normal file
339
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_functional_tests.cc
generated
vendored
Normal file
|
@ -0,0 +1,339 @@
|
|||
// Licensed to the Apache Software Foundation(ASF) under one
|
||||
// or more contributor license agreements.See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership.The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "../catch/catch.hpp"
|
||||
#include <thrift/parse/t_program.h>
|
||||
#include <thrift/generate/t_netcore_generator.h>
|
||||
#include "t_netcore_generator_functional_tests_helpers.h"
|
||||
|
||||
TEST_CASE( "t_netcore_generator should generate valid enum", "[functional]" )
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
|
||||
std::pair<string, t_enum*> pair = TestDataGenerator::get_test_enum_data(program);
|
||||
string expected_result = pair.first;
|
||||
t_enum* test_enum = pair.second;
|
||||
|
||||
string file_path = test_enum->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_NOTHROW(gen->generate_enum(out, test_enum));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
REQUIRE(expected_result == actual_result);
|
||||
|
||||
delete test_enum;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should generate valid void", "[functional]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
|
||||
std::pair<string, t_const*> pair = TestDataGenerator::get_test_void_const_data(gen);
|
||||
string expected_result = pair.first;
|
||||
t_const* const_ = pair.second;
|
||||
vector<t_const*> consts_;
|
||||
consts_.push_back(const_);
|
||||
|
||||
string file_path = const_->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_THROWS(gen->generate_consts(out, consts_));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
delete const_;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should generate valid string with escaping keyword", "[functional]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
gen->init_generator();
|
||||
|
||||
std::pair<string, t_const*> pair = TestDataGenerator::get_test_string_const_data(gen);
|
||||
string expected_result = pair.first;
|
||||
t_const* const_ = pair.second;
|
||||
vector<t_const*> consts_;
|
||||
consts_.push_back(const_);
|
||||
|
||||
string file_path = const_->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_NOTHROW(gen->generate_consts(out, consts_));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
REQUIRE(expected_result == actual_result);
|
||||
|
||||
delete const_;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should generate valid bool with escaping keyword", "[functional]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
gen->init_generator();
|
||||
|
||||
std::pair<string, t_const*> pair = TestDataGenerator::get_test_bool_const_data(gen);
|
||||
string expected_result = pair.first;
|
||||
t_const* const_ = pair.second;
|
||||
vector<t_const*> consts_;
|
||||
consts_.push_back(const_);
|
||||
|
||||
string file_path = const_->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_NOTHROW(gen->generate_consts(out, consts_));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
REQUIRE(expected_result == actual_result);
|
||||
|
||||
delete const_;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should generate valid sbyte (i8) with escaping keyword", "[functional]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
gen->init_generator();
|
||||
|
||||
std::pair<string, t_const*> pair = TestDataGenerator::get_test_i8_const_data(gen);
|
||||
string expected_result = pair.first;
|
||||
t_const* const_ = pair.second;
|
||||
vector<t_const*> consts_;
|
||||
consts_.push_back(const_);
|
||||
|
||||
string file_path = const_->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_NOTHROW(gen->generate_consts(out, consts_));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
REQUIRE(expected_result == actual_result);
|
||||
|
||||
delete const_;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should generate valid short (i16) with escaping keyword", "[functional]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
gen->init_generator();
|
||||
|
||||
std::pair<string, t_const*> pair = TestDataGenerator::get_test_i16_const_data(gen);
|
||||
string expected_result = pair.first;
|
||||
t_const* const_ = pair.second;
|
||||
vector<t_const*> consts_;
|
||||
consts_.push_back(const_);
|
||||
|
||||
string file_path = const_->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_NOTHROW(gen->generate_consts(out, consts_));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
REQUIRE(expected_result == actual_result);
|
||||
|
||||
delete const_;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should generate valid integer (i32) with escaping keyword", "[functional]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
gen->init_generator();
|
||||
|
||||
std::pair<string, t_const*> pair = TestDataGenerator::get_test_i32_const_data(gen);
|
||||
string expected_result = pair.first;
|
||||
t_const* const_ = pair.second;
|
||||
vector<t_const*> consts_;
|
||||
consts_.push_back(const_);
|
||||
|
||||
string file_path = const_->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_NOTHROW(gen->generate_consts(out, consts_));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
REQUIRE(expected_result == actual_result);
|
||||
|
||||
delete const_;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should generate valid long (i64) with escaping keyword", "[functional]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
gen->init_generator();
|
||||
|
||||
std::pair<string, t_const*> pair = TestDataGenerator::get_test_i64_const_data(gen);
|
||||
string expected_result = pair.first;
|
||||
t_const* const_ = pair.second;
|
||||
vector<t_const*> consts_;
|
||||
consts_.push_back(const_);
|
||||
|
||||
string file_path = const_->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_NOTHROW(gen->generate_consts(out, consts_));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
REQUIRE(expected_result == actual_result);
|
||||
|
||||
delete const_;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should generate valid double with escaping keyword", "[functional]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
gen->init_generator();
|
||||
|
||||
std::pair<string, t_const*> pair = TestDataGenerator::get_test_double_const_data(gen);
|
||||
string expected_result = pair.first;
|
||||
t_const* const_ = pair.second;
|
||||
vector<t_const*> consts_;
|
||||
consts_.push_back(const_);
|
||||
|
||||
string file_path = const_->get_name() + ".cs";
|
||||
ofstream out;
|
||||
out.open(file_path.c_str());
|
||||
|
||||
REQUIRE_NOTHROW(gen->generate_consts(out, consts_));
|
||||
|
||||
out.close();
|
||||
|
||||
std::ifstream ifs(file_path);
|
||||
string actual_result((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
std::remove(file_path.c_str());
|
||||
|
||||
REQUIRE(expected_result == actual_result);
|
||||
|
||||
delete const_;
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
237
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_functional_tests_helpers.cc
generated
vendored
Normal file
237
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_functional_tests_helpers.cc
generated
vendored
Normal file
|
@ -0,0 +1,237 @@
|
|||
// Licensed to the Apache Software Foundation(ASF) under one
|
||||
// or more contributor license agreements.See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership.The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <thrift/parse/t_program.h>
|
||||
#include "thrift/common.h"
|
||||
#include <thrift/generate/t_netcore_generator.h>
|
||||
#include "t_netcore_generator_functional_tests_helpers.h"
|
||||
|
||||
const string TestDataGenerator::DEFAULT_FILE_HEADER = "/**" "\n"
|
||||
" * Autogenerated by Thrift Compiler ()" "\n"
|
||||
" *" "\n"
|
||||
" * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING" "\n"
|
||||
" * @generated" "\n"
|
||||
" */";
|
||||
|
||||
std::pair<string, t_enum*> TestDataGenerator::get_test_enum_data(t_program* program)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER +
|
||||
"\n"
|
||||
"\n"
|
||||
"/// <summary>\n"
|
||||
"/// TestDoc\n"
|
||||
"/// </summary>\n"
|
||||
"public enum TestName\n"
|
||||
"{\n"
|
||||
" None = 0,\n"
|
||||
" First = 1,\n"
|
||||
" Second = 2,\n"
|
||||
"}\n";
|
||||
|
||||
t_enum* enum_ = new t_enum(program);
|
||||
enum_->set_name("TestName");
|
||||
enum_->set_doc("TestDoc");
|
||||
enum_->append(new t_enum_value("None", 0));
|
||||
enum_->append(new t_enum_value("First", 1));
|
||||
enum_->append(new t_enum_value("Second", 2));
|
||||
|
||||
return std::pair<string, t_enum*>(expected_result, enum_);
|
||||
}
|
||||
|
||||
std::pair<string, t_const*> TestDataGenerator::get_test_void_const_data(t_netcore_generator* gen)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER;
|
||||
|
||||
t_type* type_ = new t_base_type("void", t_base_type::TYPE_VOID);
|
||||
type_->set_doc("TestDoc");
|
||||
|
||||
t_const_value* const_value_ = new t_const_value();
|
||||
const_value_->set_string("VoidValue");
|
||||
|
||||
t_const* const_ = new t_const(type_, "void", const_value_);
|
||||
const_->set_doc("TestDoc");
|
||||
|
||||
return std::pair<string, t_const*>(expected_result, const_);
|
||||
}
|
||||
|
||||
std::pair<string, t_const*> TestDataGenerator::get_test_string_const_data(t_netcore_generator* gen)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER + "\n" +gen->netcore_type_usings() +
|
||||
"\n"
|
||||
"public static class netcoreConstants\n"
|
||||
"{\n"
|
||||
" /// <summary>\n"
|
||||
" /// TestDoc\n"
|
||||
" /// </summary>\n"
|
||||
" public const string @string = \"StringValue\";\n"
|
||||
"}\n";
|
||||
|
||||
t_type* type_ = new t_base_type("string", t_base_type::TYPE_STRING);
|
||||
type_->set_doc("TestDoc");
|
||||
|
||||
t_const_value* const_value_ = new t_const_value();
|
||||
const_value_->set_string("StringValue");
|
||||
|
||||
t_const* const_ = new t_const(type_, "string", const_value_);
|
||||
const_->set_doc("TestDoc");
|
||||
|
||||
return std::pair<string, t_const*>(expected_result, const_);
|
||||
}
|
||||
|
||||
std::pair<string, t_const*> TestDataGenerator::get_test_bool_const_data(t_netcore_generator* gen)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER + "\n" +gen->netcore_type_usings() +
|
||||
"\n"
|
||||
"public static class netcoreConstants\n"
|
||||
"{\n"
|
||||
" /// <summary>\n"
|
||||
" /// TestDoc\n"
|
||||
" /// </summary>\n"
|
||||
" public const bool @bool = true;\n"
|
||||
"}\n";
|
||||
|
||||
t_type* type_ = new t_base_type("bool", t_base_type::TYPE_BOOL);
|
||||
type_->set_doc("TestDoc");
|
||||
|
||||
t_const_value* const_value_ = new t_const_value();
|
||||
const_value_->set_integer(1);
|
||||
|
||||
t_const* const_ = new t_const(type_, "bool", const_value_);
|
||||
const_->set_doc("TestDoc");
|
||||
|
||||
return std::pair<string, t_const*>(expected_result, const_);
|
||||
}
|
||||
|
||||
std::pair<string, t_const*> TestDataGenerator::get_test_i8_const_data(t_netcore_generator* gen)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER + "\n" +gen->netcore_type_usings() +
|
||||
"\n"
|
||||
"public static class netcoreConstants\n"
|
||||
"{\n"
|
||||
" /// <summary>\n"
|
||||
" /// TestDoc\n"
|
||||
" /// </summary>\n"
|
||||
" public const sbyte @sbyte = 127;\n"
|
||||
"}\n";
|
||||
|
||||
t_type* type_ = new t_base_type("I8", t_base_type::TYPE_I8);
|
||||
type_->set_doc("TestDoc");
|
||||
|
||||
t_const_value* const_value_ = new t_const_value();
|
||||
const_value_->set_integer(127);
|
||||
|
||||
t_const* const_ = new t_const(type_, "sbyte", const_value_);
|
||||
const_->set_doc("TestDoc");
|
||||
|
||||
return std::pair<string, t_const*>(expected_result, const_);
|
||||
}
|
||||
|
||||
std::pair<string, t_const*> TestDataGenerator::get_test_i16_const_data(t_netcore_generator* gen)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER + "\n" +gen->netcore_type_usings() +
|
||||
"\n"
|
||||
"public static class netcoreConstants\n"
|
||||
"{\n"
|
||||
" /// <summary>\n"
|
||||
" /// TestDoc\n"
|
||||
" /// </summary>\n"
|
||||
" public const short @short = 32767;\n"
|
||||
"}\n";
|
||||
|
||||
t_type* type_ = new t_base_type("i16", t_base_type::TYPE_I16);
|
||||
type_->set_doc("TestDoc");
|
||||
|
||||
t_const_value* const_value_ = new t_const_value();
|
||||
const_value_->set_integer(32767);
|
||||
|
||||
t_const* const_ = new t_const(type_, "short", const_value_);
|
||||
const_->set_doc("TestDoc");
|
||||
|
||||
return std::pair<string, t_const*>(expected_result, const_);
|
||||
}
|
||||
|
||||
std::pair<string, t_const*> TestDataGenerator::get_test_i32_const_data(t_netcore_generator* gen)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER + "\n" +gen->netcore_type_usings() +
|
||||
"\n"
|
||||
"public static class netcoreConstants\n"
|
||||
"{\n"
|
||||
" /// <summary>\n"
|
||||
" /// TestDoc\n"
|
||||
" /// </summary>\n"
|
||||
" public const int @int = 2147483647;\n"
|
||||
"}\n";
|
||||
|
||||
t_type* type_ = new t_base_type("i32", t_base_type::TYPE_I32);
|
||||
type_->set_doc("TestDoc");
|
||||
|
||||
t_const_value* const_value_ = new t_const_value();
|
||||
const_value_->set_integer(2147483647);
|
||||
|
||||
t_const* const_ = new t_const(type_, "int", const_value_);
|
||||
const_->set_doc("TestDoc");
|
||||
|
||||
return std::pair<string, t_const*>(expected_result, const_);
|
||||
}
|
||||
|
||||
std::pair<string, t_const*> TestDataGenerator::get_test_i64_const_data(t_netcore_generator* gen)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER + "\n" +gen->netcore_type_usings() +
|
||||
"\n"
|
||||
"public static class netcoreConstants\n"
|
||||
"{\n"
|
||||
" /// <summary>\n"
|
||||
" /// TestDoc\n"
|
||||
" /// </summary>\n"
|
||||
" public const long @long = 9223372036854775807;\n"
|
||||
"}\n";
|
||||
|
||||
t_type* type_ = new t_base_type("i64", t_base_type::TYPE_I64);
|
||||
type_->set_doc("TestDoc");
|
||||
|
||||
t_const_value* const_value_ = new t_const_value();
|
||||
const_value_->set_integer(9223372036854775807);
|
||||
|
||||
t_const* const_ = new t_const(type_, "long", const_value_);
|
||||
const_->set_doc("TestDoc");
|
||||
|
||||
return std::pair<string, t_const*>(expected_result, const_);
|
||||
}
|
||||
|
||||
std::pair<string, t_const*> TestDataGenerator::get_test_double_const_data(t_netcore_generator* gen)
|
||||
{
|
||||
string expected_result = DEFAULT_FILE_HEADER + "\n" +gen->netcore_type_usings() +
|
||||
"\n"
|
||||
"public static class netcoreConstants\n"
|
||||
"{\n"
|
||||
" /// <summary>\n"
|
||||
" /// TestDoc\n"
|
||||
" /// </summary>\n"
|
||||
" public const double @double = 9.22337e+18;\n"
|
||||
"}\n";
|
||||
|
||||
t_type* type_ = new t_base_type("double", t_base_type::TYPE_DOUBLE);
|
||||
type_->set_doc("TestDoc");
|
||||
|
||||
t_const_value* const_value_ = new t_const_value();
|
||||
const_value_->set_double(9223372036854775807.1);
|
||||
|
||||
t_const* const_ = new t_const(type_, "double", const_value_);
|
||||
const_->set_doc("TestDoc");
|
||||
|
||||
return std::pair<string, t_const*>(expected_result, const_);
|
||||
}
|
34
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_functional_tests_helpers.h
generated
vendored
Normal file
34
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_functional_tests_helpers.h
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Licensed to the Apache Software Foundation(ASF) under one
|
||||
// or more contributor license agreements.See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership.The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <thrift/parse/t_program.h>
|
||||
|
||||
class TestDataGenerator
|
||||
{
|
||||
public:
|
||||
static const string DEFAULT_FILE_HEADER;
|
||||
|
||||
static std::pair<string, t_enum*> get_test_enum_data(t_program* program);
|
||||
static std::pair<string, t_const*> get_test_void_const_data(t_netcore_generator* gen);
|
||||
static std::pair<string, t_const*> get_test_string_const_data(t_netcore_generator* gen);
|
||||
static std::pair<string, t_const*> get_test_bool_const_data(t_netcore_generator* gen);
|
||||
static std::pair<string, t_const*> get_test_i8_const_data(t_netcore_generator* gen);
|
||||
static std::pair<string, t_const*> get_test_i16_const_data(t_netcore_generator* gen);
|
||||
static std::pair<string, t_const*> get_test_i32_const_data(t_netcore_generator* gen);
|
||||
static std::pair<string, t_const*> get_test_i64_const_data(t_netcore_generator* gen);
|
||||
static std::pair<string, t_const*> get_test_double_const_data(t_netcore_generator* gen);
|
||||
};
|
209
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc
generated
vendored
Normal file
209
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_helpers_tests.cc
generated
vendored
Normal file
|
@ -0,0 +1,209 @@
|
|||
// Licensed to the Apache Software Foundation(ASF) under one
|
||||
// or more contributor license agreements.See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership.The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "../catch/catch.hpp"
|
||||
#include <thrift/parse/t_program.h>
|
||||
#include <thrift/generate/t_netcore_generator.h>
|
||||
|
||||
using std::vector;
|
||||
|
||||
TEST_CASE("t_netcore_generator::netcore_type_usings() without option wcf should return valid namespaces", "[helpers]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "union", "union" } };
|
||||
string option_string = "";
|
||||
|
||||
string expected_namespaces = "using System;\n"
|
||||
"using System.Collections;\n"
|
||||
"using System.Collections.Generic;\n"
|
||||
"using System.Text;\n"
|
||||
"using System.IO;\n"
|
||||
"using System.Threading;\n"
|
||||
"using System.Threading.Tasks;\n"
|
||||
"using Thrift;\n"
|
||||
"using Thrift.Collections;\n" + endl;
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
|
||||
REQUIRE_FALSE(gen->is_wcf_enabled());
|
||||
REQUIRE(gen->netcore_type_usings() == expected_namespaces);
|
||||
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator::netcore_type_usings() with option wcf should return valid namespaces", "[helpers]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
|
||||
string expected_namespaces_wcf = "using System;\n"
|
||||
"using System.Collections;\n"
|
||||
"using System.Collections.Generic;\n"
|
||||
"using System.Text;\n"
|
||||
"using System.IO;\n"
|
||||
"using System.Threading;\n"
|
||||
"using System.Threading.Tasks;\n"
|
||||
"using Thrift;\n"
|
||||
"using Thrift.Collections;\n"
|
||||
"using System.ServiceModel;\n"
|
||||
"using System.Runtime.Serialization;\n" + endl;
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
|
||||
REQUIRE(gen->is_wcf_enabled());
|
||||
REQUIRE(gen->netcore_type_usings() == expected_namespaces_wcf);
|
||||
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should contains latest C# keywords to normalize with @", "[helpers]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" } };
|
||||
string option_string = "";
|
||||
vector<string> current_keywords = {
|
||||
{ "abstract" },
|
||||
{ "as" },
|
||||
{ "base" },
|
||||
{ "bool" },
|
||||
{ "break" },
|
||||
{ "byte" },
|
||||
{ "case" },
|
||||
{ "catch" },
|
||||
{ "char" },
|
||||
{ "checked" },
|
||||
{ "class" },
|
||||
{ "const" },
|
||||
{ "continue" },
|
||||
{ "decimal" },
|
||||
{ "default" },
|
||||
{ "delegate" },
|
||||
{ "do" },
|
||||
{ "double" },
|
||||
{ "else" },
|
||||
{ "enum" },
|
||||
{ "event" },
|
||||
{ "explicit" },
|
||||
{ "extern" },
|
||||
{ "false" },
|
||||
{ "finally" },
|
||||
{ "fixed" },
|
||||
{ "float" },
|
||||
{ "for" },
|
||||
{ "foreach" },
|
||||
{ "goto" },
|
||||
{ "if" },
|
||||
{ "implicit" },
|
||||
{ "in" },
|
||||
{ "int" },
|
||||
{ "interface" },
|
||||
{ "internal" },
|
||||
{ "is" },
|
||||
{ "lock" },
|
||||
{ "long" },
|
||||
{ "namespace" },
|
||||
{ "new" },
|
||||
{ "null" },
|
||||
{ "object" },
|
||||
{ "operator" },
|
||||
{ "out" },
|
||||
{ "override" },
|
||||
{ "params" },
|
||||
{ "private" },
|
||||
{ "protected" },
|
||||
{ "public" },
|
||||
{ "readonly" },
|
||||
{ "ref" },
|
||||
{ "return" },
|
||||
{ "sbyte" },
|
||||
{ "sealed" },
|
||||
{ "short" },
|
||||
{ "sizeof" },
|
||||
{ "stackalloc" },
|
||||
{ "static" },
|
||||
{ "string" },
|
||||
{ "struct" },
|
||||
{ "switch" },
|
||||
{ "this" },
|
||||
{ "throw" },
|
||||
{ "true" },
|
||||
{ "try" },
|
||||
{ "typeof" },
|
||||
{ "uint" },
|
||||
{ "ulong" },
|
||||
{ "unchecked" },
|
||||
{ "unsafe" },
|
||||
{ "ushort" },
|
||||
{ "using" },
|
||||
{ "void" },
|
||||
{ "volatile" },
|
||||
{ "while" },
|
||||
// Contextual Keywords
|
||||
{ "add" },
|
||||
{ "alias" },
|
||||
{ "ascending" },
|
||||
{ "async" },
|
||||
{ "await" },
|
||||
{ "descending" },
|
||||
{ "dynamic" },
|
||||
{ "from" },
|
||||
{ "get" },
|
||||
{ "global" },
|
||||
{ "group" },
|
||||
{ "into" },
|
||||
{ "join" },
|
||||
{ "let" },
|
||||
{ "orderby" },
|
||||
{ "partial" },
|
||||
{ "remove" },
|
||||
{ "select" },
|
||||
{ "set" },
|
||||
{ "value" },
|
||||
{ "var" },
|
||||
{ "when" },
|
||||
{ "where" },
|
||||
{ "yield" }
|
||||
};
|
||||
|
||||
string missed_keywords = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
gen->init_generator();
|
||||
map<string, int> generators_keywords = gen->get_keywords_list();
|
||||
|
||||
for (vector<string>::iterator it = current_keywords.begin(); it != current_keywords.end(); ++it)
|
||||
{
|
||||
if (generators_keywords.find(*it) == generators_keywords.end())
|
||||
{
|
||||
missed_keywords = missed_keywords + *it + ",";
|
||||
}
|
||||
}
|
||||
|
||||
REQUIRE(missed_keywords == "");
|
||||
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
74
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_initialization_tests.cc
generated
vendored
Normal file
74
vendor/git.apache.org/thrift.git/compiler/cpp/tests/netcore/t_netcore_generator_initialization_tests.cc
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
// Licensed to the Apache Software Foundation(ASF) under one
|
||||
// or more contributor license agreements.See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership.The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "../catch/catch.hpp"
|
||||
#include <thrift/parse/t_program.h>
|
||||
#include <thrift/generate/t_netcore_generator.h>
|
||||
|
||||
TEST_CASE( "t_netcore_generator should throw error with unknown options", "[initialization]" )
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "keys", "keys" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = nullptr;
|
||||
|
||||
REQUIRE_THROWS(gen = new t_netcore_generator(program, parsed_options, option_string));
|
||||
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should create valid instance with valid options", "[initialization]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" }, { "nullable", "nullable"} };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = nullptr;
|
||||
|
||||
REQUIRE_NOTHROW(gen = new t_netcore_generator(program, parsed_options, option_string));
|
||||
REQUIRE(gen != nullptr);
|
||||
REQUIRE(gen->is_wcf_enabled());
|
||||
REQUIRE(gen->is_nullable_enabled());
|
||||
REQUIRE_FALSE(gen->is_hashcode_enabled());
|
||||
REQUIRE_FALSE(gen->is_serialize_enabled());
|
||||
REQUIRE_FALSE(gen->is_union_enabled());
|
||||
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("t_netcore_generator should pass init succesfully", "[initialization]")
|
||||
{
|
||||
string path = "CassandraTest.thrift";
|
||||
string name = "netcore";
|
||||
map<string, string> parsed_options = { { "wcf", "wcf" },{ "nullable", "nullable" } };
|
||||
string option_string = "";
|
||||
|
||||
t_program* program = new t_program(path, name);
|
||||
t_netcore_generator* gen = new t_netcore_generator(program, parsed_options, option_string);
|
||||
|
||||
REQUIRE_NOTHROW(gen->init_generator());
|
||||
|
||||
delete gen;
|
||||
delete program;
|
||||
}
|
19
vendor/git.apache.org/thrift.git/compiler/cpp/tests/tests_main.cc
generated
vendored
Normal file
19
vendor/git.apache.org/thrift.git/compiler/cpp/tests/tests_main.cc
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Licensed to the Apache Software Foundation(ASF) under one
|
||||
// or more contributor license agreements.See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership.The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch/catch.hpp"
|
Loading…
Add table
Add a link
Reference in a new issue