From fbe87c1385b06b3b963b0703b190faedadce8306 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Tue, 27 Sep 2016 20:37:42 +0200 Subject: [PATCH 1/6] Implement basic formatting check --- test/correct_style.cpp | 268 +++++++++++++++++++++++++++++++++++++++++ wscript | 70 ++++++++++- 2 files changed, 335 insertions(+), 3 deletions(-) create mode 100644 test/correct_style.cpp diff --git a/test/correct_style.cpp b/test/correct_style.cpp new file mode 100644 index 0000000..a374f0b --- /dev/null +++ b/test/correct_style.cpp @@ -0,0 +1,268 @@ +#include +#include +#include +#include + +#if defined(PLATFORM_WINDOWS_PHONE) + #if defined(PLATFORM_MSVC_ARM) + // NEON introduced in VS2012 + #if (_MSC_VER >= 1700) + #define PLATFORM_NEON 1 + #endif + #endif +#elif defined(PLATFORM_MSVC_X86) + // SSSE3, SSE4.1, SSE4.2, PCLMUL introduced in VS2008 + #if (_MSC_VER >= 1500) + #define PLATFORM_SSSE3 1 + #define PLATFORM_SSE41 1 + #define PLATFORM_SSE42 1 + #define PLATFORM_PCLMUL 1 + #endif + // AVX and AVX2 introduced in VS2012 + #if (_MSC_VER >= 1700) + #define PLATFORM_AVX 1 + #define PLATFORM_AVX2 1 + #endif +#endif + +namespace kodo_core +{ +/// @ingroup finite_field_layers +/// +/// @brief Template alias for the common set of finite field +/// layers used in most stacks +template +using finite_field_layers = + finite_field_math::type, + finite_field>; +} + +namespace kodo_rlnc +{ +/// @ingroup coefficient_generator_layers +/// +/// @brief Generates an uniform random coefficient (from the +/// chosen Finite Field) for every symbol. In addition +/// using the pivot_aware_generate means that we will only +/// generate non-zero coefficients for symbols which are +/// available locally. +template +using on_the_fly_generator = + kodo_core::check_partial_generator< + kodo_core::uniform_generator_layers::type > >; +} + +namespace kodo_rlnc +{ +template +< + class MainStack, + class Features +> +class full_vector_recoding_stack : public + // Payload API + kodo_core::payload_info< + // Codec Header API + kodo_core::default_off_systematic_encoder< + kodo_core::symbol_id_encoder< + // Symbol ID API + recoder_symbol_id< + // Coefficient Generator API + kodo_core::uniform_generator_layers::type, + kodo_core::trace_symbol, + kodo_core::linear_block_encoder< + // Coefficient Storage API + kodo_core::coefficient_value_access< + // Proxy + kodo_core::proxy_layer > > > > > > > > > > > > +{ }; +} + +namespace fifi +{ +template +< + class T, + typename std::enable_if::value, + uint8_t>::type = 0 +> +inline void region_multiply_constant(T& t, uint8_t* dest, + typename T::value_type constant, + uint32_t size) +{ + t.region_multiply_constant(dest, constant, size); +} + +/// @copydoc layer::multipy_add(uint8_t*, const uint8_t*, +/// value_type, uint32_t) +void multiply_add(uint8_t* symbol_dest, + const uint8_t* symbol_src, + value_type coefficient, uint32_t symbol_size) +{ + assert(m_field); + assert(symbol_dest != 0); + assert(symbol_src != 0); + assert(symbol_size > 0); + + coefficient = fifi::pack_constant(coefficient); + + m_field->region_multiply_add(symbol_dest, symbol_src, coefficient, + symbol_size); +} +} + +namespace magic +{ +class my_class +{ +public: + + stub::function copy_into_symbol; + + stub::function< + void(uint8_t**, const uint8_t**, uint8_t**, + uint32_t, uint32_t, uint32_t) + > m_vector_dot_product; + + stub::function< + void (uint8_t*, const uint8_t*, value_type, uint32_t) + > multiply_add; + + my_class() : + m_value(0U), + m_second(1U) + { } + + uint32_t value() const + { + return m_value; + } + + void set_value(uint32_t value) + { + m_value = value; + + m_pep = m_pep * std::pow(base, losses + 1.0) + + (1.0 - std::pow(base, losses)); + + if (coffee_pot == full && + second_condition::value && + third_condition::value) + { + continue; + } + + try + { + my_function(); + } + catch (const std::exception& e) + { + // handles std::exception + } + catch (...) + { + // handles int or std::string or any other unrelated type + } + + m_redundancy_estimator.sample( + (1.0 + m_redundancy_estimator.estimate()) * + m_generation_size() / m_worst.get() - 1.0); + + m_worst = + (m_worst) ? std::max(*m_worst, s.m_rank) : s.m_rank; + } + + /// Queues an async receive call on the socket + void queue_async_receive() + { + assert(m_socket && "Invalid socket in queue_async_receive"); + + assert(cancelled == 0 && + "Rate limiter send called multiple times without " + "waiting for callback!"); + + namespace ph = std::placeholders; + + m_receive_buffer.resize(receive_buffer_size, 0u); + + std::shared_ptr ep = + std::make_shared(); + + m_timer->async_wait(std::bind(&rate_limiter::timeout_handler, + this, std::placeholders::_1, callback)); + + m_socket->async_receive_from( + boost::asio::buffer(m_receive_buffer), *ep, std::bind( + &sockets::handle_async_receive_from, this, + ph::_1, ph::_2, ep)); + } + + + template + < + class T = Value, + typename std::enable_if< + std::is_default_constructible::value, uint8_t>::type = 0 + > + resource_pool() : + m_pool(std::make_shared( + allocate_function(std::make_shared))) + { } + +private: + + uint32_t m_value; +}; +} + +/// Test that our resource pool is a regular type. We are not +/// implementing equality or less than here, but maybe we could. +namespace +{ +template +struct is_regular : + std::integral_constant::value && + std::is_copy_constructible::value && + std::is_move_constructible::value && + std::is_copy_assignable::value && + std::is_move_assignable::value> +{ }; +} + +int main(int argc, const char* argv[]) +{ + uint16_t num = 42; + + auto recycle = [&recycled](std::shared_ptr o) + { + EXPECT_TRUE((bool) o); + ++recycled; + }; + + std::vector data = + { + 0x67, 0x42, 0x00, 0x0A, 0xF8, 0x41, 0xA2 + }; + + // insert code here... + std::cout << "This is a very loooooooooong line for this Hello World! " + << num << std::endl; + + std::vector v = {0, 1, 2, 3, 4, 5}; + + for (int& i : v) + std::cout << i << ' '; + + return 0; +} diff --git a/wscript b/wscript index a05cb82..eadef83 100644 --- a/wscript +++ b/wscript @@ -1,11 +1,19 @@ #! /usr/bin/env python # encoding: utf-8 +import os +import filecmp +import difflib +import sys +import subprocess +import shutil +from waflib.TaskGen import feature, after_method +from waflib import Errors +import waflib.extras.wurf_options + APPNAME = 'astyle' VERSION = '0.1.0' -import waflib.extras.wurf_options - def options(opt): @@ -44,8 +52,64 @@ def build(bld): static_libs = ['Shell32'] bld.program( - features='cxx', + features='cxx test_astyle', source=bld.path.ant_glob('src/*.cpp'), lib=static_libs, target='astyle') + +@feature('test_astyle') +@after_method('apply_link') +def test_astyle(self): + # Only execute the tests within the current project + if self.path.is_child_of(self.bld.srcnode): + if self.bld.has_tool_option('run_tests'): + self.bld.add_post_fun(run_astyle_tests) + + +def run_command(args): + print("Running: {}".format(args)) + sys.stdout.flush() + subprocess.check_call(args) + + +def run_astyle_tests(bld): + astyle = bld.get_tgen_by_name('astyle').link_task.outputs[0].abspath() + options = "--options={}".format(bld.path.find_node('.astylerc').abspath()) + + if os.path.isdir('test'): + test_folder = os.path.join(os.getcwd(), 'test') + correct_style = os.path.join(test_folder, 'correct_style.cpp') + correct_lines = open(correct_style, 'r').readlines() + + temp_folder = os.path.join(test_folder, 'temp') + # Make sure that the temp folder is deleted before copytree + if os.path.isdir(temp_folder): + shutil.rmtree(temp_folder) + shutil.copytree(test_folder, temp_folder) + + incorrect_files = 0 + + # Run astyle to format each test file + for file in sorted(os.listdir(temp_folder)): + test_file = os.path.join(temp_folder, file) + if (os.path.isfile(test_file)): + print('Test file: '+test_file) + run_command([astyle, options, test_file]) + + # Compare the formatted file with the correct style + if not filecmp.cmp(correct_style, test_file): + incorrect_files += 1 + print('\nIncorrect formatting: {}'.format(test_file)) + + test_lines = open(test_file, 'r').readlines() + + diff = difflib.unified_diff(correct_lines, test_lines) + print(''.join(diff)) + + # Clean up the temp directory + shutil.rmtree(temp_folder) + + if incorrect_files > 0: + raise Errors.WafError('Number of incorrectly formatted ' + 'files: {}'.format(incorrect_files)) \ No newline at end of file From 2d9dba76cbc5f76d7f7e0a6f1a9c8a214b59fd74 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Tue, 27 Sep 2016 20:46:56 +0200 Subject: [PATCH 2/6] Use universal newlines for comparison --- wscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wscript b/wscript index eadef83..0005c34 100644 --- a/wscript +++ b/wscript @@ -80,7 +80,7 @@ def run_astyle_tests(bld): if os.path.isdir('test'): test_folder = os.path.join(os.getcwd(), 'test') correct_style = os.path.join(test_folder, 'correct_style.cpp') - correct_lines = open(correct_style, 'r').readlines() + correct_lines = open(correct_style, 'U').readlines() temp_folder = os.path.join(test_folder, 'temp') # Make sure that the temp folder is deleted before copytree @@ -102,7 +102,7 @@ def run_astyle_tests(bld): incorrect_files += 1 print('\nIncorrect formatting: {}'.format(test_file)) - test_lines = open(test_file, 'r').readlines() + test_lines = open(test_file, 'U').readlines() diff = difflib.unified_diff(correct_lines, test_lines) print(''.join(diff)) From 90757717a50ad910c8f385a9d64db7a691634956 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Tue, 27 Sep 2016 21:04:01 +0200 Subject: [PATCH 3/6] Fix newline comparison on windows --- wscript | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/wscript b/wscript index 0005c34..bd7ed38 100644 --- a/wscript +++ b/wscript @@ -2,7 +2,6 @@ # encoding: utf-8 import os -import filecmp import difflib import sys import subprocess @@ -80,7 +79,9 @@ def run_astyle_tests(bld): if os.path.isdir('test'): test_folder = os.path.join(os.getcwd(), 'test') correct_style = os.path.join(test_folder, 'correct_style.cpp') - correct_lines = open(correct_style, 'U').readlines() + # Read the input file using universal newlines (so the line endings + # are seen as '\n', even if git checks out the code with '\r\n') + correct_lines = open(correct_style, 'rU').readlines() temp_folder = os.path.join(test_folder, 'temp') # Make sure that the temp folder is deleted before copytree @@ -98,14 +99,14 @@ def run_astyle_tests(bld): run_command([astyle, options, test_file]) # Compare the formatted file with the correct style - if not filecmp.cmp(correct_style, test_file): + test_lines = open(test_file, 'r').readlines() + diff = difflib.unified_diff(correct_lines, test_lines) + diff_lines = ''.join(diff) + + if len(diff_lines) > 0: incorrect_files += 1 print('\nIncorrect formatting: {}'.format(test_file)) - - test_lines = open(test_file, 'U').readlines() - - diff = difflib.unified_diff(correct_lines, test_lines) - print(''.join(diff)) + print(diff_lines) # Clean up the temp directory shutil.rmtree(temp_folder) From d39345f7cd3a0ad49ed0bfe96502f4ae5787e4af Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Wed, 28 Sep 2016 03:26:12 +0200 Subject: [PATCH 4/6] Add ample code examples in correct_style.cpp --- test/correct_style.cpp | 664 +++++++++++++++++++++++++++++++++++------ wscript | 2 +- 2 files changed, 580 insertions(+), 86 deletions(-) diff --git a/test/correct_style.cpp b/test/correct_style.cpp index a374f0b..a1e7644 100644 --- a/test/correct_style.cpp +++ b/test/correct_style.cpp @@ -1,8 +1,13 @@ +// Copyright comment + +#pragma once + #include #include #include #include +// Indented preprocessor statements #if defined(PLATFORM_WINDOWS_PHONE) #if defined(PLATFORM_MSVC_ARM) // NEON introduced in VS2012 @@ -25,8 +30,12 @@ #endif #endif -namespace kodo_core +// Namespaces +namespace test { + +// Using expressions + /// @ingroup finite_field_layers /// /// @brief Template alias for the common set of finite field @@ -34,11 +43,9 @@ namespace kodo_core template using finite_field_layers = finite_field_math::type, + // Test comment finite_field>; -} -namespace kodo_rlnc -{ /// @ingroup coefficient_generator_layers /// /// @brief Generates an uniform random coefficient (from the @@ -49,13 +56,21 @@ namespace kodo_rlnc template using on_the_fly_generator = kodo_core::check_partial_generator< + // Test comment kodo_core::uniform_generator_layers::type > >; -} -namespace kodo_rlnc -{ +// Expression with template disambiguator +using type = typename std::conditional< + Predicate::value, + typename conditional_append, List...>::type, + typename conditional_append::type>::type; + +// Template stacks + template < class MainStack, @@ -85,22 +100,68 @@ class full_vector_recoding_stack : public kodo_core::final_layer > > > > > > > > > > > > > { }; + +template +struct is_regular : + // Comment 2 + std::integral_constant::value && + // Comment 4 + std::is_move_assignable::value> +{ }; + +class client : public + links::message_handler> +{ +protected: + + /// Helper struct to determine if two classes have the same field types + template + struct is_same_field + { + static const bool value = + std::is_same::value; + }; +}; + } -namespace fifi +// Nested namespaces +namespace test { -template -< - class T, - typename std::enable_if::value, - uint8_t>::type = 0 -> -inline void region_multiply_constant(T& t, uint8_t* dest, - typename T::value_type constant, - uint32_t size) + +namespace api { - t.region_multiply_constant(dest, constant, size); +inline std::shared_ptr build(final_interface* stack) +{ + auto api = dynamic_cast(stack); + assert(api); + return api->build(); } +} + +namespace +{ +struct dummy_one +{ + template + void construct(Factory& the_factory) + { + (void) the_factory; + m_construct(); + } + + stub::function m_construct; +}; +} + +} + +// Free functions /// @copydoc layer::multipy_add(uint8_t*, const uint8_t*, /// value_type, uint32_t) @@ -118,42 +179,341 @@ void multiply_add(uint8_t* symbol_dest, m_field->region_multiply_add(symbol_dest, symbol_src, coefficient, symbol_size); } + +template +inline auto easy_bind(std::function f, Args&&... args) -> + decltype(detail::easy_bind( + detail::build_indices {}, + f, std::forward(args)...)) +{ + return detail::easy_bind( + detail::build_indices {}, + f, std::forward(args)...); } -namespace magic +template +static auto test(int) -> + decltype(std::declval().some_function(), yes()); + +template +inline auto +vandermonde_matrix_base::config::construct_matrix(uint32_t symbols) -> + std::shared_ptr { + // Something +} + +template< + class Field, + class TraceTag +> +auto coder(const std::string& name) -> + boost::python::class_, boost::noncopyable> +{ + // Something +} + +template +inline auto easy_bind(indices, F const& f, Args&&... args) -> + decltype(std::bind( + f, std::forward(args)..., placeholder {} ...)) +{ + return std::bind( + f, std::forward(args)..., placeholder {} ...); +} + +template +inline auto easy_bind(R(T::*mf)(FArgs...), Args&&... args) -> + decltype(detail::easy_bind( + detail::build_indices<(sizeof...(FArgs) + 1) - sizeof...(Args)>(), + mf, std::forward(args)...)) +{ + // The extra argument is the object pointer (this) + static_assert(sizeof...(Args) <= sizeof...(FArgs) + 1, + "Too many arguments to easy_bind"); + + return detail::easy_bind( + detail::build_indices<(sizeof...(FArgs) + 1) - sizeof...(Args)>(), + mf, std::forward(args)...); +} + +template +< + class T, + typename std::enable_if::value, + uint8_t>::type = 0 +> +inline void region_multiply_constant(T& t, uint8_t* dest, + typename T::value_type constant, + uint32_t size) +{ + t.region_multiply_constant(dest, constant, size); +} + +template +< + typename... Types, + // Comment 1 + typename I = std::make_index_sequence< + // Comment 2 + std::tuple_size>::value> +> +constexpr auto tuple_to_array(std::tuple&& tuple); + + +#ifdef __cplusplus +extern "C" +{ +#endif + +KODOC_API +uint8_t kodoc_has_write_payload(kodoc_coder_t coder); + +KODOC_API +void kodoc_set_mutable_symbols( + kodoc_coder_t decoder, uint8_t* data, uint32_t size); + +#ifdef __cplusplus +} +#endif + +namespace fifi +{ +#ifdef PLATFORM_AVX2 + +namespace detail +{ +inline void multiply_helper(__m256i& low, __m256i& high, + __m256i*& table_ptr, __m256i& sum) +{ + __m256i table1, table2; + __m256i h, l, product; + + // Load the 32-byte row that contains the pre-calculated + // multiplication results with the low-half of the constant + table1 = _mm256_loadu_si256(table_ptr++); +} +} + +#else + +avx2_binary8_full_table::avx2_binary8_full_table() +{ + (void) m_table_one; + (void) m_table_two; +} + +void avx2_binary8_full_table::region_add( + uint8_t*, const uint8_t*, uint32_t) const +{ + // Not implemented + assert(0 && "This line should never be executed"); +} + +#endif +} + +// Enum +enum error_type +{ + failed_open_file = 1, + failed_open_file = 2 +}; + +// Normal class class my_class { public: - stub::function copy_into_symbol; - - stub::function< - void(uint8_t**, const uint8_t**, uint8_t**, - uint32_t, uint32_t, uint32_t) - > m_vector_dot_product; - - stub::function< - void (uint8_t*, const uint8_t*, value_type, uint32_t) - > multiply_add; + // Constructors my_class() : - m_value(0U), + m_first(0U), m_second(1U) { } - uint32_t value() const + my_class() : + m_vector { 1, 2, 3, 4 }, + m_second(1U) + { } + + // Make sure that this base class cannot be instantiated + factory(kodoc_factory_t factory, + std::function deleter) : + m_factory(factory, deleter) + { } + + decoder_factory(codec codec, field field, + uint32_t max_symbols, uint32_t max_symbol_size) : + factory(kodoc_new_decoder_factory( + (int32_t)codec, (int32_t)field, max_symbols, max_symbol_size), + [](kodoc_factory_t factory) { kodoc_delete_factory(factory); }) + { } + + io_service() : + m_io_service( + score_new_io_service(), [](score_io_service_t io) + { + score_delete_io_service(io); + }) + { } + + io_service() : + m_io_service( + score_new_io_service(), + { + 1, 2, 3 + }) + { } + + template + < + class T = Value, + typename std::enable_if< + std::is_default_constructible::value, uint8_t>::type = 0 + > + resource_pool() : + m_pool(std::make_shared( + allocate_function(std::make_shared))) + { } + +public: + + // Function calls + void function_calls() { - return m_value; + srand(static_cast(time(0))); + + assert(m_socket && "Invalid socket in queue_async_receive"); + + assert(cancelled == 0 && + "Rate limiter send called multiple times without " + "waiting for callback!"); + + m_timer->async_wait(std::bind(&rate_limiter::timeout_handler, + this, std::placeholders::_1, callback)); + + namespace ph = std::placeholders; + + m_socket->async_receive_from( + boost::asio::buffer(m_receive_buffer), *ep, std::bind( + &sockets::handle_async_receive_from, this, + ph::_1, ph::_2, ep)); + + m_redundancy_estimator.sample( + (1.0 + m_redundancy_estimator.estimate()) * + m_generation_size() / m_worst.get() - 1.0); + + m_formatters.insert(std::make_pair( + "csv", std::shared_ptr(new tables::csv_format())), + third_param); + + EXPECT_TRUE(main_stack->copy_from_symbols.expect_calls().with( + storage::storage(data)) + .to_bool()); + + // Before function + m_socket->async_receive_from( + // Line 1 + looooooooooooooooong_function_name1(m_receive_buffer), + // Line 2 + { 1, 2, 3, 4 }, + // Line 3 + looooooooooooooooong_function_name2( + // Line 4 + &sockets::handle_async_receive_from, this, + ph::_1, ph::_2, ep)); + + + // Initializer block within a function call + m_output_queue.insert(m_output_queue.begin(), + vector { 1, 2, 3 }); + + m_output_queue.insert(m_output_queue.begin(), + { + 1, 2, 3 + }, + more); + + // Examples for non-optimal manual layout. The lines should be broken + // after the '(' to get decent layout. + score::generation_storage_in::coder_type::factory factory(symbol_size, + generation_size); + + boost::asio::ip::multicast::join_group option(addr, + score::manual_sender::address_type()); } - void set_value(uint32_t value) + // Assignments and arithmetics + void assignments() { - m_value = value; - m_pep = m_pep * std::pow(base, losses + 1.0) + (1.0 - std::pow(base, losses)); + m_worst = + (m_worst) ? std::max(*m_worst, s.m_rank) : s.m_rank; + + bool binary_ext_fields = + std::is_same::value || + std::is_same::value; + + double time = static_cast( + boost::chrono::duration_cast( + m_total_stop-m_total_start).count()); + + statistics iter = calculate_statistics(iterations.cbegin(), + iterations.cend()); + + bool result = std::equal(input_buffer.begin(), input_buffer.end(), + output_buffer.begin()); + + m_socket->async_receive_from( + looooooooooooooooong_function_name1(alpha) < + looooooooooooooooong_function_name2(beta)); + + std::shared_ptr ep = + std::make_shared(); + + using rlnc_decoder = kodo_rlnc::full_vector_decoder< + fifi::binary, fifi::binary4, fifi::binary8>; + + uint8_t constant_matrix[3][3] = + { + {1, 2, 3}, + {5, 6, 7}, + {53, 71, 42} + }; + + expected_coefficients = + { 95, 203, 243, 46, 187, 199, 153, 152, 39, 114 }; + + EXXXXXXXXECT_EQ(1u, stack.m_send.calls()) << + "Only one packet be send as " << + "io service is not run yet"; + + out << "\t\t" << "dest = " << ((uintptr_t) std::get<0>(v)) + << " src = " << ((uintptr_t) std::get<1>(v)) + << " length = " << ((uint32_t) std::get<2>(v)) << std::endl; + + std::cout << "This is a very looooooong line for this Hello World! " << + "string string" << num << std::endl; + } + + // Return statements + void return_statements() + { + return looooooooooooooooong_function_name( + alpha + beta); + + return detail::easy_bind( + detail::build_indices(), + mf, std::forward(args)...); + } + + + // Control flow and special blocks + void blocks() + { if (coffee_pot == full && second_condition::value && third_condition::value) @@ -161,6 +521,36 @@ public: continue; } + while (foundAssignmentOp->length() < + foundNonAssignmentOp->length()) + { + foundAssignmentOp = NULL; + } + + for (const auto& item : m_snack_list) + { + item.write(writer, m_current_generation); + } + + for (auto it = stored_snacks.lower_bound(feedback_generation - rtt); + it != stored_snacks.end(); ++it) + { + lowest_rank = std::min(it->second, lowest_rank); + } + + switch (other.m_type) + { + case class_type::object: + m_internal.m_map = + new json::object_type( + other.m_internal.m_map->begin(), + other.m_internal.m_map->end()); + break; + default: + // Something + break; + } + try { my_function(); @@ -174,71 +564,175 @@ public: // handles int or std::string or any other unrelated type } - m_redundancy_estimator.sample( - (1.0 + m_redundancy_estimator.estimate()) * - m_generation_size() / m_worst.get() - 1.0); + // Alignment for commas + int a, b, c, + d, e, f; - m_worst = - (m_worst) ? std::max(*m_worst, s.m_rank) : s.m_rank; + // This is a block with an arbitrary macro header + RUN + { + max_value = *std::max_element(std::begin(m_container), + std::end(m_container)); + + m_redundancy_estimator.sample( + (1.0 + m_redundancy_estimator.estimate()) * + m_generation_size() / m_worst.get() - 1.0); + + bool alpha = beta + + gamma; + + return beta + + gamma; + } } - /// Queues an async receive call on the socket - void queue_async_receive() + + // Lambda functions + void lambda_functions() { - assert(m_socket && "Invalid socket in queue_async_receive"); + // Standalone lambdas - assert(cancelled == 0 && - "Rate limiter send called multiple times without " - "waiting for callback!"); + auto recycle = [&recycled](std::shared_ptr o) + { + EXPECT_TRUE((bool) o); + ++recycled; + }; - namespace ph = std::placeholders; + auto callback = [function](const std::string& zone, + const std::string& message) + { + boost::python::call(function, zone, message); + }; - m_receive_buffer.resize(receive_buffer_size, 0u); + auto callback = [function]( + const std::string& zone, const std::string& message) + { + boost::python::call(function, zone, message); + }; - std::shared_ptr ep = - std::make_shared(); + auto compare = [](const parameter& a, const parameter& b) -> bool + { + if (std::get<0>(a) != std::get<0>(b)) + return false; + }; - m_timer->async_wait(std::bind(&rate_limiter::timeout_handler, - this, std::placeholders::_1, callback)); + // Single-line lambdas - m_socket->async_receive_from( - boost::asio::buffer(m_receive_buffer), *ep, std::bind( - &sockets::handle_async_receive_from, this, - ph::_1, ph::_2, ep)); + std::function m_delay_generator = + []() { return 0; }; + + m_output_queue.insert(m_output_queue.begin(), + queue_item(repair, []() {})); + + std::generate(data.begin(), data.end(), + [&]() { return randval(engine); }); + + in.fetch_data_ready( + [&](std::vector& cb) { fetch_data_ready_stub(cb); }); + + // Lambda blocks as function arguments + + sender.flush([&io]() + { + io.stop(); + std::cout << "IO service stopped." << std::endl; + }); + + s.write_data(buffer, [&]() + { + io.post(write_data_callback); + }); + + m_io_thread = std::make_shared([&] + { + m_io_service.run(); + }); + + auto cmp = stub::make_compare([](const cup& c)->bool + { + return c.m_volume == 2.3; + }); + + // Lambda within a lambda + + deleter = [](kodoc_factory_t factory) + { + kodoc_delete_factory(factory); + + auto recycle = [&recycled](std::shared_ptr o) + { + EXPECT_TRUE((bool) o); + ++recycled; + }; + } + } + + // Standalone template expressions + void standalone_templates() + { + run_test_basic_api< + // Line 1 + Encoder, + // Line 2 + Decoder + >(symbols, symbol_size); + + parser< + box::moov> + >> + >> + > parser; + + { + SCOPED_TRACE(testing::Message() << "field = binary"); + run_test_basic_api< + Encoder, + // Line 2 + Decoder + >(symbols, symbol_size); + } } - template - < - class T = Value, - typename std::enable_if< - std::is_default_constructible::value, uint8_t>::type = 0 - > - resource_pool() : - m_pool(std::make_shared( - allocate_function(std::make_shared))) - { } +protected: -private: + // Member variables - uint32_t m_value; + std::function&)> m_write_symbol_callback; + + stub::function copy_into_symbol; + + stub::function< + void(uint8_t**, const uint8_t**, uint8_t**, uint32_t, uint32_t) + > m_vector_dot_product; + + stub::function< + void (uint8_t*, const uint8_t*, value_type, uint32_t) + > multiply_add; }; -} -/// Test that our resource pool is a regular type. We are not -/// implementing equality or less than here, but maybe we could. -namespace -{ -template -struct is_regular : - std::integral_constant::value && - std::is_copy_constructible::value && - std::is_move_constructible::value && - std::is_copy_assignable::value && - std::is_move_assignable::value> -{ }; -} +// gtest macros + +INSTANTIATE_TEST_CASE_P(/* symbol_size */, + test_message_serialize_parse_param, + ::testing::Values(/*4u, 10U, 15U, 30U,*/ + 150U, 300U, 500U, + 1500U, 3000U, 5000U)); + +INSTANTIATE_TEST_CASE_P( + /* symbol_size */, + test_message_serialize_parse_param, + ::testing::Values( + /*4u, 10U, 15U, 30U,*/ + 150U, 300U, 500U, + 1500U, 3000U, 5000U)); + +// Main function body int main(int argc, const char* argv[]) { @@ -250,6 +744,8 @@ int main(int argc, const char* argv[]) ++recycled; }; + std::vector v = {0, 1, 2, 3, 4, 5}; + std::vector data = { 0x67, 0x42, 0x00, 0x0A, 0xF8, 0x41, 0xA2 @@ -259,8 +755,6 @@ int main(int argc, const char* argv[]) std::cout << "This is a very loooooooooong line for this Hello World! " << num << std::endl; - std::vector v = {0, 1, 2, 3, 4, 5}; - for (int& i : v) std::cout << i << ' '; diff --git a/wscript b/wscript index bd7ed38..a2668a1 100644 --- a/wscript +++ b/wscript @@ -94,7 +94,7 @@ def run_astyle_tests(bld): # Run astyle to format each test file for file in sorted(os.listdir(temp_folder)): test_file = os.path.join(temp_folder, file) - if (os.path.isfile(test_file)): + if os.path.isfile(test_file): print('Test file: '+test_file) run_command([astyle, options, test_file]) From fab103cb473596b534fe53ca37d0a153a61fe156 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Thu, 29 Sep 2016 00:20:55 +0200 Subject: [PATCH 5/6] Properly handle initializer blocks with double block openers. For example: std::map generation_map( { {0, 100}, {1, 100}, {2, 100}, {3, 10}, {4, 10} }); --- src/ASBeautifier.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ASBeautifier.cpp b/src/ASBeautifier.cpp index 4c044a0..246f9ca 100644 --- a/src/ASBeautifier.cpp +++ b/src/ASBeautifier.cpp @@ -2909,12 +2909,13 @@ void ASBeautifier::parseCurrentLine(const string& line) if (!inStatementIndentStack->empty()) { bool initializerBlock = - (isInStatement && (prevNonSpaceCh == ',' || prevNonSpaceCh == '(')); + (prevNonSpaceCh == ',' || prevNonSpaceCh == '(' + || prevNonSpaceCh == '{'); // Purge the inStatementIndentStack if the line begins with '{' // and this is not a possible initializer block in a statement, // for example: function(arg, { 1, 2, 3, 4 }); - if (lineBeginsWithOpenBracket && !initializerBlock) + if (i == 0 && !initializerBlock) { while (!inStatementIndentStack->empty()) popLastInStatementIndent(); From 27c2c0e8cae988fe08977ed5841676b371c863ef Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Thu, 29 Sep 2016 00:32:43 +0200 Subject: [PATCH 6/6] Add test file for distorted style --- test/correct_style.cpp | 56 ++- test/distorted_style.cpp | 779 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 824 insertions(+), 11 deletions(-) create mode 100644 test/distorted_style.cpp diff --git a/test/correct_style.cpp b/test/correct_style.cpp index a1e7644..24000e2 100644 --- a/test/correct_style.cpp +++ b/test/correct_style.cpp @@ -180,17 +180,6 @@ void multiply_add(uint8_t* symbol_dest, symbol_size); } -template -inline auto easy_bind(std::function f, Args&&... args) -> - decltype(detail::easy_bind( - detail::build_indices {}, - f, std::forward(args)...)) -{ - return detail::easy_bind( - detail::build_indices {}, - f, std::forward(args)...); -} - template static auto test(int) -> decltype(std::declval().some_function(), yes()); @@ -222,6 +211,17 @@ inline auto easy_bind(indices, F const& f, Args&&... args) -> f, std::forward(args)..., placeholder {} ...); } +template +inline auto easy_bind(std::function f, Args&&... args) -> + decltype(detail::easy_bind( + detail::build_indices {}, + f, std::forward(args)...)) +{ + return detail::easy_bind( + detail::build_indices {}, + f, std::forward(args)...); +} + template inline auto easy_bind(R(T::*mf)(FArgs...), Args&&... args) -> decltype(detail::easy_bind( @@ -435,6 +435,22 @@ public: }, more); + m_output_queue.insert( + { + 1, 2, 3 + }, + m_output_queue.end()); + + std::map generation_map( + { {0, 100}, {1, 100}, {2, 100}, {3, 10}, {4, 10} }); + + std::map generation_map( + { + {0, 100}, {1, 100}, + {2, 100}, {3, 10}, + {4, 10} + }); + // Examples for non-optimal manual layout. The lines should be broken // after the '(' to get decent layout. score::generation_storage_in::coder_type::factory factory(symbol_size, @@ -502,6 +518,9 @@ public: // Return statements void return_statements() { + return m_pep * std::pow(base, losses + 1.0) + + (1.0 - std::pow(base, losses)); + return looooooooooooooooong_function_name( alpha + beta); @@ -514,6 +533,21 @@ public: // Control flow and special blocks void blocks() { + { + max_value = *std::max_element(std::begin(m_container), + std::end(m_container)); + + m_redundancy_estimator.sample( + (1.0 + m_redundancy_estimator.estimate()) * + m_generation_size() / m_worst.get() - 1.0); + + bool alpha = beta + + gamma; + + return beta + + gamma; + } + if (coffee_pot == full && second_condition::value && third_condition::value) diff --git a/test/distorted_style.cpp b/test/distorted_style.cpp new file mode 100644 index 0000000..f7a66b9 --- /dev/null +++ b/test/distorted_style.cpp @@ -0,0 +1,779 @@ + // Copyright comment + +#pragma once + +#include + #include + #include +#include + +// Indented preprocessor statements +#if defined(PLATFORM_WINDOWS_PHONE) +#if defined(PLATFORM_MSVC_ARM) + // NEON introduced in VS2012 + #if (_MSC_VER >= 1700) + #define PLATFORM_NEON 1 + #endif +#endif +#elif defined(PLATFORM_MSVC_X86) + // SSSE3, SSE4.1, SSE4.2, PCLMUL introduced in VS2008 + #if (_MSC_VER >= 1500) +#define PLATFORM_SSSE3 1 + #define PLATFORM_SSE41 1 + #define PLATFORM_SSE42 1 + #define PLATFORM_PCLMUL 1 +#endif + // AVX and AVX2 introduced in VS2012 + #if (_MSC_VER >= 1700) +#define PLATFORM_AVX 1 + #define PLATFORM_AVX2 1 + #endif +#endif + +// Namespaces +namespace test { + +// Using expressions + +/// @ingroup finite_field_layers + /// + /// @brief Template alias for the common set of finite field +/// layers used in most stacks +template +using finite_field_layers = + finite_field_math::type, + // Test comment + finite_field>; + +/// @ingroup coefficient_generator_layers +/// +/// @brief Generates an uniform random coefficient (from the +/// chosen Finite Field) for every symbol. In addition +/// using the pivot_aware_generate means that we will only +/// generate non-zero coefficients for symbols which are +/// available locally. +template +using on_the_fly_generator = + kodo_core::check_partial_generator< + // Test comment + kodo_core::uniform_generator_layers::type > >; + +// Expression with template disambiguator +using type = typename std::conditional< + Predicate::value, + typename conditional_append, List...>::type, + typename conditional_append::type>::type; + +// Template stacks + +template + < + class MainStack, + class Features + > +class full_vector_recoding_stack : public + // Payload API + kodo_core::payload_info< + // Codec Header API + kodo_core::default_off_systematic_encoder< + kodo_core::symbol_id_encoder< + // Symbol ID API + recoder_symbol_id< + // Coefficient Generator API + kodo_core::uniform_generator_layers::type, + kodo_core::trace_symbol, + kodo_core::linear_block_encoder< + // Coefficient Storage API + kodo_core::coefficient_value_access< + // Proxy + kodo_core::proxy_layer > > > > > > > > > > > > +{ }; + +template +struct is_regular : + // Comment 2 + std::integral_constant::value && + // Comment 4 + std::is_move_assignable::value> + { }; + +class client : public + links::message_handler> +{ +protected: + + /// Helper struct to determine if two classes have the same field types + template + struct is_same_field { + static const bool value = + std::is_same::value; + }; + }; + +} + +// Nested namespaces +namespace test +{ + +namespace api { +inline std::shared_ptr build(final_interface* stack) +{ + auto api = dynamic_cast(stack); + assert(api); + return api->build( ); +} +} + +namespace +{ +struct dummy_one +{ + template + void construct(Factory& the_factory) + { + (void) the_factory; + m_construct(); + } + + stub::function m_construct; +}; +} + +} + +// Free functions + +/// @copydoc layer::multipy_add(uint8_t*, const uint8_t*, +/// value_type, uint32_t) +void multiply_add(uint8_t* symbol_dest, + const uint8_t* symbol_src, + value_type coefficient, uint32_t symbol_size) +{ + assert (m_field); + assert(symbol_dest != 0); + assert( symbol_src != 0); + assert(symbol_size > 0); + + coefficient = fifi::pack_constant(coefficient); + + m_field->region_multiply_add(symbol_dest, symbol_src, coefficient, + symbol_size); +} + + template +static auto test(int) -> +decltype(std::declval().some_function(), yes()); + +template +inline auto +vandermonde_matrix_base::config::construct_matrix(uint32_t symbols) -> + std::shared_ptr +{ + // Something +} + +template< + class Field, + class TraceTag + > +auto coder(const std::string& name) -> + boost::python::class_, boost::noncopyable> + { + // Something + } + +template +inline auto easy_bind(indices, F const& f, Args&&... args) -> +decltype(std::bind( + f, std::forward(args)..., placeholder {} ...)) +{ +return std::bind( + f, std::forward(args)..., placeholder {} ...); +} + +template +inline auto easy_bind(std::function f, Args&&... args) -> + decltype(detail::easy_bind( + detail::build_indices {}, + f, std::forward(args)...)) +{ + return detail::easy_bind( + detail::build_indices {}, + f, std::forward(args)...); +} + + template +inline auto easy_bind(R(T::*mf)(FArgs...), Args&&... args) -> + decltype(detail::easy_bind( + detail::build_indices<(sizeof...(FArgs) + 1) - sizeof...(Args)>(), + mf, std::forward(args)...)) +{ + // The extra argument is the object pointer (this) + static_assert(sizeof...(Args) <= sizeof...(FArgs) + 1, + "Too many arguments to easy_bind"); + + return detail::easy_bind( + detail::build_indices<(sizeof...(FArgs) + 1) - sizeof...(Args)>(), + mf, std::forward(args)...); +} + +template +< + class T, + typename std::enable_if::value, + uint8_t>::type = 0 +> +inline void region_multiply_constant(T& t, uint8_t* dest, + typename T::value_type constant, + uint32_t size) +{ +t.region_multiply_constant(dest, constant, size); +} + +template + < + typename... Types, + // Comment 1 + typename I = std::make_index_sequence< + // Comment 2 + std::tuple_size>::value> + > +constexpr auto tuple_to_array(std::tuple&& tuple); + + +#ifdef __cplusplus +extern "C" +{ +#endif + +KODOC_API + uint8_t kodoc_has_write_payload(kodoc_coder_t coder); + +KODOC_API +void kodoc_set_mutable_symbols( + kodoc_coder_t decoder, uint8_t* data, uint32_t size); + +#ifdef __cplusplus +} +#endif + +namespace fifi +{ +#ifdef PLATFORM_AVX2 + +namespace detail +{ +inline void multiply_helper(__m256i &low, __m256i& high, + __m256i* &table_ptr, __m256i& sum) +{ + __m256i table1, table2; + __m256i h, l, product; + + // Load the 32-byte row that contains the pre-calculated + // multiplication results with the low-half of the constant + table1 = _mm256_loadu_si256(table_ptr++); +} +} + +#else + +avx2_binary8_full_table::avx2_binary8_full_table() +{ + (void) m_table_one; + (void) m_table_two; +} + +void avx2_binary8_full_table::region_add( + uint8_t*, const uint8_t*, uint32_t ) const + { + // Not implemented + assert(0 && "This line should never be executed"); +} + +#endif +} + +// Enum +enum error_type +{ + failed_open_file = 1, + failed_open_file = 2 + }; + +// Normal class +class my_class { +public: + + // Constructors + + my_class(): m_first(0U), + m_second(1U) + { } + + my_class() + : m_vector { 1, 2, 3, 4 }, + m_second(1U) + { } + + // Make sure that this base class cannot be instantiated + factory(kodoc_factory_t factory, + std::function deleter) + : m_factory(factory, deleter) + { } + + decoder_factory(codec codec, field field, + uint32_t max_symbols, uint32_t max_symbol_size): + factory(kodoc_new_decoder_factory( + (int32_t)codec, (int32_t)field, max_symbols, max_symbol_size), + [](kodoc_factory_t factory) { kodoc_delete_factory(factory); }) + { } + + io_service() : + m_io_service( + score_new_io_service(), [](score_io_service_t io) { + score_delete_io_service(io); + }) + { } + + io_service() : + m_io_service( + score_new_io_service(), + { + 1, 2, 3 + }) + { } + + template + < + class T = Value, + typename std::enable_if< + std::is_default_constructible::value, uint8_t>::type = 0 + > + resource_pool() : + m_pool(std::make_shared( + allocate_function(std::make_shared))) + { } + +public: + + // Function calls + void function_calls() { + srand( static_cast( time(0 ) )); + + assert(m_socket && "Invalid socket in queue_async_receive"); + + assert(cancelled == 0 && + "Rate limiter send called multiple times without " + "waiting for callback!"); + + m_timer->async_wait(std::bind(&rate_limiter::timeout_handler, + this, std::placeholders::_1, callback)); + + namespace ph = std::placeholders; + + m_socket->async_receive_from( + boost::asio::buffer(m_receive_buffer), *ep, std::bind( + &sockets::handle_async_receive_from, this, + ph::_1, ph::_2, ep)); + + m_redundancy_estimator.sample( + (1.0 + m_redundancy_estimator.estimate()) * + m_generation_size() / m_worst.get() - 1.0); + + m_formatters.insert(std::make_pair( + "csv", std::shared_ptr(new tables::csv_format())), + third_param); + + EXPECT_TRUE(main_stack->copy_from_symbols.expect_calls().with( + storage::storage(data)) + .to_bool()); + + // Before function + m_socket->async_receive_from( + // Line 1 + looooooooooooooooong_function_name1(m_receive_buffer), + // Line 2 + { 1, 2, 3, 4 }, + // Line 3 + looooooooooooooooong_function_name2( + // Line 4 + &sockets::handle_async_receive_from, this, + ph::_1, ph::_2, ep)); + + + // Initializer block within a function call + m_output_queue.insert(m_output_queue.begin(), + vector { 1, 2, 3 }); + + m_output_queue.insert(m_output_queue.begin(), + { + 1, 2, 3 + }, + more); + + m_output_queue.insert( + { + 1, 2, 3 + }, + m_output_queue.end()); + + std::map generation_map( + { {0, 100}, {1, 100}, {2, 100}, {3, 10}, {4, 10} }); + + std::map generation_map( + { + {0, 100}, {1, 100}, + {2, 100}, {3, 10}, + {4, 10} + }); + + // Examples for non-optimal manual layout. The lines should be broken + // after the '(' to get decent layout. + score::generation_storage_in::coder_type::factory factory(symbol_size, + generation_size); + + boost::asio::ip::multicast::join_group option(addr, + score::manual_sender::address_type()); + } + + // Assignments and arithmetics + void assignments() + { + m_pep = m_pep * std::pow(base, losses + 1.0) + + (1.0 - std::pow(base, losses)); + + m_worst = + (m_worst) ? std::max(*m_worst, s.m_rank) : s.m_rank; + + bool binary_ext_fields = + std::is_same::value || + std::is_same::value; + + double time = static_cast( + boost::chrono::duration_cast( + m_total_stop-m_total_start).count()); + + statistics iter = calculate_statistics(iterations.cbegin(), + iterations.cend()); + + bool result = std::equal(input_buffer.begin(), input_buffer.end(), + output_buffer.begin()); + + m_socket->async_receive_from( + looooooooooooooooong_function_name1(alpha) < + looooooooooooooooong_function_name2(beta)); + + std::shared_ptr ep = + std::make_shared(); + + using rlnc_decoder = kodo_rlnc::full_vector_decoder< + fifi::binary, fifi::binary4, fifi::binary8>; + + uint8_t constant_matrix[3][3] = + { + {1, 2, 3}, + {5, 6, 7}, + {53, 71, 42} + }; + + expected_coefficients = + { 95, 203, 243, 46, 187, 199, 153, 152, 39, 114 }; + + EXXXXXXXXECT_EQ(1u, stack.m_send.calls()) << + "Only one packet be send as " << + "io service is not run yet"; + + out << "\t\t" << "dest = " << ((uintptr_t) std::get<0>(v)) + << " src = " << ((uintptr_t) std::get<1>(v)) + << " length = " << ((uint32_t) std::get<2>(v)) << std::endl; + + std::cout << "This is a very looooooong line for this Hello World! " << + "string string" << num << std::endl; + } + + // Return statements + void return_statements() { + return m_pep * std::pow(base, losses + 1.0) + + (1.0 - std::pow(base, losses)); + + return looooooooooooooooong_function_name( + alpha + beta); + + return detail::easy_bind( + detail::build_indices(), + mf, std::forward(args)...); + } + + + // Control flow and special blocks + void blocks() + { + { + max_value = *std::max_element(std::begin(m_container), + std::end(m_container)); + + m_redundancy_estimator.sample( + (1.0 + m_redundancy_estimator.estimate()) * + m_generation_size() / m_worst.get() - 1.0); + + bool alpha = beta + + gamma; + + return beta + + gamma; + } + + if (coffee_pot == full && + second_condition::value && + third_condition::value) + { + continue; + } + + while (foundAssignmentOp->length() < + foundNonAssignmentOp->length()) + { + foundAssignmentOp = NULL; + } + + for (const auto & item : m_snack_list ) + { + item.write(writer, m_current_generation); + } + + for ( auto it = stored_snacks.lower_bound(feedback_generation - rtt); + it != stored_snacks.end();++it) { + lowest_rank = std::min(it->second, lowest_rank); + } + + switch (other.m_type) { + case class_type::object: + m_internal.m_map = + new json::object_type( + other.m_internal.m_map->begin(), + other.m_internal.m_map->end()); + break; + default: + // Something + break; + } + + try { + my_function(); + } + catch(const std::exception& e) + { + // handles std::exception + } + catch(...) + { + // handles int or std::string or any other unrelated type + } + + // Alignment for commas + int a, b, c, + d, e, f; + + // This is a block with an arbitrary macro header + RUN + { + max_value = *std::max_element(std::begin(m_container), + std::end(m_container)); + + m_redundancy_estimator.sample( + (1.0 + m_redundancy_estimator.estimate()) * + m_generation_size() / m_worst.get() - 1.0); + + bool alpha = beta + + gamma; + + return beta + + gamma; + } + } + + + // Lambda functions + void lambda_functions() + { + // Standalone lambdas + + auto recycle = [&recycled](std::shared_ptr o) { + EXPECT_TRUE((bool) o); + ++recycled; + }; + + auto callback = [function](const std::string& zone, + const std::string& message) + { + boost::python::call(function, zone, message); + }; + + auto callback = [function]( + const std::string& zone, const std::string& message) + { + boost::python::call(function, zone, message); + }; + + auto compare = [](const parameter& a, const parameter& b) -> bool { + if(std::get<0>(a) != std::get<0>(b)) + return false; + }; + + // Single-line lambdas + + std::function m_delay_generator = + []() { return 0; }; + + m_output_queue.insert(m_output_queue.begin(), + queue_item(repair, []() {})); + + std::generate(data.begin(), data.end(), + [&]() { return randval(engine); }); + + in.fetch_data_ready( + [&](std::vector& cb) { fetch_data_ready_stub(cb); }); + + // Lambda blocks as function arguments + + sender.flush([&io]() { + io.stop(); + std::cout << "IO service stopped." << std::endl; + }); + + s.write_data(buffer, [&]() + { + io.post(write_data_callback); + }); + + m_io_thread = std::make_shared([&] { + m_io_service.run(); + }); + + auto cmp = stub::make_compare( [](const cup& c)->bool + { + return c.m_volume == 2.3; + }); + + // Lambda within a lambda + + deleter = []( kodoc_factory_t factory) { + kodoc_delete_factory(factory); + + auto recycle = [&recycled](std::shared_ptr o) + { + EXPECT_TRUE((bool) o); + ++recycled; + }; + } + } + + // Standalone template expressions + void standalone_templates() + { + run_test_basic_api< + // Line 1 + Encoder, + // Line 2 + Decoder + >( symbols, symbol_size); + + parser< + box::moov> + >> + >> + > parser; + + { + SCOPED_TRACE(testing::Message() << "field = binary"); + run_test_basic_api< + Encoder, + // Line 2 + Decoder + >(symbols, symbol_size); + } + } + + + protected: + + // Member variables + + std::function&)> m_write_symbol_callback; + + stub::function copy_into_symbol; + + stub::function< + void(uint8_t**, const uint8_t**, uint8_t**, uint32_t, uint32_t) + > m_vector_dot_product; + + stub::function< + void (uint8_t*, const uint8_t*, value_type, uint32_t) + > multiply_add; + }; + +// gtest macros + + INSTANTIATE_TEST_CASE_P(/* symbol_size */, + test_message_serialize_parse_param, + ::testing::Values(/*4u, 10U, 15U, 30U,*/ + 150U, 300U, 500U, + 1500U, 3000U, 5000U)); + +INSTANTIATE_TEST_CASE_P ( +/* symbol_size */, +test_message_serialize_parse_param, +::testing::Values( + /*4u, 10U, 15U, 30U,*/ + 150U, 300U, 500U, + 1500U, 3000U, 5000U)); + +// Main function body + +int main(int argc, const char *argv[]) +{ + uint16_t num = 42; + + auto recycle = [&recycled](std::shared_ptr o) + { + EXPECT_TRUE((bool) o); + ++recycled; + }; + + std::vector v = {0, 1, 2, 3, 4, 5}; + + std::vector data = { + 0x67, 0x42, 0x00, 0x0A, 0xF8, 0x41, 0xA2 + }; + + // insert code here... + std::cout << "This is a very loooooooooong line for this Hello World! " + << num << std::endl; + + for (int &i : v) + std::cout << i << ' '; + + return 0; +}