hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
9c7d255d3c4aeeaa13cfb69977543d596294483a
5,769
hpp
C++
src/3rd party/boost/boost/mpl/aux_/preprocessed/msvc60/list.hpp
OLR-xray/OLR-3.0
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
[ "Apache-2.0" ]
8
2016-01-25T20:18:51.000Z
2019-03-06T07:00:04.000Z
src/3rd party/boost/boost/mpl/aux_/preprocessed/msvc60/list.hpp
OLR-xray/OLR-3.0
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
[ "Apache-2.0" ]
null
null
null
src/3rd party/boost/boost/mpl/aux_/preprocessed/msvc60/list.hpp
OLR-xray/OLR-3.0
b6a9bb2a0c1fb849b8c6cea2e831e1ceea5cc611
[ "Apache-2.0" ]
3
2016-02-14T01:20:43.000Z
2021-02-03T11:19:11.000Z
// preprocessed version of 'boost/mpl/list.hpp' header // see the original for copyright information namespace boost { namespace mpl { namespace aux { template< nttp_int N > struct list_impl_chooser; } namespace aux { template<> struct list_impl_chooser<0> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list0< > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<1> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list1< T0 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<2> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list2< T0, T1 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<3> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list3< T0, T1, T2 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<4> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list4< T0, T1, T2, T3 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<5> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list5< T0, T1, T2, T3, T4 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<6> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list6< T0, T1, T2, T3, T4, T5 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<7> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list7< T0, T1, T2, T3, T4, T5, T6 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<8> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list8< T0, T1, T2, T3, T4, T5, T6, T7 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<9> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list9< T0, T1, T2, T3, T4, T5, T6, T7, T8 > type; }; }; } // namespace aux namespace aux { template<> struct list_impl_chooser<10> { template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct result_ { typedef list10< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > type; }; }; } // namespace aux namespace aux { template< typename T > struct is_list_arg { enum { value = true }; }; template<> struct is_list_arg<void_> { enum { value = false }; }; template< typename T1, typename T2, typename T3, typename T4, typename T5 , typename T6, typename T7, typename T8, typename T9, typename T10 > struct list_count_args { enum { value = is_list_arg<T1>::value + is_list_arg<T2>::value + is_list_arg<T3>::value + is_list_arg<T4>::value + is_list_arg<T5>::value + is_list_arg<T6>::value + is_list_arg<T7>::value + is_list_arg<T8>::value + is_list_arg<T9>::value + is_list_arg<T10>::value }; }; template< typename T0, typename T1, typename T2, typename T3, typename T4 , typename T5, typename T6, typename T7, typename T8, typename T9 > struct list_impl { typedef aux::list_count_args< T0,T1,T2,T3,T4,T5,T6,T7,T8,T9 > arg_num_; typedef typename aux::list_impl_chooser< arg_num_::value >::template result_< T0,T1,T2,T3,T4,T5,T6,T7,T8,T9 >::type type; }; } // namespace aux template< typename T0 = void_, typename T1 = void_, typename T2 = void_ , typename T3 = void_, typename T4 = void_, typename T5 = void_ , typename T6 = void_, typename T7 = void_, typename T8 = void_ , typename T9 = void_ > struct list : aux::list_impl< T0,T1,T2,T3,T4,T5,T6,T7,T8,T9 >::type { typedef typename aux::list_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::type type; }; } // namespace mpl } // namespace boost
20.603571
75
0.585717
OLR-xray
9c7e1ef90a8ec0f15ee218c55331ddf8b327742a
4,361
hpp
C++
src/framework/types.hpp
awcross1/qiskit-aer
72863e804ec3d07c0da2ebeb665a31db7a7e3010
[ "Apache-2.0" ]
null
null
null
src/framework/types.hpp
awcross1/qiskit-aer
72863e804ec3d07c0da2ebeb665a31db7a7e3010
[ "Apache-2.0" ]
null
null
null
src/framework/types.hpp
awcross1/qiskit-aer
72863e804ec3d07c0da2ebeb665a31db7a7e3010
[ "Apache-2.0" ]
null
null
null
/** * Copyright 2018, IBM. * * This source code is licensed under the Apache License, Version 2.0 found in * the LICENSE.txt file in the root directory of this source tree. */ #ifndef _aer_framework_types_hpp_ #define _aer_framework_types_hpp_ #include <cstdint> #include <complex> #include <iostream> #include <map> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include "framework/matrix.hpp" // matrix class /***************************************************************************/ /** * * Numeric Types for backends * ******************************************************************************/ namespace AER { // Numeric Types using int_t = int_fast64_t; using uint_t = uint_fast64_t; using complex_t = std::complex<double>; using cvector_t = std::vector<complex_t>; using cmatrix_t = matrix<complex_t>; using rvector_t = std::vector<double>; using rmatrix_t = matrix<double>; using reg_t = std::vector<uint_t>; using stringset_t = std::unordered_set<std::string>; template <typename T> using stringmap_t = std::unordered_map<std::string, T>; } //============================================================================ // STL ostream overloads //============================================================================ // STL containers template <typename T1, typename T2> std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p); template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v); template <typename T, size_t N> std::ostream &operator<<(std::ostream &out, const std::array<T, N> &v); template <typename T1, typename T2, typename T3> std::ostream &operator<<(std::ostream &out, const std::map<T1, T2, T3> &m); template <typename T1, typename T2, typename T3> std::ostream &operator<<(std::ostream &out, const std::unordered_map<T1, T2, T3> &m); template <typename T1> std::ostream &operator<<(std::ostream &out, const std::unordered_set<T1> &s); template <typename T1> std::ostream &operator<<(std::ostream &out, const std::set<T1> &s); // ostream overload for pairs template <typename T1, typename T2> std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) { out << "(" << p.first << ", " << p.second << ")"; return out; } // ostream overload for vectors template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { out << "["; size_t last = v.size() - 1; for (size_t i = 0; i < v.size(); ++i) { out << v[i]; if (i != last) out << ", "; } out << "]"; return out; } // ostream overload for arrays template <typename T, size_t N> std::ostream &operator<<(std::ostream &out, const std::array<T, N> &v) { out << "["; for (size_t i = 0; i < N; ++i) { out << v[i]; if (i != N - 1) out << ", "; } out << "]"; return out; } // ostream overload for maps template <typename T1, typename T2, typename T3> std::ostream &operator<<(std::ostream &out, const std::map<T1, T2, T3> &m) { out << "{"; size_t pos = 0, last = m.size() - 1; for (auto const &p : m) { out << p.first << ":" << p.second; if (pos != last) out << ", "; pos++; } out << "}"; return out; } // ostream overload for unordered maps template <typename T1, typename T2, typename T3> std::ostream &operator<<(std::ostream &out, const std::unordered_map<T1, T2, T3> &m) { out << "{"; size_t pos = 0, last = m.size() - 1; for (auto const &p : m) { out << p.first << ":" << p.second; if (pos != last) out << ", "; pos++; } out << "}"; return out; } // ostream overload for sets template <typename T1> std::ostream &operator<<(std::ostream &out, const std::unordered_set<T1> &s) { out << "{"; size_t pos = 0, last = s.size() - 1; for (auto const &elt : s) { out << elt; if (pos != last) out << ", "; pos++; } out << "}"; return out; } // ostream overload for unordered sets template <typename T1> std::ostream &operator<<(std::ostream &out, const std::set<T1> &s) { out << "{"; size_t pos = 0, last = s.size() - 1; for (auto const &elt : s) { out << elt; if (pos != last) out << ", "; pos++; } out << "}"; return out; } //------------------------------------------------------------------------------ #endif
27.086957
86
0.557441
awcross1
9c7fc413e99ff5d562b8e24818372c33ed501fe5
21,547
cpp
C++
stl/src/vector_algorithms.cpp
tetex7/x46_STL
5a28cb89d58c05c41ea1704e59a74ee57005e428
[ "Apache-2.0" ]
1
2021-02-07T07:05:49.000Z
2021-02-07T07:05:49.000Z
stl/src/vector_algorithms.cpp
tetex7/x46_STL
5a28cb89d58c05c41ea1704e59a74ee57005e428
[ "Apache-2.0" ]
null
null
null
stl/src/vector_algorithms.cpp
tetex7/x46_STL
5a28cb89d58c05c41ea1704e59a74ee57005e428
[ "Apache-2.0" ]
null
null
null
// Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This must be as small as possible, because its contents are // injected into the msvcprt.lib and msvcprtd.lib import libraries. // Do not include or define anything else here. // In particular, basic_string must not be included here. #if (defined(_M_IX86) || defined(_M_X64)) && !defined(_M_CEE_PURE) #include <emmintrin.h> #include <immintrin.h> #include <intrin0.h> #include <isa_availability.h> extern "C" long __isa_enabled; template <class _BidIt> static void _Reverse_tail(_BidIt _First, _BidIt _Last) noexcept { for (; _First != _Last && _First != --_Last; ++_First) { const auto _Temp = *_First; *_First = *_Last; *_Last = _Temp; } } template <class _BidIt, class _OutIt> static void _Reverse_copy_tail(_BidIt _First, _BidIt _Last, _OutIt _Dest) noexcept { while (_First != _Last) { *_Dest++ = *--_Last; } } static size_t _Byte_length(const void* _First, const void* _Last) noexcept { return static_cast<const unsigned char*>(_Last) - static_cast<const unsigned char*>(_First); } static void _Advance_bytes(void*& _Target, ptrdiff_t _Offset) noexcept { _Target = static_cast<unsigned char*>(_Target) + _Offset; } static void _Advance_bytes(const void*& _Target, ptrdiff_t _Offset) noexcept { _Target = static_cast<const unsigned char*>(_Target) + _Offset; } extern "C" { __declspec(noalias) void __cdecl __std_swap_ranges_trivially_swappable_noalias( void* _First1, void* _Last1, void* _First2) noexcept { constexpr size_t _Mask_32 = ~((static_cast<size_t>(1) << 5) - 1); if (_Byte_length(_First1, _Last1) >= 32 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const void* _Stop_at = _First1; _Advance_bytes(_Stop_at, _Byte_length(_First1, _Last1) & _Mask_32); do { const __m256i _Left = _mm256_loadu_si256(static_cast<__m256i*>(_First1)); const __m256i _Right = _mm256_loadu_si256(static_cast<__m256i*>(_First2)); _mm256_storeu_si256(static_cast<__m256i*>(_First1), _Right); _mm256_storeu_si256(static_cast<__m256i*>(_First2), _Left); _Advance_bytes(_First1, 32); _Advance_bytes(_First2, 32); } while (_First1 != _Stop_at); } constexpr size_t _Mask_16 = ~((static_cast<size_t>(1) << 4) - 1); if (_Byte_length(_First1, _Last1) >= 16 #ifdef _M_IX86 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE2) #endif // _M_IX86 ) { const void* _Stop_at = _First1; _Advance_bytes(_Stop_at, _Byte_length(_First1, _Last1) & _Mask_16); do { const __m128i _Left = _mm_loadu_si128(static_cast<__m128i*>(_First1)); const __m128i _Right = _mm_loadu_si128(static_cast<__m128i*>(_First2)); _mm_storeu_si128(static_cast<__m128i*>(_First1), _Right); _mm_storeu_si128(static_cast<__m128i*>(_First2), _Left); _Advance_bytes(_First1, 16); _Advance_bytes(_First2, 16); } while (_First1 != _Stop_at); } #if defined(_M_X64) // NOTE: UNALIGNED MEMORY ACCESSES constexpr size_t _Mask_8 = ~((static_cast<size_t>(1) << 3) - 1); if (_Byte_length(_First1, _Last1) >= 8) { const void* _Stop_at = _First1; _Advance_bytes(_Stop_at, _Byte_length(_First1, _Last1) & _Mask_8); do { const unsigned long long _Left = *static_cast<unsigned long long*>(_First1); const unsigned long long _Right = *static_cast<unsigned long long*>(_First2); *static_cast<unsigned long long*>(_First1) = _Right; *static_cast<unsigned long long*>(_First2) = _Left; _Advance_bytes(_First1, 8); _Advance_bytes(_First2, 8); } while (_First1 != _Stop_at); } #elif defined(_M_IX86) // NOTE: UNALIGNED MEMORY ACCESSES constexpr size_t _Mask_4 = ~((static_cast<size_t>(1) << 2) - 1); if (_Byte_length(_First1, _Last1) >= 4) { const void* _Stop_at = _First1; _Advance_bytes(_Stop_at, _Byte_length(_First1, _Last1) & _Mask_4); do { const unsigned long _Left = *static_cast<unsigned long*>(_First1); const unsigned long _Right = *static_cast<unsigned long*>(_First2); *static_cast<unsigned long*>(_First1) = _Right; *static_cast<unsigned long*>(_First2) = _Left; _Advance_bytes(_First1, 4); _Advance_bytes(_First2, 4); } while (_First1 != _Stop_at); } #else #error Unsupported architecture #endif auto _First1c = static_cast<unsigned char*>(_First1); auto _Last1c = static_cast<unsigned char*>(_Last1); auto _First2c = static_cast<unsigned char*>(_First2); for (; _First1c != _Last1c; ++_First1c, ++_First2c) { unsigned char _Ch = *_First1c; *_First1c = *_First2c; *_First2c = _Ch; } } // TRANSITION, ABI: __std_swap_ranges_trivially_swappable() is preserved for binary compatibility void* __cdecl __std_swap_ranges_trivially_swappable(void* _First1, void* _Last1, void* _First2) noexcept { __std_swap_ranges_trivially_swappable_noalias(_First1, _Last1, _First2); return static_cast<char*>(_First2) + (static_cast<char*>(_Last1) - static_cast<char*>(_First1)); } __declspec(noalias) void __cdecl __std_reverse_trivially_swappable_1(void* _First, void* _Last) noexcept { if (_Byte_length(_First, _Last) >= 64 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const __m256i _Reverse_char_lanes_avx = _mm256_set_epi8( // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); const void* _Stop_at = _First; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 6 << 5); do { _Advance_bytes(_Last, -32); // vpermq to load left and right, and transpose the lanes const __m256i _Left = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<__m256i*>(_First)), 78); const __m256i _Right = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<__m256i*>(_Last)), 78); // transpose all the chars in the lanes const __m256i _Left_reversed = _mm256_shuffle_epi8(_Left, _Reverse_char_lanes_avx); const __m256i _Right_reversed = _mm256_shuffle_epi8(_Right, _Reverse_char_lanes_avx); _mm256_storeu_si256(static_cast<__m256i*>(_First), _Right_reversed); _mm256_storeu_si256(static_cast<__m256i*>(_Last), _Left_reversed); _Advance_bytes(_First, 32); } while (_First != _Stop_at); } if (_Byte_length(_First, _Last) >= 32 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE42)) { const __m128i _Reverse_char_sse = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); const void* _Stop_at = _First; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 5 << 4); do { _Advance_bytes(_Last, -16); const __m128i _Left = _mm_loadu_si128(static_cast<__m128i*>(_First)); const __m128i _Right = _mm_loadu_si128(static_cast<__m128i*>(_Last)); const __m128i _Left_reversed = _mm_shuffle_epi8(_Left, _Reverse_char_sse); // SSSE3 const __m128i _Right_reversed = _mm_shuffle_epi8(_Right, _Reverse_char_sse); _mm_storeu_si128(static_cast<__m128i*>(_First), _Right_reversed); _mm_storeu_si128(static_cast<__m128i*>(_Last), _Left_reversed); _Advance_bytes(_First, 16); } while (_First != _Stop_at); } _Reverse_tail(static_cast<unsigned char*>(_First), static_cast<unsigned char*>(_Last)); } __declspec(noalias) void __cdecl __std_reverse_trivially_swappable_2(void* _First, void* _Last) noexcept { if (_Byte_length(_First, _Last) >= 64 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const __m256i _Reverse_short_lanes_avx = _mm256_set_epi8( // 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, // 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); const void* _Stop_at = _First; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 6 << 5); do { _Advance_bytes(_Last, -32); const __m256i _Left = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<__m256i*>(_First)), 78); const __m256i _Right = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<__m256i*>(_Last)), 78); const __m256i _Left_reversed = _mm256_shuffle_epi8(_Left, _Reverse_short_lanes_avx); const __m256i _Right_reversed = _mm256_shuffle_epi8(_Right, _Reverse_short_lanes_avx); _mm256_storeu_si256(static_cast<__m256i*>(_First), _Right_reversed); _mm256_storeu_si256(static_cast<__m256i*>(_Last), _Left_reversed); _Advance_bytes(_First, 32); } while (_First != _Stop_at); } if (_Byte_length(_First, _Last) >= 32 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE42)) { const __m128i _Reverse_short_sse = _mm_set_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); const void* _Stop_at = _First; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 5 << 4); do { _Advance_bytes(_Last, -16); const __m128i _Left = _mm_loadu_si128(static_cast<__m128i*>(_First)); const __m128i _Right = _mm_loadu_si128(static_cast<__m128i*>(_Last)); const __m128i _Left_reversed = _mm_shuffle_epi8(_Left, _Reverse_short_sse); // SSSE3 const __m128i _Right_reversed = _mm_shuffle_epi8(_Right, _Reverse_short_sse); _mm_storeu_si128(static_cast<__m128i*>(_First), _Right_reversed); _mm_storeu_si128(static_cast<__m128i*>(_Last), _Left_reversed); _Advance_bytes(_First, 16); } while (_First != _Stop_at); } _Reverse_tail(static_cast<unsigned short*>(_First), static_cast<unsigned short*>(_Last)); } __declspec(noalias) void __cdecl __std_reverse_trivially_swappable_4(void* _First, void* _Last) noexcept { if (_Byte_length(_First, _Last) >= 64 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const void* _Stop_at = _First; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 6 << 5); do { _Advance_bytes(_Last, -32); const __m256i _Left = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<__m256i*>(_First)), 78); const __m256i _Right = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<__m256i*>(_Last)), 78); const __m256i _Left_reversed = _mm256_shuffle_epi32(_Left, 27); const __m256i _Right_reversed = _mm256_shuffle_epi32(_Right, 27); _mm256_storeu_si256(static_cast<__m256i*>(_First), _Right_reversed); _mm256_storeu_si256(static_cast<__m256i*>(_Last), _Left_reversed); _Advance_bytes(_First, 32); } while (_First != _Stop_at); } if (_Byte_length(_First, _Last) >= 32 #ifdef _M_IX86 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE2) #endif // _M_IX86 ) { const void* _Stop_at = _First; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 5 << 4); do { _Advance_bytes(_Last, -16); const __m128i _Left = _mm_loadu_si128(static_cast<__m128i*>(_First)); const __m128i _Right = _mm_loadu_si128(static_cast<__m128i*>(_Last)); const __m128i _Left_reversed = _mm_shuffle_epi32(_Left, 27); const __m128i _Right_reversed = _mm_shuffle_epi32(_Right, 27); _mm_storeu_si128(static_cast<__m128i*>(_First), _Right_reversed); _mm_storeu_si128(static_cast<__m128i*>(_Last), _Left_reversed); _Advance_bytes(_First, 16); } while (_First != _Stop_at); } _Reverse_tail(static_cast<unsigned long*>(_First), static_cast<unsigned long*>(_Last)); } __declspec(noalias) void __cdecl __std_reverse_trivially_swappable_8(void* _First, void* _Last) noexcept { if (_Byte_length(_First, _Last) >= 64 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const void* _Stop_at = _First; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 6 << 5); do { _Advance_bytes(_Last, -32); const __m256i _Left = _mm256_loadu_si256(static_cast<__m256i*>(_First)); const __m256i _Right = _mm256_loadu_si256(static_cast<__m256i*>(_Last)); const __m256i _Left_reversed = _mm256_permute4x64_epi64(_Left, 27); const __m256i _Right_reversed = _mm256_permute4x64_epi64(_Right, 27); _mm256_storeu_si256(static_cast<__m256i*>(_First), _Right_reversed); _mm256_storeu_si256(static_cast<__m256i*>(_Last), _Left_reversed); _Advance_bytes(_First, 32); } while (_First != _Stop_at); } if (_Byte_length(_First, _Last) >= 32 #ifdef _M_IX86 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE2) #endif // _M_IX86 ) { const void* _Stop_at = _First; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 5 << 4); do { _Advance_bytes(_Last, -16); const __m128i _Left = _mm_loadu_si128(static_cast<__m128i*>(_First)); const __m128i _Right = _mm_loadu_si128(static_cast<__m128i*>(_Last)); const __m128i _Left_reversed = _mm_shuffle_epi32(_Left, 78); const __m128i _Right_reversed = _mm_shuffle_epi32(_Right, 78); _mm_storeu_si128(static_cast<__m128i*>(_First), _Right_reversed); _mm_storeu_si128(static_cast<__m128i*>(_Last), _Left_reversed); _Advance_bytes(_First, 16); } while (_First != _Stop_at); } _Reverse_tail(static_cast<unsigned long long*>(_First), static_cast<unsigned long long*>(_Last)); } __declspec(noalias) void __cdecl __std_reverse_copy_trivially_copyable_1( const void* _First, const void* _Last, void* _Dest) noexcept { if (_Byte_length(_First, _Last) >= 32 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const __m256i _Reverse_char_lanes_avx = _mm256_set_epi8( // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); const void* _Stop_at = _Dest; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 5 << 5); do { _Advance_bytes(_Last, -32); const __m256i _Block = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<const __m256i*>(_Last)), 78); const __m256i _Block_reversed = _mm256_shuffle_epi8(_Block, _Reverse_char_lanes_avx); _mm256_storeu_si256(static_cast<__m256i*>(_Dest), _Block_reversed); _Advance_bytes(_Dest, 32); } while (_Dest != _Stop_at); } if (_Byte_length(_First, _Last) >= 16 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE42)) { const __m128i _Reverse_char_sse = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); const void* _Stop_at = _Dest; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 4 << 4); do { _Advance_bytes(_Last, -16); const __m128i _Block = _mm_loadu_si128(static_cast<const __m128i*>(_Last)); const __m128i _Block_reversed = _mm_shuffle_epi8(_Block, _Reverse_char_sse); // SSSE3 _mm_storeu_si128(static_cast<__m128i*>(_Dest), _Block_reversed); _Advance_bytes(_Dest, 16); } while (_Dest != _Stop_at); } _Reverse_copy_tail(static_cast<const unsigned char*>(_First), static_cast<const unsigned char*>(_Last), static_cast<unsigned char*>(_Dest)); } __declspec(noalias) void __cdecl __std_reverse_copy_trivially_copyable_2( const void* _First, const void* _Last, void* _Dest) noexcept { if (_Byte_length(_First, _Last) >= 32 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const __m256i _Reverse_short_lanes_avx = _mm256_set_epi8( // 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, // 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); const void* _Stop_at = _Dest; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 5 << 5); do { _Advance_bytes(_Last, -32); const __m256i _Block = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<const __m256i*>(_Last)), 78); const __m256i _Block_reversed = _mm256_shuffle_epi8(_Block, _Reverse_short_lanes_avx); _mm256_storeu_si256(static_cast<__m256i*>(_Dest), _Block_reversed); _Advance_bytes(_Dest, 32); } while (_Dest != _Stop_at); } if (_Byte_length(_First, _Last) >= 16 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE42)) { const __m128i _Reverse_short_sse = _mm_set_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14); const void* _Stop_at = _Dest; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 4 << 4); do { _Advance_bytes(_Last, -16); const __m128i _Block = _mm_loadu_si128(static_cast<const __m128i*>(_Last)); const __m128i _Block_reversed = _mm_shuffle_epi8(_Block, _Reverse_short_sse); // SSSE3 _mm_storeu_si128(static_cast<__m128i*>(_Dest), _Block_reversed); _Advance_bytes(_Dest, 16); } while (_Dest != _Stop_at); } _Reverse_copy_tail(static_cast<const unsigned short*>(_First), static_cast<const unsigned short*>(_Last), static_cast<unsigned short*>(_Dest)); } __declspec(noalias) void __cdecl __std_reverse_copy_trivially_copyable_4( const void* _First, const void* _Last, void* _Dest) noexcept { if (_Byte_length(_First, _Last) >= 32 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const void* _Stop_at = _Dest; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 5 << 5); do { _Advance_bytes(_Last, -32); const __m256i _Block = _mm256_permute4x64_epi64(_mm256_loadu_si256(static_cast<const __m256i*>(_Last)), 78); const __m256i _Block_reversed = _mm256_shuffle_epi32(_Block, 27); _mm256_storeu_si256(static_cast<__m256i*>(_Dest), _Block_reversed); _Advance_bytes(_Dest, 32); } while (_Dest != _Stop_at); } if (_Byte_length(_First, _Last) >= 16 #ifdef _M_IX86 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE2) #endif // _M_IX86 ) { const void* _Stop_at = _Dest; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 4 << 4); do { _Advance_bytes(_Last, -16); const __m128i _Block = _mm_loadu_si128(static_cast<const __m128i*>(_Last)); const __m128i _Block_reversed = _mm_shuffle_epi32(_Block, 27); _mm_storeu_si128(static_cast<__m128i*>(_Dest), _Block_reversed); _Advance_bytes(_Dest, 16); } while (_Dest != _Stop_at); } _Reverse_copy_tail(static_cast<const unsigned long*>(_First), static_cast<const unsigned long*>(_Last), static_cast<unsigned long*>(_Dest)); } __declspec(noalias) void __cdecl __std_reverse_copy_trivially_copyable_8( const void* _First, const void* _Last, void* _Dest) noexcept { if (_Byte_length(_First, _Last) >= 32 && _bittest(&__isa_enabled, __ISA_AVAILABLE_AVX2)) { const void* _Stop_at = _Dest; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 5 << 5); do { _Advance_bytes(_Last, -32); const __m256i _Block = _mm256_loadu_si256(static_cast<const __m256i*>(_Last)); const __m256i _Block_reversed = _mm256_permute4x64_epi64(_Block, 27); _mm256_storeu_si256(static_cast<__m256i*>(_Dest), _Block_reversed); _Advance_bytes(_Dest, 32); } while (_Dest != _Stop_at); } if (_Byte_length(_First, _Last) >= 16 #ifdef _M_IX86 && _bittest(&__isa_enabled, __ISA_AVAILABLE_SSE2) #endif // _M_IX86 ) { const void* _Stop_at = _Dest; _Advance_bytes(_Stop_at, _Byte_length(_First, _Last) >> 4 << 4); do { _Advance_bytes(_Last, -16); const __m128i _Block = _mm_loadu_si128(static_cast<const __m128i*>(_Last)); const __m128i _Block_reversed = _mm_shuffle_epi32(_Block, 78); _mm_storeu_si128(static_cast<__m128i*>(_Dest), _Block_reversed); _Advance_bytes(_Dest, 16); } while (_Dest != _Stop_at); } _Reverse_copy_tail(static_cast<const unsigned long long*>(_First), static_cast<const unsigned long long*>(_Last), static_cast<unsigned long long*>(_Dest)); } } // extern "C" #endif // (defined(_M_IX86) || defined(_M_X64)) && !defined(_M_CEE_PURE)
51.059242
121
0.635587
tetex7
9c813eaec6bd5b9db67e99391aa855f09f428692
11,281
cpp
C++
src/ListView.cpp
ok/FontBoy
dc3079d6099e97382ae536a08a858ccab86ed491
[ "Artistic-1.0" ]
2
2018-01-27T20:00:21.000Z
2022-03-27T10:11:43.000Z
src/ListView.cpp
ok/FontBoy
dc3079d6099e97382ae536a08a858ccab86ed491
[ "Artistic-1.0" ]
39
2015-01-07T07:17:18.000Z
2022-03-13T14:12:37.000Z
src/ListView.cpp
ok/FontBoy
dc3079d6099e97382ae536a08a858ccab86ed491
[ "Artistic-1.0" ]
13
2015-01-06T17:50:12.000Z
2021-02-07T19:16:53.000Z
/* ListView for displaing Fonts */ #include "Fontboy.h" #include "Prefs.h" #include "ListView.h" #include "ListWindow.h" #include "FontList.h" #include "MsgVals.h" #ifdef FFont_Support #include "FFont.h" #endif #include "Debug.h" ListView::ListView(BRect frame) :MultiBoxView(frame) { fontboy = dynamic_cast<Fontboy*>(be_app); prefs = fontboy->prefs; } ListView::~ListView() { } void ListView::FrameResized(float aWidth, float aHeight) { MultiBoxView::UpdateProperties(); Init(); MultiBoxView::FrameResized(aWidth, aHeight); } void ListView::DrawContentBox(int32 element) { BPoint point, point2; BFont infofont(be_plain_font), font(be_plain_font); BRect rect; struct fnode *fontptr; char atext[128]; const char *textinput[1]; char *textoutput[1]; float x, y; fontlist = dynamic_cast<Fontboy*>(be_app)->GetFontList(); if (fontlist != NULL) { GetRectAt(element, &rect); SetDrawingMode(B_OP_COPY); SetPenSize(0); fontptr = fontlist->FontAt(fontlist->GetFirstInView() + element); // Fill boxes at end of list with background color if (fontptr == NULL) { SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // adjust rectsize for borders rect.left++; // top rect doesn't need borders offset if (rect.top != 0) rect.top++; FillRect(rect); } // Draw Fontbox else { SetHighColor(prefs->GetMBgColor(fontptr->selected)); SetLowColor(prefs->GetMBgColor(fontptr->selected)); x = rect.left; y = rect.top; FillRect(rect); float cwidth = GetColWidth(); // Stroke line for base + ascent & decent height if (prefs->GetDrawHeights()) { SetHighColor(prefs->GetMHeightsColor(fontptr->selected)); point.Set(x, y + dist); point2.Set(x + cwidth, y + dist); StrokeLine(point, point2); point.Set(x, y + dist + th_base); point2.Set(x + cwidth, y + dist + th_base); StrokeLine(point, point2); point.Set(x, y + dist + th_all); point2.Set(x + cwidth, y + dist + th_all); StrokeLine(point, point2); } // Stroke line around fontrect SetHighColor(prefs->GetMStrokeColor()); if (prefs->GetDrawBorder()) { StrokeRect(rect); } // Set current font to display point.Set(x + leftdist, y + dist + th_base); font.SetFamilyAndStyle(fontptr->family, fontptr->style); font.SetSize(prefs->GetFontSize()); if (prefs->GetFontSize() > 18) // Set correct spacing for current fontsize font.SetSpacing(B_CHAR_SPACING); else font.SetSpacing(B_STRING_SPACING); SetFont(&font); // copy and maybe truncate text to display SetHighColor(prefs->GetMDisplayColor(fontptr->selected)); strcpy(atext, (const char *)prefs->GetDisplayText().String()); *textinput = *textoutput = atext; font.GetTruncatedStrings(textinput, 1, B_TRUNCATE_END, cwidth - leftdist, textoutput); DrawString(atext, point); // prepare font and text for fontinformation SetHighColor(prefs->GetMInfoColor(fontptr->selected)); point.Set(x + leftdist, y + dist + ih_base); SetFont(&infofont); sprintf(atext, "%s %s", fontptr->family, fontptr->style); *textinput = *textoutput = atext; infofont.GetTruncatedStrings(textinput, 1, B_TRUNCATE_END, cwidth - leftdist, textoutput); DrawString(atext, point); } } } void ListView::ScrollTo(BPoint apoint) { CalcLeader(); Draw(Bounds()); } void ListView::MouseDown(BPoint point) { struct fnode *fontptr; BPopUpMenu *popup; BMenuItem *item; BString dragtext; BPoint dragpoint; BRect rect, dragrect; int32 clicks = 0; int32 buttons = 0; uint32 dragbuttons = 0; #ifdef FFont_Support FFont font; #endif rect = Bounds(); rect.top = GetNumRows() * GetRowHeight() + 1; if (rect.Contains(point)) return; Window()->CurrentMessage()->FindInt32("clicks", &clicks); Window()->CurrentMessage()->FindInt32("buttons", &buttons); // check for doubleclick if ((clicks >= 2) && (buttons & B_PRIMARY_MOUSE_BUTTON)) { GetRectAt(point, &rect); if (rect.Contains(lastPoint)) { be_app->PostMessage(M_DETAILS); return; } } lastPoint = point; fontlist = dynamic_cast<Fontboy*>(be_app)->GetFontList(); if (fontlist == NULL) return; // update to new selected font fnode *sel = fontlist->FontAt(fontlist->GetSelected()); // Get FontPtr & Rect at Point x,y fontptr = fontlist->FontAt(GetElementAt(point) + fontlist->GetFirstInView()); if (fontptr != NULL) { if (fontptr != sel) { fontlist->SetSelected(fontptr->listpos); if (sel != NULL) DrawContentBox(sel->listpos - fontlist->GetFirstInView()); DrawContentBox(fontptr->listpos - fontlist->GetFirstInView()); } // check for right mousebutton if(buttons & B_SECONDARY_MOUSE_BUTTON) { popup = new BPopUpMenu("PopUp", false); popup->AddItem(item = new BMenuItem("Details", new BMessage(M_DETAILS))); popup->AddSeparatorItem(); popup->AddItem(item = new BMenuItem("Refresh", new BMessage(M_REFRESH))); ConvertToScreen(&point); item = popup->Go(point); if (item) { if (item->Message()->what == M_DETAILS) be_app->PostMessage(item->Message()->what); else Window()->PostMessage(item->Message()->what); } return; } dragrect.Set(point.x - 3, point.y - 3, point.x + 3, point.y + 3); GetMouse(&dragpoint, &dragbuttons, true); while (dragbuttons) { snooze(20 * 1000); GetMouse(&dragpoint, &dragbuttons, true); if (!dragrect.Contains(dragpoint)) { #ifndef FFont_Support BMessage dragmsg('Font'); #else BMessage dragmsg('!FNT'); font.SetFamilyAndStyle(fontptr->family, fontptr->style); font.SetSize(prefs->GetFontSize()); if(AddMessageFont(&dragmsg, "font", &font) != B_NO_ERROR) { printf("Error while adding FFont class to Drag & Drop Message!\n"); } #endif dragtext = fontptr->family; dragtext += " "; dragtext += fontptr->style; dragmsg.AddData("text/plain", B_MIME_TYPE, dragtext.String(), dragtext.Length()); dragtext = "<FONT FACE=\""; dragtext += fontptr->family; dragtext += "\"></FONT>\0"; dragmsg.AddData("text/html", B_MIME_TYPE, dragtext.String(), dragtext.Length()); // add text_run_array const int entryCount = 2; int32 size = sizeof(text_run_array) + (entryCount - 1) * sizeof(text_run); text_run_array* runArray = (text_run_array*)calloc(size, 1); if (runArray != NULL) { runArray->count = 1; const rgb_color black = {0, 0, 0, 255}; //font.SetSize(14); new (&runArray->runs[0].font) BFont(font); runArray->runs[0].color = black; new (&runArray->runs[1].font) BFont; dragmsg.AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE, runArray, size); free(runArray); } // calc rectangle for fontname BFont font(be_plain_font); font.SetFamilyAndStyle(fontptr->fsysvalue); font.SetSize(20.0); char atext[256]; sprintf(atext, "%s %s", fontptr->family, fontptr->style); const char* strings[1] = { atext }; BRect rrects[1]; escapement_delta zero_escapements[1] = {{ 0,0 }}; font.GetBoundingBoxesForStrings(strings,1,B_SCREEN_METRIC,zero_escapements,rrects); BRect rect(rrects[0]); rect.InsetBy(-dragdist, -dragdist); rect.OffsetTo(0, 0); //rect.Set(0, 0, 150, 50); BBitmap *dbmp = new BBitmap(rect, B_RGB32, true); BView *dview = new BView(rect, "temp", B_FOLLOW_NONE, B_WILL_DRAW); if (dbmp && dview) { dbmp->Lock(); dbmp->AddChild(dview); rgb_color c = prefs->GetMBgColor(true); c.alpha = 196; dview->SetLowColor(c); dview->SetHighColor(c); dview->FillRect(rect); c = prefs->GetMStrokeColor(); c.alpha = 196; dview->SetHighColor(c); dview->StrokeRect(rect); c = prefs->GetMDisplayColor(); c.alpha = 196; dview->SetHighColor(c); dview->SetFont(&font); font_height theight; font.GetHeight(&theight); // _sPrintf("asc: %f, desc: %f, lead: %f\n", theight.ascent, theight.descent, theight.leading); dview->DrawString(atext, BPoint(dragdist, dragdist + theight.ascent - theight.descent)); dbmp->RemoveChild(dview); dbmp->Unlock(); delete dview; DragMessage(&dragmsg, dbmp, B_OP_ALPHA, BPoint(10, 10)); break; } } } } } void ListView::MessageReceived(BMessage *msg) { switch (msg->what) { default: BView::MessageReceived(msg); break; } } void ListView::Init() { BRect frame = Bounds(); prefs->SetMViewRect(&frame); prefs->Update(); float rheight = prefs->GetRowHeight(); SetRowHeight(rheight); BFont font(be_plain_font); font.GetHeight(&infoheight); ih_base = dist + infoheight.ascent; font.SetSize(prefs->GetFontSize()); font.GetHeight(&textheight); th_base = textheight.ascent; th_all = textheight.ascent + textheight.descent; ih_base += th_all; SetAutoColumns(prefs->GetAutoAdjust()); float swidth = font.StringWidth(prefs->GetDisplayText().String()); swidth += swidth / 8.0; if (prefs->GetAutoAdjust()) { // calculate number of columns int32 ncols = int32(frame.right / swidth); if (ncols < 1) ncols = 1; SetNumCols(ncols); } else { SetNumCols(prefs->GetNumCols()); } float minw, maxw, minh, maxh; Window()->GetSizeLimits(&minw, &maxw, &minh, &maxh); Window()->SetSizeLimits(100, maxw, rheight + 33 + B_H_SCROLL_BAR_HEIGHT, maxh); BRect aRect(0, 0, swidth + 10, rheight + B_H_SCROLL_BAR_HEIGHT); if (aRect.Contains(Window()->Bounds())) { aRect = aRect | Window()->Bounds(); aRect = Window()->ConvertToScreen(aRect) & BScreen(B_MAIN_SCREEN_ID).Frame(); aRect.bottom -= 25; aRect = Window()->ConvertFromScreen(aRect); Window()->ResizeTo(aRect.right, aRect.bottom); } UpdateScrollBar(); CalcLeader(); } // needs ScrollBarUpdate before Call! void ListView::CalcLeader() { struct fnode *fontptr; BScrollBar *hsb, *vsb; int32 sval; fontlist = dynamic_cast<Fontboy*>(be_app)->GetFontList(); if (fontlist != NULL) { fontptr = fontlist->FirstFont(); if (int(GetNumCols()) == 1) { vsb=ScrollBar(B_VERTICAL); sval = int32(vsb->Value() - 1); for (int32 i = 0; i < sval; i++) fontptr = fontlist->GetNext(fontptr); } else { hsb=ScrollBar(B_HORIZONTAL); sval = int32((hsb->Value() - 1) * GetNumRows()); for (int32 i = 0; i < sval; i++) fontptr = fontlist->GetNext(fontptr); } fontlist->SetFirstInView(fontptr->listpos); } } void ListView::UpdateScrollBar() { fontlist = dynamic_cast<Fontboy*>(be_app)->GetFontList(); if (fontlist != NULL) { float nrows = GetNumRows(); float ncols = GetNumCols(); BScrollBar *hsb=ScrollBar(B_HORIZONTAL); BScrollBar *vsb=ScrollBar(B_VERTICAL); if (int(GetNumCols()) != 1) { float max = ceil(fontlist->CountFonts() / nrows) - ncols; float prop = ceil(fontlist->CountFonts() / nrows) / ncols; hsb->SetRange(1, max+1); hsb->SetProportion(1 / prop); hsb->SetSteps(1, ncols); vsb->SetRange(0, 0); } else { float max = fontlist->CountFonts() - nrows; float prop = ceil(fontlist->CountFonts() / nrows); vsb->SetRange(1, max+1); vsb->SetProportion(1 / prop); vsb->SetSteps(1, nrows); hsb->SetRange(0, 0); } } } void ListView::PrintRect(BRect *rect) { _sPrintf("Rect-> X:%f, Y:%f, W:%f, H:%f\n", rect->left, rect->top, rect->Width(), rect->Height()); }
27.31477
99
0.659871
ok
9c835c14925a857847ef4ce03475a3a58f006ddc
283
cpp
C++
DroneClient/Image.cpp
poli0048/Recon-DJI-IOS-Interface
65ec4858baab57a8acb5521102b972f5fe738bf5
[ "BSD-3-Clause" ]
1
2021-12-26T13:33:05.000Z
2021-12-26T13:33:05.000Z
DroneClient/Image.cpp
poli0048/Recon-DJI-IOS-Interface
65ec4858baab57a8acb5521102b972f5fe738bf5
[ "BSD-3-Clause" ]
null
null
null
DroneClient/Image.cpp
poli0048/Recon-DJI-IOS-Interface
65ec4858baab57a8acb5521102b972f5fe738bf5
[ "BSD-3-Clause" ]
2
2021-04-27T06:33:19.000Z
2021-12-26T13:33:13.000Z
// // Image.m // DroneClient // // Created by Ben Choi on 4/11/21. // #include "Image.hpp" Image::Image(unsigned char * bitmap, int rows, int cols, int size_pixel) { this->bitmap = bitmap; this->rows = rows; this->cols = cols; this->size_pixel = size_pixel; }
15.722222
74
0.614841
poli0048
9c8785d2fb133558cba8b7f2181081a1217a5890
701
cpp
C++
Array/At least two greater elements.cpp
DY-2001/DSA
0f1f7a19304a2e5cfef690bf51a22bbc73eef4bc
[ "MIT" ]
null
null
null
Array/At least two greater elements.cpp
DY-2001/DSA
0f1f7a19304a2e5cfef690bf51a22bbc73eef4bc
[ "MIT" ]
null
null
null
Array/At least two greater elements.cpp
DY-2001/DSA
0f1f7a19304a2e5cfef690bf51a22bbc73eef4bc
[ "MIT" ]
null
null
null
// { Driver Code Starts #include<bits/stdc++.h> using namespace std; // } Driver Code Ends class Solution{ public: vector<int> findElements(int a[], int n) { vector<int> v; sort(a, a + n); for(int i = 0; i < n - 2; i++) { v.push_back(a[i]); } return v; } }; // { Driver Code Starts. int main() { int t; cin>>t; while(t--) { int n; cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; Solution ob; vector <int> res = ob.findElements(a,n); for(int i=0;i<res.size();i++) cout<<res[i]<<" "; cout<<endl; } } // } Driver Code Ends
17.097561
48
0.442225
DY-2001
9c8792fa01d52b431dc851bb2a7f3f45fa82c123
3,218
cpp
C++
Based_Engine/Based_Engine/PlayerController.cpp
Sanmopre/Based_Engine
2a408dc501f6357bde9872e2eef70f67295e0a3a
[ "MIT" ]
null
null
null
Based_Engine/Based_Engine/PlayerController.cpp
Sanmopre/Based_Engine
2a408dc501f6357bde9872e2eef70f67295e0a3a
[ "MIT" ]
null
null
null
Based_Engine/Based_Engine/PlayerController.cpp
Sanmopre/Based_Engine
2a408dc501f6357bde9872e2eef70f67295e0a3a
[ "MIT" ]
null
null
null
#include "Application.h" #include "Input.h" #include "ObjectManager.h" #include "PlayerController.h" #include "GameObject.h" #include "RigidBodyComponent.h" #include "imgui_impl_sdl.h" #include "imgui_impl_opengl3.h" #include "misc/cpp/imgui_stdlib.h" #include "PxPhysicsAPI.h" PlayerController::PlayerController(char* name, GameObject* parent, Application* app, bool active) : Component(name, parent, app, active) { } PlayerController::~PlayerController() { parent->controller = nullptr; } bool PlayerController::Update(float dt) { if (!App->paused) if (parent->rigidbody) { physx::PxVec3 vel = parent->rigidbody->rigidBody->getLinearVelocity(); bool w = false; bool s = false; bool d = false; bool a = false; if (App->input->GetKey(SDL_SCANCODE_UP) == KEY_REPEAT) w = true; if (App->input->GetKey(SDL_SCANCODE_DOWN) == KEY_REPEAT) s = true; if (App->input->GetKey(SDL_SCANCODE_LEFT) == KEY_REPEAT) d = true; if (App->input->GetKey(SDL_SCANCODE_RIGHT) == KEY_REPEAT) a = true; if (s) parent->rigidbody->rigidBody->addForce(physx::PxVec3(0, 0, acceleration)); else if (!w) if (vel.z > 0) parent->rigidbody->rigidBody->addForce(physx::PxVec3(0, 0, -deceleration)); if (w) parent->rigidbody->rigidBody->addForce(physx::PxVec3(0, 0, -acceleration)); else if (!s) if (vel.z < 0) parent->rigidbody->rigidBody->addForce(physx::PxVec3(0, 0, deceleration)); if (a) parent->rigidbody->rigidBody->addForce(physx::PxVec3(acceleration, 0, 0)); else if (!d) if (vel.x > 0) parent->rigidbody->rigidBody->addForce(physx::PxVec3(-deceleration, 0, 0)); if (d) parent->rigidbody->rigidBody->addForce(physx::PxVec3(-acceleration, 0, 0)); else if (!a) if (vel.x < 0) parent->rigidbody->rigidBody->addForce(physx::PxVec3(deceleration, 0, 0)); bool changed = false; for (int i = 0; i < 3; i++) if (vel[i] > maxVelocity) { vel[i] = maxVelocity; changed = true; } else if (vel[i] < -maxVelocity) { vel[i] = -maxVelocity; changed = true; } if (changed) parent->rigidbody->rigidBody->setLinearVelocity(vel); } else { bool pressed = false; if (App->input->GetKey(SDL_SCANCODE_UP) == KEY_DOWN) pressed = true; else if (App->input->GetKey(SDL_SCANCODE_DOWN) == KEY_DOWN) pressed = true; else if (App->input->GetKey(SDL_SCANCODE_LEFT) == KEY_DOWN) pressed = true; else if (App->input->GetKey(SDL_SCANCODE_RIGHT) == KEY_DOWN) pressed = true; if (pressed) LOG("Player controller error! No RigidBody found!"); } return true; } void PlayerController::DisplayComponentMenu() { if (ImGui::CollapsingHeader("Player Controller", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Checkbox("active controller", &active); ImGui::SameLine(); if (ImGui::Button("delete controller")) to_delete = true; ImGui::InputFloat("max speed", &maxVelocity); ImGui::InputFloat("acceleration", &acceleration); ImGui::InputFloat("deceleration", &deceleration); } } void PlayerController::SetAccAndDec(float acceleration, float deceleration) { this->acceleration = acceleration; this->deceleration = deceleration; }
26.162602
97
0.668428
Sanmopre
9c8a049dbf64464ff7f49239eb93319075ef031c
6,857
cpp
C++
platform/gucefCORE/src/gucefCORE_CBusyWaitPulseGeneratorDriver.cpp
amvb/GUCEF
08fd423bbb5cdebbe4b70df24c0ae51716b65825
[ "Apache-2.0" ]
5
2016-04-18T23:12:51.000Z
2022-03-06T05:12:07.000Z
platform/gucefCORE/src/gucefCORE_CBusyWaitPulseGeneratorDriver.cpp
amvb/GUCEF
08fd423bbb5cdebbe4b70df24c0ae51716b65825
[ "Apache-2.0" ]
2
2015-10-09T19:13:25.000Z
2018-12-25T17:16:54.000Z
platform/gucefCORE/src/gucefCORE_CBusyWaitPulseGeneratorDriver.cpp
amvb/GUCEF
08fd423bbb5cdebbe4b70df24c0ae51716b65825
[ "Apache-2.0" ]
15
2015-02-23T16:35:28.000Z
2022-03-25T13:40:33.000Z
/* * gucefCORE: GUCEF module providing O/S abstraction and generic solutions * Copyright (C) 2002 - 2008. Dinand Vanvelzen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /*-------------------------------------------------------------------------// // // // INCLUDES // // // //-------------------------------------------------------------------------*/ #ifndef GUCEF_MT_DVMTOSWRAP_H #include "gucefMT_dvmtoswrap.h" #define GUCEF_MT_DVMTOSWRAP_H #endif /* GUCEF_MT_DVMTOSWRAP_H ? */ #ifndef GUCEF_CORE_CTRACER_H #include "CTracer.h" #define GUCEF_CORE_CTRACER_H #endif /* GUCEF_CORE_CTRACER_H ? */ #ifndef GUCEF_CORE_LOGGING_H #include "gucefCORE_Logging.h" #define GUCEF_CORE_LOGGING_H #endif /* GUCEF_CORE_LOGGING_H ? */ #include "gucefCORE_CBusyWaitPulseGeneratorDriver.h" /*-------------------------------------------------------------------------// // // // NAMESPACE // // // //-------------------------------------------------------------------------*/ namespace GUCEF { namespace CORE { /*-------------------------------------------------------------------------// // // // UTILITIES // // // //-------------------------------------------------------------------------*/ CBusyWaitPulseGeneratorDriver::CBusyWaitPulseGeneratorDriver( void ) : CIPulseGeneratorDriver() , m_loop( false ) , m_desiredPulseDelta( 10 ) , m_immediatePulseTickets( 0 ) , m_immediatePulseTicketMax( 1 ) {GUCEF_TRACE; } /*--------------------------------------------------------------------------*/ CBusyWaitPulseGeneratorDriver::CBusyWaitPulseGeneratorDriver( const CBusyWaitPulseGeneratorDriver& src ) : CIPulseGeneratorDriver( src ) , m_loop( false ) , m_desiredPulseDelta( 10 ) , m_immediatePulseTickets( 0 ) , m_immediatePulseTicketMax( 1 ) {GUCEF_TRACE; } /*--------------------------------------------------------------------------*/ CBusyWaitPulseGeneratorDriver::~CBusyWaitPulseGeneratorDriver() {GUCEF_TRACE; m_loop = false; } /*--------------------------------------------------------------------------*/ void CBusyWaitPulseGeneratorDriver::RequestImmediatePulse( CPulseGenerator& pulseGenerator ) {GUCEF_TRACE; if ( m_loop ) { m_immediatePulseTickets = m_immediatePulseTicketMax; } else SendDriverPulse( pulseGenerator ); } /*--------------------------------------------------------------------------*/ void CBusyWaitPulseGeneratorDriver::RequestPulsesPerImmediatePulseRequest( CPulseGenerator& pulseGenerator , const Int32 requestedPulsesPerImmediatePulseRequest ) {GUCEF_TRACE; if ( requestedPulsesPerImmediatePulseRequest > 1 ) m_immediatePulseTicketMax = requestedPulsesPerImmediatePulseRequest; else m_immediatePulseTicketMax = 1; } /*--------------------------------------------------------------------------*/ void CBusyWaitPulseGeneratorDriver::Run( CPulseGenerator& pulseGenerator , UInt32 forcedMinimalCycleDeltaInMilliSecs , UInt32 desiredMaximumCycleDeltaInMilliSecs ) {GUCEF_TRACE; m_loop = true; while ( m_loop ) { // For immediate pulses we use a tight loop with no CPU yielding at all // This is intended for when the application is stressed and CPU bottlenecking on its workload if ( m_immediatePulseTickets > 0 ) { --m_immediatePulseTickets; SendDriverPulse( pulseGenerator ); continue; } pulseGenerator.WaitTillNextPulseWindow( forcedMinimalCycleDeltaInMilliSecs, desiredMaximumCycleDeltaInMilliSecs ); SendDriverPulse( pulseGenerator ); } GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "BusyWaitPulseGeneratorDriver: Exited run loop" ); } /*--------------------------------------------------------------------------*/ void CBusyWaitPulseGeneratorDriver::RequestPeriodicPulses( CPulseGenerator& pulseGenerator , const UInt32 pulseDeltaInMilliSecs ) {GUCEF_TRACE; m_desiredPulseDelta = pulseDeltaInMilliSecs; } /*--------------------------------------------------------------------------*/ void CBusyWaitPulseGeneratorDriver::RequestPulseInterval( CPulseGenerator& pulseGenerator , const UInt32 pulseDeltaInMilliSecs ) {GUCEF_TRACE; m_desiredPulseDelta = pulseDeltaInMilliSecs; } /*--------------------------------------------------------------------------*/ void CBusyWaitPulseGeneratorDriver::RequestStopOfPeriodicUpdates( CPulseGenerator& pulseGenerator ) {GUCEF_TRACE; m_loop = false; } /*-------------------------------------------------------------------------// // // // NAMESPACE // // // //-------------------------------------------------------------------------*/ }; /* namespace CORE */ }; /* namespace GUCEF */ /*--------------------------------------------------------------------------*/
37.883978
124
0.448884
amvb
9c8fb782fe8976e50b6a830c33d521b6bcfc7006
4,231
hpp
C++
include/Convolver.hpp
Buerner/laproque
c44ebf7705770d269bf5df14b4be0a76869e66d5
[ "MIT" ]
null
null
null
include/Convolver.hpp
Buerner/laproque
c44ebf7705770d269bf5df14b4be0a76869e66d5
[ "MIT" ]
null
null
null
include/Convolver.hpp
Buerner/laproque
c44ebf7705770d269bf5df14b4be0a76869e66d5
[ "MIT" ]
null
null
null
// // Convolver.hpp // laproque - https://github.com/Buerner/laproque // // Copyright © 2017 Martin Bürner. All rights reserved. // Licensed under the MIT License. See LICENSE.md file in the project root for full license information. // #ifndef Convolver_hpp #define Convolver_hpp #include <stdio.h> #include <fftw3.h> #include <atomic> #include "complexmath.hpp" #include "FFThelper.hpp" namespace laproque { // TODO: The _freq_resp_parts array must be thread safe because // replacing could interfere with the audio porcessing. Maybe write a // threadsafe array class and overload braces operator. /** * @brief Partitioned fast convolution class. * * Class which computes the convolution of and input buffer with an impulse response passed on initialization of instance. It uses the partitioned convolution approach to allow the use in blockwise audio processing. * On initialization just pass your impulse response, its size and the size of the partitiones. */ class Convolver { public: /** * @brief Construtor for convolver instance with desired impulse response. * @param imp_resp Pointer to the impulse response you want to use. * @param n_samples Length of the impulse response in samples. * @param block_size Size of the processing blocks i.e. partitions. */ Convolver(float* imp_resp, unsigned long n_samples, unsigned block_size); /** * Copy constructor. */ Convolver( Convolver& conv ); virtual ~Convolver(); /** * @brief Function which computes the convolution result. * Note that the size of input and outputs equals the block_size chosen on initialization. * @param in_buffer Input data with size of block_size. * @param out_buffer Output data with size of block_size. */ virtual void process( float* in_buffer, float* out_buffer ); /** * @brief Replace frequency response. * * This functions overwrites the currently frequency response which is currently set. It expects correctly patitioned blocks in the frequency domain. */ void set_freq_response( fftwf_complex* new_response ); /** * @brief Set time domain input buffer to 0. * * As the class processes multiple blocks, the input needs to be stored to comply with the partitiond convolution pricipal. When you want to use a Convolver instance for different input signals call this function between processing. */ void reset_input_buffer(); /** * @brief Returns FFT resolution. */ unsigned get_fft_size(); /** * @brief Returns processing block size. */ unsigned get_block_size(); /** * @brief Returns resolution of one partition (fft_size/2 + 1). */ unsigned get_spectrum_size(); /** * @brief Returns size of all frequency domain partitions combined. */ unsigned get_spectra_size(); /** * @brief Returns number of partitions. */ unsigned get_n_parts(); protected: /** Length of discrete fourier transform */ unsigned _fft_size; /** Number of frames in on block during block processing. */ unsigned _block_size; /** Number fo complex values in one partition pectrum */ unsigned _spectrum_size; /** Number of complex values in partitions combined */ unsigned _spectra_size; /** Number of partitions. */ unsigned _n_parts; float* _input; float* _result; fftwf_complex* _input_spectra; fftwf_complex* _freq_resp_parts; fftwf_complex* _multiply_buffer; fftwf_complex* _output_spectr; FFThelper _fft; /** Takes care of all memory reservations needed for convolution process. */ void _make_allocations(); /** * @brief Actual fast convolution process . * Heart of the convolution. * Implemented as seperate function to enable derived classes to do additional processing. */ void _fast_conv(); /** * Prepares the frequency response partitions i.e. computes FFT of blocks of the impulse response. */ void _compute_freq_resp( float* imp_resp ); }; } // namespace laproque #endif /* Convolver_hpp */
30.221429
236
0.684235
Buerner
9c8fda6067ee26ee33f42a94c47ea70a9d9effba
1,170
cpp
C++
CurveSim/Edge.cpp
suvojit-0x55aa/CurveSim
57b49eddb038330919f365635628be619d4120cc
[ "MIT" ]
1
2019-11-23T06:15:57.000Z
2019-11-23T06:15:57.000Z
CurveSim/Edge.cpp
suvojit-0x55aa/CurveSim
57b49eddb038330919f365635628be619d4120cc
[ "MIT" ]
null
null
null
CurveSim/Edge.cpp
suvojit-0x55aa/CurveSim
57b49eddb038330919f365635628be619d4120cc
[ "MIT" ]
null
null
null
#include "Edge.h" //Author : Suvojit Manna //Application : CurveSim Edge::Edge( const std::bitset<STATES> &fromState, const size_t fromID, const std::bitset<STATES> &toState, const size_t toID, const size_t latency ) { this->toState = toState; this->fromState = fromState; this->toID = toID; this->fromID = fromID; this->latency = latency; } //Return the tail state const std::bitset<STATES>& Edge::to_state(void) { return toState; } //Return head state const std::bitset<STATES>& Edge::from_state(void) { return fromState; } //Return tail state ID size_t Edge::to(void) const { return toID; } //Return head state ID size_t Edge::from(void) const { return fromID; } //Return latency size_t Edge::get_latency(void) const { return latency; } //Return the Edge as a string std::string Edge::to_string(size_t stateLen) const { std::string edgeStr; //Build the string edgeStr = fromState.to_string().substr(STATES - stateLen) + " -(" + std::to_string(latency) + ")-> " + toState.to_string().substr(STATES - stateLen); return edgeStr; //TODO : Format string }
24.893617
72
0.651282
suvojit-0x55aa
9c94756193805c751b12866c2fdcba1390389984
2,064
cpp
C++
Source/GameBaseFramework/Private/GameFramework/GBFSaveGame.cpp
TheEmidee/UEGameBaseFramework
10ab0e7a508a155844c12421c2713e459b8c68ad
[ "MIT" ]
null
null
null
Source/GameBaseFramework/Private/GameFramework/GBFSaveGame.cpp
TheEmidee/UEGameBaseFramework
10ab0e7a508a155844c12421c2713e459b8c68ad
[ "MIT" ]
null
null
null
Source/GameBaseFramework/Private/GameFramework/GBFSaveGame.cpp
TheEmidee/UEGameBaseFramework
10ab0e7a508a155844c12421c2713e459b8c68ad
[ "MIT" ]
null
null
null
#include "GameFramework/GBFSaveGame.h" #include <Kismet/GameplayStatics.h> UGBFSaveGame::UGBFSaveGame() : EnableForceFeedback( true ), EnableSubtitles( true ) { } int UGBFSaveGame::GetAchievementCurrentCount( const FName & achievement_id ) const { if ( const auto current_count = AchievementsCurrentCountMap.Find( achievement_id ) ) { return *current_count; } return 0; } void UGBFSaveGame::SetSlotNameAndIndex( const FString & slot_name, const int user_index ) { SlotName = slot_name; UserIndex = user_index; } void UGBFSaveGame::UpdateAchievementCurrentCount( const FName achievement_id, const int current_count ) { AchievementsCurrentCountMap.FindOrAdd( achievement_id ) = current_count; IsDirty = true; } void UGBFSaveGame::ResetAchievementsProgression() { #if !( UE_BUILD_SHIPPING || UE_BUILD_TEST ) AchievementsCurrentCountMap.Reset(); IsDirty = true; #endif } void UGBFSaveGame::SetActiveCulture( const FString & active_culture ) { if ( ActiveCulture == active_culture ) { return; } ActiveCulture = active_culture; IsDirty = true; } void UGBFSaveGame::SetEnableForceFeedback( const bool new_value ) { if ( EnableForceFeedback == new_value ) { return; } EnableForceFeedback = new_value; IsDirty = true; } void UGBFSaveGame::SetEnableSubtitles( const bool new_value ) { if ( EnableSubtitles == new_value ) { return; } EnableSubtitles = new_value; IsDirty = true; } bool UGBFSaveGame::Save() { if ( GetIsDirty() ) { if ( !ensure( !SlotName.IsEmpty() ) ) { return false; } OnSaveGameSavedEvent.Broadcast(); const auto save_to_slot_result = UGameplayStatics::SaveGameToSlot( this, SlotName, UserIndex ); if ( save_to_slot_result ) { IsDirty = false; } return save_to_slot_result; } return true; }
21.5
104
0.636143
TheEmidee
9c948d8da63f539fb871d4dbf714cfa7d4d518bd
652
cpp
C++
src/common/HostStencilFactory.cpp
ashwinma/mpiacc-contention-tests
6246ad9b177095220aa9cea5c85def7effd78222
[ "BSD-3-Clause-Clear", "BSD-3-Clause" ]
23
2015-04-07T20:36:11.000Z
2021-12-12T23:22:30.000Z
spectral-methods/fft/opencl/common/HostStencilFactory.cpp
rusiqe/AssemblyScript-vs-Javascript-bench
75a6590f1952b3c4f2c8c47fbd23ab84d9aa7087
[ "MIT" ]
38
2015-06-06T07:43:35.000Z
2021-07-22T15:39:19.000Z
spectral-methods/fft/opencl/common/HostStencilFactory.cpp
rusiqe/AssemblyScript-vs-Javascript-bench
75a6590f1952b3c4f2c8c47fbd23ab84d9aa7087
[ "MIT" ]
12
2015-04-07T20:35:55.000Z
2020-03-24T09:12:24.000Z
#include <iostream> #include "HostStencilFactory.h" #include "HostStencil.h" template<class T> Stencil<T>* HostStencilFactory<T>::BuildStencil( const OptionParser& options ) { // get options for base class T wCenter; T wCardinal; T wDiagonal; StencilFactory<T>::ExtractOptions( options, wCenter, wCardinal, wDiagonal ); return new HostStencil<T>( wCenter, wCardinal, wDiagonal ); } template<class T> void HostStencilFactory<T>::CheckOptions( const OptionParser& options ) const { // let base class check its options StencilFactory<T>::CheckOptions( options ); // nothing else to do - we add no options }
21.733333
80
0.708589
ashwinma
9c990b6a35fb90d0d0ca93ce6f9a8246afe887b9
739
cpp
C++
InternalLib/src/SDL/SDLDrawResource.cpp
NoixChou/CreamyGameLib
f3268d8f6d468e2cce93efc70206d4d19e8c3716
[ "MIT" ]
null
null
null
InternalLib/src/SDL/SDLDrawResource.cpp
NoixChou/CreamyGameLib
f3268d8f6d468e2cce93efc70206d4d19e8c3716
[ "MIT" ]
2
2021-01-04T23:27:20.000Z
2021-01-04T23:31:46.000Z
InternalLib/src/SDL/SDLDrawResource.cpp
NoixChou/CreamyGameLib
f3268d8f6d468e2cce93efc70206d4d19e8c3716
[ "MIT" ]
null
null
null
#ifdef CREAMY_USE_SDL #include "DrawResource.hpp" #include "Resource/TextureResource.hpp" #include "../../../CreamyGameLib/include/Util/Color.hpp" #include "../../../CreamyGameLib/include/Math/Vector2.hpp" #include "SDL.h" namespace creamyLib::impl { void DrawTexture2D(const LibHandlePointer& libHandle, const resource::TextureResource& texture, const math::Vector2& position, const math::Vector2& scale) { const auto [x, y] = position.toInteger(); const auto [scaleX, scaleY] = scale; SDL_Rect rect{ x, y, static_cast<int>(texture.width * scaleX), static_cast<int>(texture.height * scaleY) }; SDL_RenderCopy(libHandle->sdlRenderer, texture.handle->texture, nullptr, &rect); } } #endif
28.423077
158
0.699594
NoixChou
9c9ba2fd9964c22bd4d15769fd4b0129e50b7777
364
hpp
C++
RIT_Library/src/include/structures/VertexInclude.hpp
PWrGitHub194238/RIT
74ae41ce8cfdca3f14fc1e9a36840c68dff42b23
[ "Apache-2.0" ]
null
null
null
RIT_Library/src/include/structures/VertexInclude.hpp
PWrGitHub194238/RIT
74ae41ce8cfdca3f14fc1e9a36840c68dff42b23
[ "Apache-2.0" ]
1
2016-02-14T18:27:05.000Z
2016-03-15T17:32:11.000Z
BinaryIMST_Library/src/include/structures/VertexInclude.hpp
PWrGitHub194238/BinaryIMST
53490c10580fd4ad61c9234b82b3140c5cce5de0
[ "Apache-2.0" ]
null
null
null
/* * VertexInclude.hpp * * Created on: 6 sty 2016 * Author: tomasz */ #ifndef INCLUDE_STRUCTURES_VERTEXINCLUDE_HPP_ #define INCLUDE_STRUCTURES_VERTEXINCLUDE_HPP_ #define VertexIF_Vertex #include "VertexIF.hpp" #ifdef VertexIF_Vertex #include "Vertex/Vertex.hpp" #endif typedef Vertex VertexImpl; #endif /* INCLUDE_STRUCTURES_VERTEXINCLUDE_HPP_ */
16.545455
50
0.774725
PWrGitHub194238
9c9c53ad6ff50734b89dcadb516fc989934bba43
5,572
cpp
C++
src/frame.cpp
plnegre/stereo_odometry
0abd84d51478c40d101bde959a158c1b81ad620f
[ "BSD-4-Clause" ]
null
null
null
src/frame.cpp
plnegre/stereo_odometry
0abd84d51478c40d101bde959a158c1b81ad620f
[ "BSD-4-Clause" ]
null
null
null
src/frame.cpp
plnegre/stereo_odometry
0abd84d51478c40d101bde959a158c1b81ad620f
[ "BSD-4-Clause" ]
null
null
null
#include "frame.h" namespace odom { Frame::Frame() {} Frame::Frame(Featools* feat, const cv::Mat l_img, const cv::Mat r_img, const uint frame_uid, uint& feat_uid) : featools_(feat) { // Copy l_img.copyTo(l_img_); r_img.copyTo(r_img_); // Extract keypoints vector<cv::KeyPoint> l_kp, r_kp; cv::ORB orb(1500, 1.2, 8, 10, 0, 2, 0, 10); orb(l_img_, cv::noArray(), l_kp, cv::noArray(), false); orb(r_img_, cv::noArray(), r_kp, cv::noArray(), false); // Extract descriptors cv::Mat l_desc, r_desc; cv::Ptr<cv::DescriptorExtractor> cv_extractor; cv_extractor = cv::DescriptorExtractor::create("ORB"); cv_extractor->compute(l_img_, l_kp, l_desc); cv_extractor->compute(r_img_, r_kp, r_desc); if (l_kp.empty() || r_kp.empty()) return; // Undistort featools_->undistortKeyPoints(l_kp, l_ukp_); featools_->undistortKeyPoints(r_kp, r_ukp_); // Left/right matching vector<cv::DMatch> matches, matches_filtered; featools_->ratioMatching(l_desc, r_desc, 0.8, matches); // Filter featools_->stereoMatchingFilter(l_ukp_, r_ukp_, matches, matches_filtered); // Bucketing matches_bucketed_ = bucketFeatures(l_ukp_, r_ukp_, matches_filtered); // Fill the features vector for (uint i=0; i<matches_bucketed_.size(); i++) { cv::KeyPoint l_kp_1 = l_ukp_[matches_bucketed_[i].queryIdx]; cv::KeyPoint r_kp_1 = r_ukp_[matches_bucketed_[i].trainIdx]; cv::Mat l_desc_1 = l_desc.row(matches_bucketed_[i].queryIdx); cv::Mat r_desc_1 = r_desc.row(matches_bucketed_[i].trainIdx); cv::Point3d world_point = computeWorldPoint(l_kp_1, r_kp_1); Feature* f = new Feature(feat_uid, frame_uid, world_point, l_kp_1, r_kp_1, l_desc_1, r_desc_1); features_.push_back(f); feat_uid++; } } cv::Point3d Frame::computeWorldPoint(cv::KeyPoint l_kp, cv::KeyPoint r_kp) { // Camera parameters double baseline = featools_->getBaseline(); cv::Mat camera_matrix = featools_->getCameraMatrix(); ROS_ASSERT(camera_matrix.at<double>(0,0) == camera_matrix.at<double>(1,1)); const double cx = camera_matrix.at<double>(0,2); const double cy = camera_matrix.at<double>(1,2); const double f = camera_matrix.at<double>(0,0); double disparity = l_kp.pt.x - r_kp.pt.x; double wa = (1.0 / baseline) * disparity; double x = (l_kp.pt.x - cx) * (1.0 / wa); double y = (l_kp.pt.y - cy) * (1.0 / wa); double z = f * (1.0 / wa); cv::Point3d p(x, y, z); return p; } vector<cv::DMatch> Frame::bucketFeatures(vector<cv::KeyPoint> l_kp, vector<cv::KeyPoint> r_kp, vector<cv::DMatch> matches) { const int b_width = 40; const int b_height = 30; const int max_feat = 4; // Find max values float x_max = 0; float y_max = 0; for (vector<cv::DMatch>::iterator it = matches.begin(); it!=matches.end(); it++) { if (l_kp[it->queryIdx].pt.x > x_max) x_max = l_kp[it->queryIdx].pt.x; if (l_kp[it->queryIdx].pt.y > y_max) y_max = l_kp[it->queryIdx].pt.y; } // Allocate number of buckets needed int bucket_cols = (int)floor(x_max/b_width) + 1; int bucket_rows = (int)floor(y_max/b_height) + 1; vector<cv::KeyPoint> *buckets = new vector<cv::KeyPoint>[bucket_cols*bucket_rows]; // Assign keypoints to their buckets for (vector<cv::DMatch>::iterator it=matches.begin(); it!=matches.end(); it++) { int u = (int)floor(l_kp[it->queryIdx].pt.x/b_width); int v = (int)floor(l_kp[it->queryIdx].pt.y/b_height); // Trick to sort by response: accumulate the left and right response l_kp[it->queryIdx].response = l_kp[it->queryIdx].response + r_kp[it->trainIdx].response; buckets[v*bucket_cols+u].push_back(l_kp[it->queryIdx]); } // Refill matches from buckets vector<cv::DMatch> output; for (int i=0; i<bucket_cols*bucket_rows; i++) { // Sort descriptors matched by distance sort(buckets[i].begin(), buckets[i].end(), sortByBigResponse); // Add up to max_features features from this bucket to output int k=0; for (vector<cv::KeyPoint>::iterator it=buckets[i].begin(); it!=buckets[i].end(); it++) { // Search this feature into the matches vector cv::DMatch found_match; for (vector<cv::DMatch>::iterator it_m=matches.begin(); it_m!=matches.end(); it_m++) { if (fabs(it->pt.x - l_kp[it_m->queryIdx].pt.x) < 1.0e-3 and fabs(it->pt.y - l_kp[it_m->queryIdx].pt.y) < 1.0e-3) { found_match = *it_m; break; } } output.push_back(found_match); k++; if (k >= max_feat) break; } } return output; } cv::Mat Frame::drawStereoMatches() { cv::Mat img_matches; if (matches_bucketed_.size() == 0) { cv::hconcat(l_img_, r_img_, img_matches); return img_matches; } else { // Draw matches only vector<cv::KeyPoint> l_kp, r_kp; for (uint i=0; i<matches_bucketed_.size(); i++) { l_kp.push_back(l_ukp_[matches_bucketed_[i].queryIdx]); r_kp.push_back(r_ukp_[matches_bucketed_[i].trainIdx]); matches_bucketed_[i].queryIdx = i; matches_bucketed_[i].trainIdx = i; } // Draw cv::drawMatches(l_img_, l_kp, r_img_, r_kp, matches_bucketed_, img_matches); return img_matches; } } } //namespace odom
33.166667
128
0.615578
plnegre
9c9c8091a390244b6b6268248f0c38b0c4a17881
2,024
cpp
C++
src/Programs/Desktop/Desktop.cpp
Kaj9296/Electric_OS
31e1d9318943e50e2bc095dc2ba32d4ce26e7e8b
[ "MIT" ]
7
2022-02-20T16:34:48.000Z
2022-02-26T06:14:51.000Z
src/Programs/Desktop/Desktop.cpp
fantomphreaker/Electric_OS
138c00cb19497ec8592f3c155339fd02beb44259
[ "MIT" ]
null
null
null
src/Programs/Desktop/Desktop.cpp
fantomphreaker/Electric_OS
138c00cb19497ec8592f3c155339fd02beb44259
[ "MIT" ]
4
2022-02-20T16:25:44.000Z
2022-03-20T07:49:25.000Z
#include "Desktop.h" #include "STL/System/System.h" #include "STL/Graphics/Framebuffer.h" #include "STL/String/cstr.h" #include "Programs/Topbar/Topbar.h" namespace Desktop { void(*CurrentAnimation)(STL::Framebuffer*); uint64_t AnimationCounter = 0; inline void StartAnimation(void(*Animation)(STL::Framebuffer*)) { AnimationCounter = 0; CurrentAnimation = Animation; } STL::ARGB BackgroundColor = STL::ARGB(255, 60, 120, 180); void OpenAnimation(STL::Framebuffer* Buffer) { if (AnimationCounter > 60) { STL::System("set drawmouse 1"); STL::System("start topbar"); StartAnimation(nullptr); Buffer->Fill(BackgroundColor); } else { Buffer->Fill((BackgroundColor / (uint8_t)60) * (uint8_t)AnimationCounter); } } STL::PROR Procedure(STL::PROM Message, STL::PROI Input) { switch(Message) { case STL::PROM::INIT: { STL::PINFO* Info = (STL::PINFO*)Input; Info->Type = STL::PROT::FULLSCREEN; Info->Depth = 0; Info->Title = "Desktop"; BackgroundColor = STL::ARGB(255, 60, 120, 180); StartAnimation(OpenAnimation); } break; case STL::PROM::DRAW: { STL::Framebuffer* Buffer = (STL::Framebuffer*)Input; if (CurrentAnimation != nullptr) { CurrentAnimation(Buffer); AnimationCounter++; if (CurrentAnimation == nullptr) { return STL::PROR::DRAW; } } } break; case STL::PROM::TICK: { if (CurrentAnimation != nullptr) { return STL::PROR::DRAW; } } break; default: { } break; } return STL::PROR::SUCCESS; } }
23
86
0.494071
Kaj9296
9c9d14c2c1eba2c6bb803a8cace040f692d9be49
1,704
hpp
C++
common/Dependencies/amy/amy/detail/mysql_option.hpp
avennstrom/NovusCore-Common
f0687f0df75c0651137d11bb14aba6fede918d93
[ "MIT" ]
181
2016-11-07T17:50:25.000Z
2022-02-09T14:09:07.000Z
common/Dependencies/amy/amy/detail/mysql_option.hpp
avennstrom/NovusCore-Common
f0687f0df75c0651137d11bb14aba6fede918d93
[ "MIT" ]
19
2016-11-10T21:36:19.000Z
2021-03-30T23:15:00.000Z
common/Dependencies/amy/amy/detail/mysql_option.hpp
avennstrom/NovusCore-Common
f0687f0df75c0651137d11bb14aba6fede918d93
[ "MIT" ]
43
2016-11-08T04:49:39.000Z
2021-05-18T03:33:15.000Z
#ifndef __AMY_DETAIL_MYSQL_OPTION_HPP__ #define __AMY_DETAIL_MYSQL_OPTION_HPP__ #include <amy/detail/mysql_types.hpp> #include <string> namespace amy { namespace detail { namespace mysql_option { template<int Option, typename Uint = unsigned int> class unsigned_integer { public: unsigned_integer() : value_(0u) {} explicit unsigned_integer(unsigned int value) : value_(value) {} int option() const { return Option; } char const* data() const { return reinterpret_cast<char const*>(&value_); } private: Uint value_; }; // class unsigned_integer template<int Option> class char_sequence { public: char_sequence() : value_() {} explicit char_sequence(std::string const& value) : value_(value) {} int option() const { return Option; } char const* data() const { return value_.c_str(); } private: std::string value_; }; // class char_sequence template<int Option> class boolean { public: boolean() : value_(false) {} explicit boolean(bool value) : value_(value ? 1 : 0) {} int option() const { return Option; } char const* data() const { return reinterpret_cast<char const*>(&value_); } private: detail::my_bool value_; }; // class boolean template<int Option> class switcher { public: switcher() { } int option() const { return Option; } char* data() const { return 0; } }; // class switcher } // namespace mysql_option } // namespace detail } // namespace amy #endif // __AMY_DETAIL_MYSQL_OPTION_HPP__ // vim:ft=cpp sw=4 ts=4 tw=80 et
16.075472
54
0.618545
avennstrom
9c9f9340db44ea8e933d2f11446f93fdbc5857a0
704,933
cpp
C++
test/bidi_character_test_039.cpp
eightysquirrels/text
d935545648777786dc196a75346cde8906da846a
[ "BSL-1.0" ]
null
null
null
test/bidi_character_test_039.cpp
eightysquirrels/text
d935545648777786dc196a75346cde8906da846a
[ "BSL-1.0" ]
1
2021-03-05T12:56:59.000Z
2021-03-05T13:11:53.000Z
test/bidi_character_test_039.cpp
eightysquirrels/text
d935545648777786dc196a75346cde8906da846a
[ "BSL-1.0" ]
3
2019-10-30T18:38:15.000Z
2021-03-05T12:10:13.000Z
// Warning! This file is autogenerated. #include <boost/text/bidirectional.hpp> #include "bidi_tests.hpp" #include <gtest/gtest.h> #include <algorithm> TEST(bidi_character, bidi_character_039_000) { { // line 27301 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27302 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27303 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27304 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27305 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27306 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27307 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27308 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27309 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27310 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_001) { { // line 27311 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27312 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27313 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27314 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27315 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27316 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27317 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27318 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27319 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27320 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_002) { { // line 27321 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27322 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27323 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27326 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27327 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 2, 3, 4, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27328 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27329 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27330 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27331 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27332 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_003) { { // line 27333 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27334 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27335 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27336 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27337 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27338 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27339 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 2, 3, 4, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27340 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27341 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27342 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_004) { { // line 27343 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27344 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27345 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27346 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27347 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27348 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27349 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27350 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27351 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27352 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_005) { { // line 27353 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27354 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27355 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27356 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27357 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27360 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27361 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27362 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27363 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27364 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_006) { { // line 27365 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27366 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27367 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x0061, 0x005B, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27368 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27369 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27370 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27371 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27372 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27373 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0061, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27374 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_007) { { // line 27375 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27376 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27377 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x0061, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27378 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27379 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x05D1, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27380 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27381 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27382 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27383 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27384 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_008) { { // line 27385 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x0061, 0x005B, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27386 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27387 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27388 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27389 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27390 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27391 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27392 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27393 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27394 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_009) { { // line 27395 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27396 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27397 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27398 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27399 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27400 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27401 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27402 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27403 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27404 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_010) { { // line 27405 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27406 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27407 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27408 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27409 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27412 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 4, 3, 2, 1, 0, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27413 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x2680, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27414 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 4, 3, 2, 1, 0, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27415 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27416 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_011) { { // line 27417 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27418 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27419 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27420 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 4, 3, 2, 1, 0, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27421 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27422 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27423 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27424 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27425 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27426 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_012) { { // line 27427 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27428 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27429 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27430 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 1, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 3, 2, 1, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27431 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x2680, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27432 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 1, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 3, 2, 1, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27433 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27434 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 0, 1, 1, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 3, 2, 1, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27435 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27436 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_013) { { // line 27437 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27438 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27439 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27440 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27441 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x2680, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27442 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27443 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x2680 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27446 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27447 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x0061, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27448 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_014) { { // line 27449 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27450 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27451 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27452 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27453 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27454 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27455 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27456 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27457 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27458 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_015) { { // line 27459 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27460 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27461 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27462 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 3, 2, 1, 0, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27463 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27464 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 1, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 3, 2, 1, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27465 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27466 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 1, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 3, 2, 1, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27467 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27468 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 1, 1, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 3, 2, 1, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_016) { { // line 27469 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27470 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27471 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27472 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27473 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27474 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27475 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27476 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27477 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27480 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 4, 3, 2, 1, 0, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_017) { { // line 27481 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x05D2, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27482 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 4, 3, 2, 1, 0, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27483 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x05D2, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27484 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27485 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x05D1, 0x005B, 0x0029, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27486 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 4, 3, 2, 1, 0, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27487 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27488 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27489 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x05D1, 0x0029, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27490 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_018) { { // line 27491 std::vector<uint32_t> const cps = { 0x05D0, 0x0028, 0x005B, 0x0029, 0x05D1, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27492 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D }; std::vector<int> const expected_levels = { 0, 1, 1, 1, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 3, 2, 1, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27493 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x05D2, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27494 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 0, 1, 1, 1, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 3, 2, 1, 4, 5, 6 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27495 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27496 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 0, 1, 0, 0, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27497 std::vector<uint32_t> const cps = { 0x0028, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27498 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 0, 0, 1, 0, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 6, 5, 4 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27499 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D, 0x05D2 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27502 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x2683, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_019) { { // line 27503 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x2683, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27504 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D, 0x2683 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27505 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D, 0x2683 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27506 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D, 0x2683 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27507 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D, 0x2683 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27508 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x2683 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27509 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x2683 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27510 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x2683 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27511 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x2683 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27514 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_020) { { // line 27515 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27516 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27517 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27518 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27519 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27520 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27521 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27522 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27523 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27524 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_021) { { // line 27525 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27526 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27527 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27528 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27529 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27530 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27531 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27532 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27533 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27534 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_022) { { // line 27535 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27536 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27537 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27538 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27539 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27540 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27541 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27542 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27543 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x005D, 0x2682, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27546 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_023) { { // line 27547 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27548 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27549 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27550 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27551 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27552 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27553 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27554 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27555 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27556 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_024) { { // line 27557 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27558 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27559 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27560 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27561 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27562 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27563 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27564 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27565 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27566 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_025) { { // line 27567 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27568 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27569 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27570 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27571 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27572 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27573 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27574 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27575 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x005D, 0x2682, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27578 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x2682, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_026) { { // line 27579 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x2682, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27580 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27581 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27582 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27583 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27584 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27585 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27586 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27587 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27588 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_027) { { // line 27589 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27590 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27591 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27592 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27593 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27594 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27595 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27596 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27597 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27598 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_028) { { // line 27599 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27600 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27601 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27602 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27603 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27604 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27605 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27606 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27607 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27608 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_029) { { // line 27609 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27610 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27611 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27612 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27613 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27614 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27615 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27616 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27617 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27618 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_030) { { // line 27619 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27620 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27621 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27622 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27623 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27624 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27625 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27626 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27627 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27630 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_031) { { // line 27631 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 3, 4, 5, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27632 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27633 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27634 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27635 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27636 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27637 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27638 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27639 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27640 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_032) { { // line 27641 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 6, 7, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27642 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27643 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27644 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27645 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27646 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27647 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 6, 7, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27648 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27649 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 6, 7, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27650 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_033) { { // line 27651 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27652 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27653 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27654 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27655 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 6, 7, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27656 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27657 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 6, 7, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27658 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27659 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 5, 6, 7, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27662 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x05D0, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_034) { { // line 27663 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x05D0, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27664 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27665 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27666 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27667 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27668 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27669 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x0061, 0x005B, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27670 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27671 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27672 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_035) { { // line 27673 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27674 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27675 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0061, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27676 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27677 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27678 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27679 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27680 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27681 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27682 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_036) { { // line 27683 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27684 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27685 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27686 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27687 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27688 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27689 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27690 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27691 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27692 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_037) { { // line 27693 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27694 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27695 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x05D0, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27696 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27697 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27698 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27699 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0061, 0x0029, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27700 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27701 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27702 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_038) { { // line 27703 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27704 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27705 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27706 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27707 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27708 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27709 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x05D0, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27710 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27711 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x0061, 0x005D, 0x05D0 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27714 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x2682, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_039) { { // line 27715 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x2682, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27716 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27717 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27718 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27719 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27720 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27721 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27722 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27723 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27724 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_040) { { // line 27725 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27726 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27727 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27728 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27729 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27730 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27731 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27732 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27733 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27734 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_041) { { // line 27735 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27736 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27737 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27738 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27739 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27740 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27741 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27742 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27743 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27744 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_042) { { // line 27745 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27746 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27747 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27748 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27749 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27750 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27751 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27752 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27753 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27754 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_043) { { // line 27755 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27756 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27757 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27758 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27759 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27760 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27761 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27762 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27763 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27766 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x0061, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_044) { { // line 27767 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x0061, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27768 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27769 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27770 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27771 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27772 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27773 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27774 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27775 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27776 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_045) { { // line 27777 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27778 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27779 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27780 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27781 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27782 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27783 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27784 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27785 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27786 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_046) { { // line 27787 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27788 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27789 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27790 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27791 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27792 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27793 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27794 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27795 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27796 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_047) { { // line 27797 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27798 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27799 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0061, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27800 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27801 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27802 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27803 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27804 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27805 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27806 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_048) { { // line 27807 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27808 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27809 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27810 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27811 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27812 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27813 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x0061, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27814 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27815 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005D, 0x0061 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27818 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 1, 1, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 5, 4, 3, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_049) { { // line 27819 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x05D1, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27820 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27821 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27822 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 1, 0, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27823 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x05D0, 0x005B, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27824 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27825 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27826 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27827 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x05D0, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27828 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 7, 6, 5 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_050) { { // line 27829 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x2681, 0x005B, 0x0029, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27830 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27831 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27832 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27833 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27834 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 7, 6, 5 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27835 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27836 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 7, 6, 5 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27837 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27838 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 1, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_051) { { // line 27839 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x05D1, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27840 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 1, 0, 0, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27841 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x05D0, 0x0029, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27842 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 7, 6, 5 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27843 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x2681, 0x0029, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27844 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 7, 6, 5 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27845 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27846 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 7, 6, 5 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27847 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x2681, 0x05D0, 0x005D, 0x05D1 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27850 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_052) { { // line 27851 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27852 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27853 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27854 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27855 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27856 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27857 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27858 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27859 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27860 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_053) { { // line 27861 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27862 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27863 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27864 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27865 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27866 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27867 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27868 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27869 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27870 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_054) { { // line 27871 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x2682, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27872 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27873 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27874 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27875 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27876 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27877 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27878 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27879 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27880 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_055) { { // line 27881 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27882 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27883 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27884 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27885 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27886 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27887 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27888 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27889 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27890 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_056) { { // line 27891 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0029, 0x2682, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27892 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27893 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0029, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27894 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27895 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27896 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27897 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27898 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x2680, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27899 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x2680, 0x0061, 0x2681, 0x005D, 0x2682 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27902 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0062, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_057) { { // line 27903 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x0062, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 2, 3, 4, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27904 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27905 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 2, 3, 4, 5, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27906 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27907 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27908 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27909 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x2681, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27910 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27911 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 2, 3, 4, 5, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27912 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_058) { { // line 27913 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27914 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27915 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27916 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27917 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27918 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27919 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27920 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27921 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x0061, 0x005B, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27922 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_059) { { // line 27923 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 3, 4, 5, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27924 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27925 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27926 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27927 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27928 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27929 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27930 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27931 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27932 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_060) { { // line 27933 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0061, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27934 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27935 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27936 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27937 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27938 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27939 std::vector<uint32_t> const cps = { 0x2680, 0x0028, 0x005B, 0x0029, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27940 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0062, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27941 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x0062, 0x005B, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 1, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 2, 3, 4, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27942 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_061) { { // line 27943 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 2, 3, 4, 5, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27944 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27945 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27946 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27947 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x2681, 0x005B, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27948 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27949 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 2, 3, 4, 5, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27950 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27951 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27952 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_062) { { // line 27953 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27954 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27955 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27956 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27957 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27958 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27959 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x0061, 0x005B, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 2, 1, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27960 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27961 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 3, 4, 5, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27962 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_063) { { // line 27963 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27964 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27965 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27966 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27967 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27968 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27969 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27970 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27971 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0061, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27972 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_064) { { // line 27973 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27974 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27975 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27976 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27977 std::vector<uint32_t> const cps = { 0x0028, 0x2680, 0x005B, 0x0029, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27978 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27979 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0062, 0x0029, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 2, 2, 1, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 3, 4, 5, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27980 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27981 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0029, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27982 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_065) { { // line 27983 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x2681, 0x0029, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27984 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27985 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27986 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27987 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27988 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27989 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0061, 0x0029, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 2, 1, 1, 1, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 6, 5, 4, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27990 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27991 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27992 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } } TEST(bidi_character, bidi_character_039_066) { { // line 27993 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27994 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27995 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x2680, 0x0029, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27996 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x2680, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27997 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x2680, 0x0061, 0x2681, 0x0062, 0x005D }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 1 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 7, 4, 5, 6, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27998 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x2680, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 27999 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x2680, 0x0061, 0x2681, 0x005D, 0x0062 }; std::vector<int> const expected_levels = { 1, 1, 1, 1, 2, 2, 2, 2 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 1); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 4, 5, 6, 7, 3, 2, 1, 0 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 1); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } { // line 28000 std::vector<uint32_t> const cps = { 0x0028, 0x005B, 0x0029, 0x2680, 0x0061, 0x005D, 0x2681, 0x0062 }; std::vector<int> const expected_levels = { 0, 0, 0, 0, 0, 0, 0, 0 }; std::vector<int> const levels = bidi_levels(cps.begin(), cps.end(), 0); int i = 0; for (int l : expected_levels) { if (0 <= l) { EXPECT_EQ(levels[i], l) << "i=" << i; ++i; } } EXPECT_EQ((int)levels.size(), i); std::vector<uint32_t> const expected_reordered_indices = { 0, 1, 2, 3, 4, 5, 6, 7 }; std::vector<int> const reordered = bidi_reordered_indices(cps.begin(), cps.end(), 0); i = 0; for (int idx : expected_reordered_indices) { EXPECT_EQ(reordered[i], cps[idx]) << std::hex << " 0x" << reordered[i] << " 0x" << cps[idx] << std::dec << " i=" << i; ++i; } } }
33.589031
109
0.438669
eightysquirrels
9c9fa0f655c1a187506993368188743c6d312596
4,601
cpp
C++
Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp
samsmu/MITK
c93dce6dc38d8f4c961de4440e4dd113b9841c8c
[ "BSD-3-Clause" ]
5
2015-02-05T10:58:41.000Z
2019-04-17T15:04:07.000Z
Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp
kometa-dev/MITK
984b5f7ac8ea614e80f303381ef1fc77d8ca4c3d
[ "BSD-3-Clause" ]
141
2015-03-03T06:52:01.000Z
2020-12-10T07:28:14.000Z
Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp
kometa-dev/MITK
984b5f7ac8ea614e80f303381ef1fc77d8ca4c3d
[ "BSD-3-Clause" ]
4
2015-02-19T06:48:13.000Z
2020-06-19T16:20:25.000Z
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkCreatePolygonModelAction.h" // MITK #include <mitkShowSegmentationAsSmoothedSurface.h> #include <mitkShowSegmentationAsSurface.h> #include <mitkProgressBar.h> #include <mitkStatusBar.h> #include <QmitkStdMultiWidget.h> #include <mitkIRenderWindowPart.h> #include <mitkIRenderingManager.h> // Blueberry #include <berryIPreferencesService.h> #include <berryIPreferences.h> #include <berryPlatform.h> #include <berryIWorkbenchPage.h> using namespace berry; using namespace mitk; using namespace std; QmitkCreatePolygonModelAction::QmitkCreatePolygonModelAction() { } QmitkCreatePolygonModelAction::~QmitkCreatePolygonModelAction() { } void QmitkCreatePolygonModelAction::Run(const QList<DataNode::Pointer> &selectedNodes) { DataNode::Pointer selectedNode = selectedNodes[0]; Image::Pointer image = dynamic_cast<mitk::Image *>(selectedNode->GetData()); if (image.IsNull()) { return; } try { // Get preference properties for smoothing and decimation IPreferencesService* prefService = Platform::GetPreferencesService(); IPreferences::Pointer segPref = prefService->GetSystemPreferences()->Node("/org.mitk.views.segmentation"); bool smoothingHint = segPref->GetBool("smoothing hint", true); ScalarType smoothing = segPref->GetDouble("smoothing value", 1.0); ScalarType decimation = segPref->GetDouble("decimation rate", 0.2); if (smoothingHint) { smoothing = 0.0; Vector3D spacing = image->GetGeometry()->GetSpacing(); for (Vector3D::Iterator iter = spacing.Begin(); iter != spacing.End(); ++iter) smoothing = max(smoothing, *iter); } ShowSegmentationAsSurface::Pointer surfaceFilter = ShowSegmentationAsSurface::New(); // Activate callback functions itk::SimpleMemberCommand<QmitkCreatePolygonModelAction>::Pointer successCommand = itk::SimpleMemberCommand<QmitkCreatePolygonModelAction>::New(); successCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); surfaceFilter->AddObserver(ResultAvailable(), successCommand); itk::SimpleMemberCommand<QmitkCreatePolygonModelAction>::Pointer errorCommand = itk::SimpleMemberCommand<QmitkCreatePolygonModelAction>::New(); errorCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); surfaceFilter->AddObserver(ProcessingError(), errorCommand); // set filter parameter surfaceFilter->SetDataStorage(*m_DataStorage); surfaceFilter->SetPointerParameter("Input", image); surfaceFilter->SetPointerParameter("Group node", selectedNode); surfaceFilter->SetParameter("Show result", true); surfaceFilter->SetParameter("Sync visibility", false); surfaceFilter->SetParameter("Median kernel size", 3u); surfaceFilter->SetParameter("Decimate mesh", m_IsDecimated); surfaceFilter->SetParameter("Decimation rate", (float) decimation); if (m_IsSmoothed) { surfaceFilter->SetParameter("Apply median", true); surfaceFilter->SetParameter("Smooth", true); surfaceFilter->SetParameter("Gaussian SD", sqrtf(smoothing)); // use sqrt to account for setting of variance in preferences StatusBar::GetInstance()->DisplayText("Smoothed surface creation started in background..."); } else { surfaceFilter->SetParameter("Apply median", false); surfaceFilter->SetParameter("Smooth", false); StatusBar::GetInstance()->DisplayText("Surface creation started in background..."); } surfaceFilter->StartAlgorithm(); } catch(...) { MITK_ERROR << "Surface creation failed!"; } } void QmitkCreatePolygonModelAction::OnSurfaceCalculationDone() { StatusBar::GetInstance()->Clear(); } void QmitkCreatePolygonModelAction::SetDataStorage(DataStorage *dataStorage) { m_DataStorage = dataStorage; } void QmitkCreatePolygonModelAction::SetSmoothed(bool smoothed) { m_IsSmoothed = smoothed; } void QmitkCreatePolygonModelAction::SetDecimated(bool decimated) { m_IsDecimated = decimated; } void QmitkCreatePolygonModelAction::SetFunctionality(QtViewPart *) { }
32.631206
149
0.73484
samsmu
9ca6da7d7d2d0c677621b7e1a81c8aa64ee2964c
574
cpp
C++
C++/Data_Structures/Symmetric_Trees.cpp
snehnakrani14/HactoberFest21
1d387ff4efec1f17fe20d42f46490564c5a87b52
[ "Unlicense" ]
1
2021-10-04T14:39:02.000Z
2021-10-04T14:39:02.000Z
C++/Data_Structures/Symmetric_Trees.cpp
snehnakrani14/HactoberFest21
1d387ff4efec1f17fe20d42f46490564c5a87b52
[ "Unlicense" ]
1
2021-10-06T04:41:55.000Z
2021-10-06T04:41:55.000Z
C++/Data_Structures/Symmetric_Trees.cpp
snehnakrani14/HactoberFest21
1d387ff4efec1f17fe20d42f46490564c5a87b52
[ "Unlicense" ]
1
2021-10-08T12:31:04.000Z
2021-10-08T12:31:04.000Z
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ int isSymmetricTree(TreeNode* A,TreeNode* B){ if(A==NULL&&B==NULL) return 1; else if(A==NULL||B==NULL) return 0; //if(A!=B) return false; if(A->val==B->val){ if(isSymmetricTree(A->right,B->left)&&isSymmetricTree(A->left,B->right)) return true; return false; } return false; } int Solution::isSymmetric(TreeNode* A) { return isSymmetricTree(A,A); }
24.956522
89
0.599303
snehnakrani14
9ca8729f481431f59417e1ac121701f539db34c5
170
cpp
C++
Data Types/sizeofoperator2.cpp
dealbisac/cprograms
89af58a30295099b45406cf192f4c4eb4a06f9fe
[ "Unlicense" ]
4
2019-01-27T01:00:44.000Z
2019-01-29T02:09:55.000Z
Data Types/sizeofoperator2.cpp
dealbisac/cprograms
89af58a30295099b45406cf192f4c4eb4a06f9fe
[ "Unlicense" ]
null
null
null
Data Types/sizeofoperator2.cpp
dealbisac/cprograms
89af58a30295099b45406cf192f4c4eb4a06f9fe
[ "Unlicense" ]
1
2019-02-04T11:34:40.000Z
2019-02-04T11:34:40.000Z
//Example of sizeof() operator in expression #include<stdio.h> int main() { int a = 0; double d = 10.21; printf("%d", sizeof(a+d)); return 0; }
15.454545
44
0.547059
dealbisac
66d72e0eb1c645d0218163722ccf58099ecbaa4d
65,719
cc
C++
gui/minimap.cc
lindleyw/simutrans-extended
d7d1230ca431e5c12fc9daa26c0629b6dc2c0fba
[ "Artistic-1.0" ]
null
null
null
gui/minimap.cc
lindleyw/simutrans-extended
d7d1230ca431e5c12fc9daa26c0629b6dc2c0fba
[ "Artistic-1.0" ]
null
null
null
gui/minimap.cc
lindleyw/simutrans-extended
d7d1230ca431e5c12fc9daa26c0629b6dc2c0fba
[ "Artistic-1.0" ]
null
null
null
/* * This file is part of the Simutrans-Extended project under the Artistic License. * (see LICENSE.txt) */ #include "../simevent.h" #include "../simcolor.h" #include "../simconvoi.h" #include "../vehicle/vehicle.h" #include "../simdepot.h" #include "../simhalt.h" #include "../simfab.h" #include "../simcity.h" #include "fabrik_info.h" #include "simwin.h" #include "minimap.h" #include "schedule_gui.h" #include "../dataobj/translator.h" #include "../dataobj/schedule.h" #include "../dataobj/powernet.h" #include "../boden/wege/schiene.h" #include "../obj/leitung2.h" #include "../obj/gebaeude.h" #include "../display/viewport.h" #include "../utils/simrandom.h" #include "../player/simplay.h" #include "../tpl/inthashtable_tpl.h" #include <cmath> sint32 minimap_t::max_cargo=0; sint32 minimap_t::max_passed=0; static sint32 max_waiting_change = 1; static sint32 max_tourist_ziele = 1; static sint32 max_waiting = 1; static sint32 max_origin = 1; static sint32 max_transfer = 1; static sint32 max_service = 1; static sint32 max_building_level = 0; minimap_t * minimap_t::single_instance = nullptr; karte_ptr_t minimap_t::world; #define MAX_MAP_TYPE_LAND 31 #define MAX_MAP_TYPE_WATER 5 // color for the land static const uint8 map_type_color[MAX_MAP_TYPE_WATER+MAX_MAP_TYPE_LAND] = { // water level 97, 99, 19, 21, 23, // terrain level 160, 161, 162, 163, 164, 165, 166, 167, 205, 206, 207, 172, 174, 159, COL_LIGHT_ORANGE, 157, 156, 154, 115, 114, 113, 112, 216, 217, 218, 219, 220, COL_LILAC, 222, 223, 224 }; const uint8 minimap_t::severity_color[MAX_SEVERITY_COLORS] = { //106, 2, 85, 86, 29, 30, 171, 71, 39, 132 // Original rainbow //COL_DARK_PURPLE, 2, 85, 86, 171, 30, 29, 71, 39, 132 // Improved rainbow COL_DARK_GREEN, 138, COL_LIGHT_GREEN, COL_LIGHT_YELLOW, COL_YELLOW, 30, COL_LIGHT_ORANGE, COL_ORANGE, COL_ORANGE_RED, COL_RED // Green/yellow/orange/red }; /* minimap_t::line_segment_t::line_segment_t(koord s, uint8 so, koord e, uint8 eo, schedule_t* sched, player_t* p, uint8 cc, bool diagonal) { schedule = sched; waytype = sched->get_waytype(); player = p; colorcount = cc; start_diagonal = diagonal; if( s.x<e.x || (s.x==e.x && s.y<e.y) ) { start = s; end = e; start_offset = so; end_offset = eo; } else { start = e; end = s; start_offset = eo; end_offset = so; } } */ // helper function for line segment_t bool minimap_t::line_segment_t::operator==(const line_segment_t & other) const { return start == other.start && end == other.end && player == other.player && schedule->similar( other.schedule, player ); } // Ordering based on first start then end coordinate bool minimap_t::LineSegmentOrdering::operator()(const minimap_t::line_segment_t& a, const minimap_t::line_segment_t& b) const { if( a.start.x == b.start.x ) { // same start ... return a.end.x < b.end.x; } return a.start.x < b.start.x; } static uint8 colore_idx = 0; static inthashtable_tpl< int, slist_tpl<schedule_t *>, N_BAGS_LARGE> waypoint_hash; // add the schedule to the map (if there is a valid one) void minimap_t::add_to_schedule_cache( convoihandle_t cnv, bool with_waypoints ) { // make sure this is valid! if( !cnv.is_bound() ) { return; } schedule_t *schedule = cnv->get_schedule(); if( !show_network_load_factor ) { colore_idx += 8; if( colore_idx >= 208 ) { colore_idx = (colore_idx % 8) + 1; if( colore_idx == 7 ) { colore_idx = 0; } } } else { //TODO: extract common part from with schedule_list_gui_t::display() int capacity = 0, load = 0; // total capacity and load of line (=sum of all conv's cap/load) if(cnv->get_line().is_bound()) { for( uint i = 0; i < cnv->get_line()->count_convoys(); i++ ) { convoihandle_t const cnv_in_line = cnv->get_line()->get_convoy(i); // we do not want to count the capacity of depot convois if( !cnv_in_line->in_depot() ) { for( unsigned j = 0; j < cnv_in_line->get_vehicle_count(); j++ ) { capacity += cnv_in_line->get_vehicle(j)->get_cargo_max(); load += cnv_in_line->get_vehicle(j)->get_total_cargo(); } } } } else { // we do not want to count the capacity of depot convois if(!cnv->in_depot()) { for(unsigned j = 0; j < cnv->get_vehicle_count(); j++) { capacity += cnv->get_vehicle(j)->get_cargo_max(); load += cnv->get_vehicle(j)->get_total_cargo(); } } } // we check if cap is zero, since theoretically a // conv can consist of only 1 vehicle, which has no cap (eg. locomotive) // and we do not like to divide by zero, do we? if(capacity > 0) { const uint32 load_idx = clamp(load * MAX_SEVERITY_COLORS / capacity, 0, MAX_SEVERITY_COLORS-1); colore_idx = severity_color[MAX_SEVERITY_COLORS-1 - load_idx]; } else { colore_idx = severity_color[MAX_SEVERITY_COLORS-1]; } } // ok, add this schedule to map // from here on we have a valid convoi int stops = 0; uint8 old_offset = 0, first_offset = 0, temp_offset = 0; koord old_stop, first_stop, temp_stop; bool last_diagonal = false; const bool add_schedule = schedule->get_waytype() != air_wt; FOR( minivec_tpl<schedule_entry_t>, cur, schedule->entries ) { //cycle on stops //try to read station's coordinates if there's a station at this schedule stop halthandle_t station = haltestelle_t::get_halt( cur.pos, cnv->get_owner() ); if( station.is_bound() ) { stop_cache.append_unique( station ); temp_stop = station->get_basis_pos(); stops ++; } else if( with_waypoints ) { temp_stop = cur.pos.get_2d(); stops ++; } else { continue; } const int key = temp_stop.x + temp_stop.y*world->get_size().x; waypoint_hash.put( key ); // now get the offset slist_tpl<schedule_t *>*pt_list = waypoint_hash.access(key); if( add_schedule ) { // init key if( !pt_list->is_contained( schedule ) ) { // not known => append temp_offset = pt_list->get_count(); } else { // how many times we reached here? temp_offset = pt_list->index_of( schedule ); } } else { temp_offset = 0; } if( stops>1 ) { last_diagonal ^= true; if( (temp_stop.x-old_stop.x)*(temp_stop.y-old_stop.y) == 0 ) { last_diagonal = false; } if( !schedule_cache.insert_unique_ordered( line_segment_t( temp_stop, temp_offset, old_stop, old_offset, schedule, cnv->get_owner(), colore_idx, last_diagonal ), LineSegmentOrdering() ) && add_schedule ) { // append if added and not yet there if( !pt_list->is_contained( schedule ) ) { pt_list->append( schedule ); } if( stops == 2 ) { // append first stop too, when this is called for the first time const int key = first_stop.x + first_stop.y*world->get_size().x; waypoint_hash.put( key ); slist_tpl<schedule_t *>*pt_list = waypoint_hash.access(key); if( !pt_list->is_contained( schedule ) ) { pt_list->append( schedule ); } } } old_stop = temp_stop; old_offset = temp_offset; } else { first_stop = temp_stop; first_offset = temp_offset; old_stop = temp_stop; old_offset = temp_offset; } } if( stops > 2 && !schedule->is_mirrored() ) { // connect to start last_diagonal ^= true; schedule_cache.insert_unique_ordered( line_segment_t( first_stop, first_offset, old_stop, old_offset, schedule, cnv->get_owner(), colore_idx, last_diagonal ), LineSegmentOrdering() ); } } // some routines for the minimap with schedules static uint32 number_to_radius( uint32 n ) { return log2( n>>5u ); } static void display_airport( const scr_coord_val xx, const scr_coord_val yy, const FLAGGED_PIXVAL color ) { int x = xx + 5; int y = yy - 11; if ( y < 0 ) { y = 0; } const char symbol[] = { 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '.', '.', '.', '.', 'X', '.', '.', '.', '.', 'X', 'X', '.', '.', '.', '.', 'X', '.', '.', '.', '.', 'X', 'X', '.', '.', '.', '.', 'X', '.', '.', '.', '.', 'X', 'X', '.', '.', '.', 'X', 'X', 'X', '.', '.', '.', 'X', 'X', '.', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '.', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '.', '.', '.', 'X', '.', '.', '.', 'X', 'X', 'X', '.', '.', '.', '.', 'X', '.', '.', '.', '.', 'X', 'X', '.', '.', '.', 'X', 'X', 'X', '.', '.', '.', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' }; for ( int i = 0; i < 11; i++ ) { for ( int j = 0; j < 11; j++ ) { if ( symbol[i + j * 11] == 'X' ) { display_vline_wh_clip_rgb( x + i, y + j, 1, color, true ); } } } } static void display_harbor( const scr_coord_val xx, const scr_coord_val yy, const FLAGGED_PIXVAL color ) { int x = xx + 5; int y = yy - 11 + 13; //to not overwrite airline symbol if ( y < 0 ) { y = 0; } const char symbol[] = { 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '.', '.', '.', 'X', 'X', 'X', '.', '.', '.', 'X', 'X', '.', '.', '.', '.', 'X', '.', '.', '.', '.', 'X', 'X', '.', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '.', 'X', 'X', '.', '.', '.', 'X', 'X', 'X', '.', '.', '.', 'X', 'X', '.', '.', '.', '.', 'X', '.', '.', '.', '.', 'X', 'X', 'X', 'X', '.', '.', 'X', '.', '.', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '.', 'X', '.', 'X', 'X', 'X', 'X', 'X', '.', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '.', 'X', 'X', '.', '.', 'X', 'X', 'X', 'X', 'X', '.', '.', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' }; for ( int i = 0; i < 11; i++ ) { for ( int j = 0; j < 11; j++ ) { if ( symbol[i + j * 11] == 'X' ) { display_vline_wh_clip_rgb( x + i, y + j, 1, color, true ); } } } } // those will be replaced by pak images later ...! static void display_thick_line( scr_coord_val x1, scr_coord_val y1, scr_coord_val x2, scr_coord_val y2, PIXVAL col, bool dotting, short dot_full, short dot_empty, short thickness ) { scr_coord_val delta_x = abs( x1 - x2 ); scr_coord_val delta_y = abs( y1 - y2 ); if( delta_x == 0 || delta_y/delta_x > 2.0 ) { // mostly vertical x1 -= thickness/2; x2 -= thickness/2; for( int i = 0; i < thickness; i++ ) { if ( !dotting ) { display_direct_line_rgb( x1 + i, y1, x2 + i, y2, col ); } else { display_direct_line_dotted_rgb( x1 + i, y1, x2 + i, y2, dot_full, dot_empty, col ); } } } else if( delta_y == 0.0 || delta_x/delta_y > 2.0 ) { // mostly horizontal y1 -= thickness/2; y2 -= thickness/2; for( int i = 0; i < thickness; i++ ) { if ( !dotting ) { display_direct_line_rgb( x1, y1 + i, x2, y2 + i, col ); } else { display_direct_line_dotted_rgb( x1, y1 + i, x2, y2 + i, dot_full, dot_empty, col ); } } } else { // diagonal int y_multiplier = (x1-x2)/(y1-y2) < 0 ? +1 : -1; thickness = (thickness*7)/8; x1 -= thickness/2; x2 -= thickness/2; y1 -= thickness*y_multiplier/2; y2 -= thickness*y_multiplier/2; for( int i = 0; i < thickness; i++ ) { if ( !dotting ) { display_direct_line_rgb( x1+i, y1+i*y_multiplier, x2+i, y2+i*y_multiplier, col ); display_direct_line_rgb( x1+i+1, y1+i*y_multiplier, x2+i+1, y2+i*y_multiplier, col ); } else { display_direct_line_dotted_rgb( x1 + i, y1 + i*y_multiplier, x2 + i, y2 + i*y_multiplier, dot_full, dot_empty, col ); display_direct_line_dotted_rgb( x1 + i + 1, y1 + i*y_multiplier, x2 + i + 1, y2 + i*y_multiplier, dot_full, dot_empty, col ); } } } } static void line_segment_draw( waytype_t type, scr_coord start, uint8 start_offset, scr_coord end, uint8 end_offset, bool diagonal, PIXVAL colore ) { // airplanes are different, so we must check for them first if( type == air_wt ) { // ignore offset for airplanes draw_bezier_rgb( start.x, start.y, end.x, end.y, 50, 50, 50, 50, colore, 5, 5 ); draw_bezier_rgb( start.x + 1, start.y + 1, end.x + 1, end.y + 1, 50, 50, 50, 50, colore, 5, 5 ); } else { // add offsets start.x += start_offset*3; end.x += end_offset*3; start.y += start_offset*3; end.y += end_offset*3; // due to isometric drawing, order may be swapped if( start.x > end.x ) { // but we need start.x <= end.x! scr_coord temp = start; start = end; end = temp; uint8 temp_offset = start_offset; start_offset = end_offset; end_offset = temp_offset; diagonal ^= 1; } // now determine line style uint8 thickness = 3; bool dotted = false; switch( type ) { case monorail_wt: case maglev_wt: thickness = 5; break; case track_wt: thickness = 4; break; case road_wt: thickness = 2; break; case tram_wt: case narrowgauge_wt: thickness = 3; break; default: thickness = 3; dotted = true; } // start.x is always <= end.x ... const int delta_y = end.y-start.y; if( (start.x-end.x)*delta_y == 0 ) { // horizontal/vertical line display_thick_line( start.x, start.y, end.x, end.y, colore, dotted, 5, 3, thickness ); } else { // two segment scr_coord mid; int signum_y = delta_y/abs(delta_y); // diagonal line to right bottom if( delta_y > 0 ) { if( end_offset && !diagonal ) { // start with diagonal to avoid parallel lines diagonal = true; } if( start_offset && diagonal ) { // end with diagonal to avoid parallel lines diagonal = false; } } // now draw a two segment line if( diagonal ) { // start with diagonal if( abs(delta_y) > end.x-start.x ) { mid.x = end.x; mid.y = start.y + (end.x-start.x)*signum_y; } else { mid.x = start.x + abs(delta_y); mid.y = end.y; } display_thick_line( start.x, start.y, mid.x, mid.y, colore, dotted, 5, 3, thickness ); display_thick_line( mid.x, mid.y, end.x, end.y, colore, dotted, 5, 3, thickness ); } else { // end with diagonal const int delta_y = end.y-start.y; if( abs(delta_y) > end.x-start.x ) { mid.x = start.x; mid.y = end.y - (end.x-start.x)*signum_y; } else { mid.x = end.x - abs(delta_y); mid.y = start.y; } display_thick_line( start.x, start.y, mid.x, mid.y, colore, dotted, 5, 3, thickness ); display_thick_line( mid.x, mid.y, end.x, end.y, colore, dotted, 5, 3, thickness ); } } } } // converts map (karte) koordinates to screen koordinates scr_coord minimap_t::map_to_screen_coord(const koord &k) const { assert(zoom_in ==1 || zoom_out ==1 ); sint32 x = (sint32)k.x * zoom_in; sint32 y = (sint32)k.y * zoom_in; if(isometric) { // 45 rotate view sint32 xrot = (sint32)world->get_size().y * zoom_in + x - y - 1; y = ( x + y )/2; x = xrot; } return {x/zoom_out, y/zoom_out}; } // and re-transform koord minimap_t::screen_to_map_coord(const scr_coord &c) const { sint32 x = ((sint32)c.x*zoom_out)/zoom_in; sint32 y = ((sint32)c.y*zoom_out)/zoom_in; if(isometric) { y *= 2; x = (x + y - world->get_size().y)/2; y = y - x; } return {(sint16)x, (sint16)y}; } bool minimap_t::change_zoom_factor(bool magnify) { bool zoomed = false; if( magnify ) { // zoom in if( zoom_out > 1 ) { zoom_out--; zoomed = true; } else { // check here for maximum zoom-out, otherwise there will be integer overflows // with large maps as we calculate with sint32 coordinates ... const int max_zoom_in = min( INT_MAX / (2*world->get_size_max()), 16); if( zoom_in < max_zoom_in ) { zoom_in++; zoomed = true; } } } else { // zoom out if( zoom_in > 1 ) { zoom_in--; zoomed = true; } else if( zoom_out < 16 ) { zoom_out++; zoomed = true; } } if( zoomed ){ // recalc map size calc_map_size(); } return zoomed; } PIXVAL minimap_t::calc_severity_color(sint32 amount, sint32 max_value) { if(max_value!=0) { // color array goes from light blue to red sint32 severity = amount * MAX_SEVERITY_COLORS / (max_value+1); return color_idx_to_rgb( minimap_t::severity_color[ clamp( severity, 0, MAX_SEVERITY_COLORS-1 ) ]); } return color_idx_to_rgb( minimap_t::severity_color[0]); } PIXVAL minimap_t::calc_severity_color_log(sint32 amount, sint32 max_value) { if( max_value>1 ) { sint32 severity; if( amount <= 0x003FFFFF ) { severity = log2( (uint32)( (amount << MAX_SEVERITY_COLORS) / (max_value+1) ) ); } else { severity = (uint32)( log( (double)amount*(double)(1<<MAX_SEVERITY_COLORS)/(double)max_value) + 0.5 ); } return color_idx_to_rgb( minimap_t::severity_color[ clamp( severity, 0, MAX_SEVERITY_COLORS-1 ) ]); } return color_idx_to_rgb( minimap_t::severity_color[0]); } void minimap_t::set_map_color_clip( sint16 x, sint16 y, PIXVAL color ) { if( 0<=x && (uint16)x < map_data->get_width() && 0<=y && (uint16)y < map_data->get_height() ) { map_data->at( x, y ) = color; } } void minimap_t::set_map_color(koord k_, const PIXVAL color) { // if map is in normal mode, set new color for map // otherwise do nothing // result: convois will not "paint over" special maps if ( map_data==nullptr || !world->is_within_limits(k_)) { return; } scr_coord c = map_to_screen_coord(k_); c -= cur_off; if( isometric ) { // since isometric is distorted const sint32 xw = zoom_out>=2 ? 1 : 2*zoom_in; // increase size at zoom_in 2, 5, 9, 11 const scr_coord_val mid_y = ((xw+1) / 5) + (xw / 18); // center line for( int x=0; x<xw; x++ ) { set_map_color_clip( c.x+x, c.y+mid_y, color ); } // lines above and below if( mid_y > 0 ) { scr_coord_val left = 2, right = xw-2 + ((xw>>1)&1); for( scr_coord_val y_offset = 1; y_offset <= mid_y; y_offset++ ) { for( int x=left; x<right; x++ ) { set_map_color_clip( c.x+x, c.y+mid_y+y_offset, color ); set_map_color_clip( c.x+x, c.y+mid_y-y_offset, color ); } left += 2; right -= 2; } } } else { for( sint32 x = max(0,c.x); x < zoom_in+c.x && (uint32)x < map_data->get_width(); x++ ) { for( sint32 y = max(0,c.y); y < zoom_in+c.y && (uint32)y < map_data->get_height(); y++ ) { map_data->at(x, y) = color; } } } } /** * calculates ground color for position relative to water height * @param height height of the tile * @param groundwater water height */ PIXVAL minimap_t::calc_height_color(const sint16 height, const sint16 groundwater) { sint16 relative_index; if( height>groundwater ) { // adjust index for world_maximum_height relative_index = (height-groundwater)*MAX_MAP_TYPE_LAND/world->get_settings().get_maximumheight(); if( (height-groundwater)*MAX_MAP_TYPE_LAND%world->get_settings().get_maximumheight()!=0 ) { // to avoid relative_index==0 relative_index += 1; } } else { relative_index = height-groundwater; } return color_idx_to_rgb(map_type_color[clamp( relative_index+MAX_MAP_TYPE_WATER-1, 0, MAX_MAP_TYPE_WATER+MAX_MAP_TYPE_LAND-1 )]); } /** * Calculates the minimap color of a ground tile */ PIXVAL minimap_t::calc_ground_color(const grund_t *gr, bool show_contour, bool show_buildings) { PIXVAL color = color_idx_to_rgb(COL_BLACK); #ifdef DEBUG_ROUTES /* for debug purposes only ...*/ if(gr->get_flag(grund_t::marked)) { color = color_idx_to_rgb(COL_PURPLE); } else #endif if(gr->get_halt().is_bound() && show_buildings) { color = COL_HALT; } else { switch(gr->get_typ()) { case grund_t::brueckenboden: color = color_idx_to_rgb(MN_GREY3); break; case grund_t::tunnelboden: color = color_idx_to_rgb(COL_BROWN); break; case grund_t::monorailboden: color = COL_MONORAIL; break; case grund_t::wasser: { // object at zero is either factory or boat gebaeude_t *gb = gr->find<gebaeude_t>(); fabrik_t *fab = gb ? gb->get_fabrik() : nullptr; if(fab==nullptr) { sint16 height = corner_sw(gr->get_grund_hang()); if ( show_contour ) { color = calc_height_color(world->lookup_hgt(gr->get_pos().get_2d()) + height, world->get_water_hgt(gr->get_pos().get_2d())); } else { color = color_idx_to_rgb(map_type_color[MAX_MAP_TYPE_WATER - 1]); } //color = color_idx_to_rgb(COL_BLUE); // water with boat? } else { color = fab->get_color(); } } break; // normal ground ... case grund_t::fundament: default: if(show_buildings && gr->get_typ() == grund_t::fundament){ // object at zero is either factory or house (or attraction ... ) gebaeude_t *gb = gr->find<gebaeude_t>(); fabrik_t *fab = gb ? gb->get_fabrik() : nullptr; if(fab==nullptr) { color = color_idx_to_rgb(COL_GREY3); } else { color = fab->get_color(); } } else if(gr->hat_wege()) { switch(gr->get_weg_nr(0)->get_waytype()) { case road_wt: color = COL_ROAD; break; case tram_wt: case track_wt: color = COL_RAIL; break; case water_wt: color = COL_CANAL; break; case air_wt: color = COL_RUNWAY; break; case monorail_wt: default: // all other ways light red ... color = color_idx_to_rgb(135); break; } } else { const leitung_t* lt = gr->find<leitung_t>(); if(lt!=nullptr) { color = COL_POWERLINE; } else if (!show_contour) { color = color_idx_to_rgb(map_type_color[MAX_MAP_TYPE_WATER]); } else { sint16 height = corner_sw(gr->get_grund_hang()); if( gr->get_hoehe() > world->get_groundwater() ) { color = calc_height_color( gr->get_hoehe() + height, world->get_groundwater() ); } else { color = calc_height_color( gr->get_hoehe() + height, gr->get_hoehe() + height - 1); } } } break; } } return color; } void minimap_t::calc_map_pixel(const koord k) { // no pixels visible, so noting to calculate if(!is_visible) { return; } // always use to uppermost ground const planquadrat_t *plan=world->access(k); if(plan==nullptr || plan->get_boden_count()==0) { return; } // When displaying buildings, give priority to buildings over tunnels and bridges const grund_t *gr = (show_buildings && plan->get_kartenboden()->get_typ() == grund_t::fundament)? plan->get_kartenboden() : plan->get_boden_bei(plan->get_boden_count() - 1); if( mode!=MAP_PAX_DEST && gr->get_convoi_vehicle() && (mode & MAP_CONVOYS)) { set_map_color(k, COL_VEHICLE); return; } // first use ground color set_map_color( k, calc_ground_color(gr, show_contour, show_buildings) ); bool any_suitable_stops = false; uint16 min_tiles_to_halt = -1; switch(mode& ~MAP_MODE_FLAGS) { // show passenger/mail coverage // display coverage case MAP_STATION_COVERAGE: if( plan->get_haltlist_count()>0 && gr->suche_obj(obj_t::gebaeude)) { const nearby_halt_t *const halt_list = plan->get_haltlist(); bool show_only_freight_station = (freight_type_group_index_showed_on_map != nullptr && freight_type_group_index_showed_on_map != goods_manager_t::none && freight_type_group_index_showed_on_map != goods_manager_t::mail && freight_type_group_index_showed_on_map != goods_manager_t::passengers); for (int h = 0; h < plan->get_haltlist_count(); h++) { const halthandle_t halt = halt_list[h].halt; // player filter if(player_showed_on_map != -1 && (world->get_player(player_showed_on_map) != halt->get_owner())) { continue; } // station waytype compatible filter if(transport_type_showed_on_map != simline_t::line && !(halt->get_station_type() & simline_t::linetype_to_stationtype[transport_type_showed_on_map])) { continue; } if(!(freight_type_group_index_showed_on_map==nullptr || (freight_type_group_index_showed_on_map == goods_manager_t::none && halt->get_ware_enabled()) || halt->gibt_ab(freight_type_group_index_showed_on_map))){ continue; } if (halt_list[h].distance!=0) { // FIXME: Freight coverage is determined by Manhattan distance, not Chebyshev distance. - Ranran uint16 cov; if (!show_only_freight_station && (halt->get_pax_enabled() || halt->get_mail_enabled())) { cov = world->get_settings().get_station_coverage(); } else if (halt->get_ware_enabled()) { cov = world->get_settings().get_station_coverage_factories(); } else { cov = 0; } if (cov == world->get_settings().get_station_coverage() || (cov != world->get_settings().get_station_coverage() && cov >= halt_list[h].distance)) { any_suitable_stops = true; min_tiles_to_halt = min(min_tiles_to_halt, halt_list[h].distance); } } } if (any_suitable_stops) { uint16 sutation_coverage = show_only_freight_station ? world->get_settings().get_station_coverage_factories() : world->get_settings().get_station_coverage(); set_map_color(k, calc_severity_color(min_tiles_to_halt, sutation_coverage * 2)); } } break; // show usage case MAP_FREIGHT: // need to init the maximum? if(max_cargo==0) { max_cargo = 1; calc_map(); } else if( gr->hat_wege() ) { // now calc again ... sint32 cargo=0; // maximum two ways for one ground const weg_t *w=gr->get_weg_nr(0); if(w) { cargo = w->get_statistics(WAY_STAT_GOODS); const weg_t *w=gr->get_weg_nr(1); if(w) { cargo += w->get_statistics(WAY_STAT_GOODS); } if( cargo > max_cargo ) { max_cargo = cargo; } set_map_color(k, calc_severity_color_log(cargo, max_cargo)); } } break; // show traffic (=convois/month) case MAP_TRAFFIC: // need to init the maximum? if( max_passed==0 ) { max_passed = 1; calc_map(); } else if(gr->hat_wege()) { // now calc again ... sint32 passed=0; // maximum two ways for one ground const weg_t *w=gr->get_weg_nr(0); if(w) { passed = w->get_statistics(WAY_STAT_CONVOIS); if( weg_t *w=gr->get_weg_nr(1) ) { passed += w->get_statistics(WAY_STAT_CONVOIS); } if( passed > max_passed ) { max_passed = passed; } set_map_color(k, calc_severity_color_log( passed, max_passed ) ); } } break; // Show condition case MAP_CONDITION: uint32 condition_percent; if(gr->hat_wege()) { // maximum two ways for one ground const weg_t *way = gr->get_weg_nr(0); condition_percent = way->get_condition_percent(); if (way->get_desc()->is_mothballed()) { set_map_color(k, MAP_COL_NODATA); break; } else if(const weg_t *second_way = gr->get_weg_nr(1)) { condition_percent = min(condition_percent, second_way->get_condition_percent()); } const sint32 condition_percent_reciprocal = 100 - condition_percent; set_map_color(k, calc_severity_color(condition_percent_reciprocal, 100)); } break; // Show congestion case MAP_CONGESTION: if (gr->hat_wege()) { // This is only applicable to roads. const weg_t* road = gr->get_weg(road_wt); if (road) { // Because it is possible for congestion to be >100% (as 100% merely means that traffic // takes 100% longer than the uncongested time to traverse the tile), set the colour range // based on a maximum of 250% to allow more granularity in congested places. set_map_color(k, calc_severity_color(road->get_congestion_percentage(), 250)); } } break; // show tracks: white: no electricity, red: electricity, yellow: signal case MAP_TRACKS: // show track if (gr->hat_weg(track_wt)) { const schiene_t * sch = (const schiene_t *) (gr->get_weg(track_wt)); if(sch->is_electrified()) { set_map_color(k, color_idx_to_rgb(COL_RED)); } else { set_map_color(k, color_idx_to_rgb(COL_WHITE)); } // show signals if(sch->has_sign() || sch->has_signal()) { set_map_color(k, color_idx_to_rgb(COL_YELLOW)); } } break; // show max speed (if there) case MAX_SPEEDLIMIT: { if (gr->hat_wege() && gr->get_weg_nr(0)->get_desc()->is_mothballed()) { set_map_color(k, MAP_COL_NODATA); break; } const sint32 speed_factor = 450-gr->get_max_speed() > 0 ? 450 - gr->get_max_speed() : 0; if(gr->get_max_speed()) { set_map_color(k, calc_severity_color(pow(speed_factor,2.0)/100, 2025)); } } break; // Show weight limit (if present) case MAP_WEIGHTLIMIT: { if(gr->hat_wege()) { const weg_t* way = gr->get_weg_nr(0); if (way->get_desc()->is_mothballed()) { set_map_color(k, MAP_COL_NODATA); break; } else if(way->get_waytype() == powerline_wt || !way->get_max_axle_load()) { break; } if(gr->ist_bruecke()) { set_map_color(k, calc_severity_color(350-way->get_bridge_weight_limit()>0 ? 350-way->get_bridge_weight_limit() : 0, 350)); } else { set_map_color(k, calc_severity_color(30-way->get_max_axle_load()>0 ? 30-way->get_max_axle_load() : 0, 30)); } } } break; // find power lines case MAP_POWERLINES: { const leitung_t* lt = gr->find<leitung_t>(); if(lt!=nullptr) { const uint64 demand = lt->get_net()->get_demand(); if (!lt->get_net()->get_demand() || !lt->get_net()->get_supply()) { set_map_color(k, MAP_COL_NODATA); } else if (demand) { set_map_color(k, calc_severity_color((sint32)lt->get_net()->get_demand(), (sint32)lt->get_net()->get_supply())); } } } break; case MAP_FOREST: if( gr->get_top()>1 && gr->obj_bei(gr->get_top()-1)->get_typ()==obj_t::baum ) { set_map_color(k, color_idx_to_rgb(COL_GREEN) ); } break; case MAP_OWNER: // show ownership { if( gr->is_halt() ) { set_map_color(k, color_idx_to_rgb(gr->get_halt()->get_owner()->get_player_color1()+3)); } else if( weg_t *weg = gr->get_weg_nr(0) ) { set_map_color(k, color_idx_to_rgb(weg->get_owner()==nullptr ? COL_ORANGE : weg->get_owner()->get_player_color1()+3 )); } if( gebaeude_t *gb = gr->get_building() ) { if( gb->get_owner()!=nullptr ) { set_map_color(k, color_idx_to_rgb(gb->get_owner()->get_player_color1()+3) ); } } break; } case MAP_LEVEL: if( max_building_level == 0 ) { // init maximum max_building_level = 1; calc_map(); } else if( gr->get_typ() == grund_t::fundament ) { if( gebaeude_t *gb = gr->find<gebaeude_t>() ) { if( gb->is_city_building() ) { sint32 level = gb->get_tile()->get_desc()->get_level(); if( level > max_building_level ) { max_building_level = level; } set_map_color(k, calc_severity_color(level, max_building_level)); } } } break; case MAP_ACCESSIBILITY_COMMUTING: { if (gebaeude_t *gb = gr->find<gebaeude_t>()) { gb = gb->access_first_tile(); if (gb->get_adjusted_population()) { const uint16 passengers_succeeded_commuting = gb->get_average_passenger_success_percent_commuting(); if(passengers_succeeded_commuting < 65535){ set_map_color(k, calc_severity_color(100 - passengers_succeeded_commuting, 100)); } else { set_map_color(k, MAP_COL_NODATA); } } } } break; case MAP_ACCESSIBILITY_TRIP: { if (gebaeude_t *gb = gr->find<gebaeude_t>()) { gb = gb->access_first_tile(); if (gb->get_adjusted_population()) { const uint16 passengers_succeeded_visiting = gb->get_average_passenger_success_percent_visiting(); if (passengers_succeeded_visiting < 65535) { set_map_color(k, calc_severity_color(100 - passengers_succeeded_visiting, 100)); } else { set_map_color(k, MAP_COL_NODATA); } } } } break; case MAP_STAFF_FULFILLMENT: { if (gebaeude_t *gb = gr->find<gebaeude_t>()) { gb = gb->access_first_tile(); if (gb->get_adjusted_jobs()) { if (fabrik_t *fab = gb->get_fabrik()) { // use this for primary industry or not const uint32 input_count = fab->get_input().get_count(); // Factories not in operation if (gb->get_passengers_succeeded_commuting() == 65535 && input_count) { set_map_color(k, color_idx_to_rgb(COL_DARK_PURPLE)); } else { const sint32 staffing_percentage = gb->get_staffing_level_percentage(); if (staffing_percentage < 65535) { set_map_color(k, calc_severity_color(100 - staffing_percentage, 100)); } else { set_map_color(k, MAP_COL_NODATA); } } } else { const sint32 staffing_percentage = gb->get_staffing_level_percentage(); set_map_color(k, calc_severity_color(100 - staffing_percentage, 100)); } } } } break; case MAP_MAIL_DELIVERY: { if (gebaeude_t *gb = gr->find<gebaeude_t>()) { gb = gb->access_first_tile(); if (gb->get_adjusted_mail_demand()) { const uint16 recent_mail_delivery_success_per = gb->get_average_mail_delivery_success_percent(); if (recent_mail_delivery_success_per < 65535) { set_map_color(k, calc_severity_color(100 - recent_mail_delivery_success_per, 100)); } else { set_map_color(k, MAP_COL_NODATA); } } } } break; default: break; } } scr_size minimap_t::get_min_size() const { return get_max_size(); //scr_size(0,0); } scr_size minimap_t::get_max_size() const { scr_coord size = map_to_screen_coord( koord( world->get_size().x, 0 ) ); scr_coord down = map_to_screen_coord( koord( world->get_size().x, world->get_size().y ) ); size.y = down.y; if( isometric ) { size.x += zoom_in*2; } return scr_size(size.x, size.y); } void minimap_t::calc_map_size() { set_size( get_max_size() ); // of the gui_komponete to adjust scroll bars needs_redraw = true; } void minimap_t::calc_map() { // only use bitmap size like screen size scr_size minimap_size ( min( get_size().w, new_size.w ), min( get_size().h, new_size.h ) ); // actually the following line should reduce new/deletes, but does not work properly if( map_data==nullptr || (sint16) map_data->get_width()!=minimap_size.w || (sint16) map_data->get_height()!=minimap_size.h ) { delete map_data; map_data = new array2d_tpl<PIXVAL> ( minimap_size.w,minimap_size.h); } cur_off = new_off; cur_size = new_size; needs_redraw = false; is_visible = true; // redraw the map if( !isometric ) { koord k; koord start_off = koord( (cur_off.x*zoom_out)/zoom_in, (cur_off.y*zoom_out)/zoom_in ); koord end_off = start_off+koord( ( map_data->get_width()*zoom_out)/zoom_in+1, ( map_data->get_height()*zoom_out)/zoom_in+1 ); for( k.y=start_off.y; k.y<end_off.y; k.y+=zoom_out ) { for( k.x=start_off.x; k.x<end_off.x; k.x+=zoom_out ) { calc_map_pixel(k); } } } else { // always the whole map ... map_data->init( color_idx_to_rgb(COL_BLACK) ); koord k; for( k.y=0; k.y < world->get_size().y; k.y++ ) { for( k.x=0; k.x < world->get_size().x; k.x++ ) { calc_map_pixel(k); } } } // since we do iterate the tourist info list, this must be done here // find tourist spots if(mode==MAP_TOURIST) { const weighted_vector_tpl<gebaeude_t *> &world_attractions = world->get_attractions(); // find the current maximum max_tourist_ziele = 1; FOR(weighted_vector_tpl<gebaeude_t*>, const i, world_attractions) { int const pax = i->get_adjusted_visitor_demand(); if (max_tourist_ziele < pax) { max_tourist_ziele = pax; } } // draw them FOR(weighted_vector_tpl<gebaeude_t*>, const g, world_attractions) { koord pos = g->get_pos().get_2d(); set_map_color( pos, calc_severity_color(g->get_adjusted_visitor_demand(), max_tourist_ziele)); } return; } // since we do iterate the factory info list, this must be done here if(mode==MAP_FACTORIES) { FOR(vector_tpl<fabrik_t*>, const f, world->get_fab_list()) { koord const pos = f->get_pos().get_2d(); set_map_color( pos, color_idx_to_rgb(COL_BLACK) ); set_map_color(pos, f->get_color()); } return; } if(mode==MAP_DEPOT) { FOR(slist_tpl<depot_t*>, const d, depot_t::get_depot_list()) { if (d->get_owner() == world->get_active_player()) { koord const pos = d->get_pos().get_2d(); // offset of one to avoid static uint8 depot_typ_to_color[19]={ COL_ORANGE, COL_YELLOW, COL_RED, 0, 0, 0, 0, 0, 0, COL_PURPLE, COL_DARK_RED, COL_DARK_ORANGE, 0, 0, 0, 0, 0, 0, COL_LIGHT_RED }; set_map_color(pos, color_idx_to_rgb(depot_typ_to_color[d->get_typ() - obj_t::bahndepot])); } } return; } } minimap_t::minimap_t(){ mode = MAP_TOWN; } minimap_t::~minimap_t() { finalize(); } minimap_t *minimap_t::get_instance() { if(single_instance == nullptr) { single_instance = new minimap_t(); } return single_instance; } void minimap_t::init() { //TODO should be called when closing the window; finalize(); needs_redraw = true; //is_visible = false; //show_buildings = true; calc_map_size(); max_building_level = max_cargo = max_passed = 0; max_tourist_ziele = max_waiting = max_origin = max_transfer = max_service = 1; last_schedule_counter = world->get_schedule_counter()-1; set_selected_cnv(convoihandle_t()); } void minimap_t::finalize(){ delete map_data; map_data = nullptr; } void minimap_t::set_display_mode(MAP_DISPLAY_MODE new_mode) { mode = new_mode; needs_redraw = true; } void minimap_t::new_month() { needs_redraw = true; } void minimap_t::invalidate_map_lines_cache() { last_schedule_counter = world->get_schedule_counter() - 1; needs_redraw = true; } // these two are the only gui_container specific routines // handle event bool minimap_t::infowin_event(const event_t *ev) { scr_coord c( ev->mx, ev->my ); koord k = screen_to_map_coord(c); // get factory under mouse cursor last_world_pos = k; // recenter if(IS_LEFTCLICK(ev) || IS_LEFTDRAG(ev)) { world->get_viewport()->set_follow_convoi( convoihandle_t() ); const sint8 min_hgt = world->is_within_grid_limits(k) ? world->min_hgt(k) : 0; world->get_viewport()->change_world_position(koord3d(k,min_hgt)); return true; } return false; } // helper function for finding nearby factory const fabrik_t* minimap_t::get_factory_near( const koord, bool enlarge ) const { const fabrik_t *fab = fabrik_t::get_fab(last_world_pos); for( int i=0; i<4 && fab==nullptr; i++ ) { fab = fabrik_t::get_fab( last_world_pos+koord::nesw[i] ); } if( enlarge ) { for( int i=0; i<4 && fab==nullptr; i++ ) { fab = fabrik_t::get_fab( last_world_pos+koord::nesw[i]*2 ); } } return fab; } // helper function for redraw: factory connections const fabrik_t* minimap_t::draw_factory_connections(const fabrik_t* const fab, bool supplier_link, const scr_coord pos) const { if(fab) { PIXVAL color = supplier_link ? color_idx_to_rgb(COL_RED) : color_idx_to_rgb(COL_WHITE); scr_coord fabpos = map_to_screen_coord( fab->get_pos().get_2d() ) + pos; const vector_tpl<koord>& lieferziele = supplier_link ? fab->get_suppliers() : fab->get_consumers(); FOR(vector_tpl<koord>, lieferziel, lieferziele) { const fabrik_t * fab2 = fabrik_t::get_fab(lieferziel); if (fab2) { const scr_coord end = map_to_screen_coord( lieferziel ) + pos; display_direct_line_rgb(fabpos.x, fabpos.y, end.x, end.y, color); display_fillbox_wh_clip_rgb(end.x, end.y, 3, 3, ((world->get_ticks() >> 10) & 1) == 0 ? color_idx_to_rgb(COL_RED) : color_idx_to_rgb(COL_WHITE), true); scr_coord boxpos = end + scr_coord(10, 0); const char * name = translator::translate(fab2->get_name()); int name_width = proportional_string_width(name)+8; boxpos.x = clamp( boxpos.x, pos.x, pos.x+get_size().w-name_width ); display_ddd_proportional_clip(boxpos.x, boxpos.y, name_width, 0, color_idx_to_rgb(5), color_idx_to_rgb(COL_WHITE), name, true); } } } return fab; } // show the schedule on the minimap void minimap_t::set_selected_cnv( convoihandle_t c ) { current_cnv = c; schedule_cache.clear(); stop_cache.clear(); colore_idx = 0; add_to_schedule_cache( current_cnv, true ); last_schedule_counter = world->get_schedule_counter()-1; } // draw the map (and the overlays!) void minimap_t::draw(scr_coord pos) { // sanity check, needed for overlarge maps if( (new_off.x|new_off.y)<0 ) { new_off = cur_off; } if( (new_size.w|new_size.h)<0 ) { new_size = cur_size; } if( last_mode != mode ) { // only needing update, if last mode was also not about halts ... needs_redraw = (mode^last_mode) & ~MAP_MODE_FLAGS; if( (mode & MAP_LINES) == 0 || (mode^last_mode) & MAP_MODE_HALT_FLAGS ) { // rebuilt stop_cache needed stop_cache.clear(); } if( (mode^last_mode) & (MAP_STATION_COVERAGE |MAP_FREIGHT|MAP_LINES) || (mode&MAP_LINES && stop_cache.empty()) ) { // rebuilt line display last_schedule_counter = world->get_schedule_counter()-1; } last_mode = mode; } if( needs_redraw || cur_off!=new_off || cur_size!=new_size ) { calc_map(); needs_redraw = false; } if( map_data==nullptr) { return; } if( mode & MAP_PAX_DEST && selected_city!=nullptr ) { const uint32 current_pax_destinations = selected_city->get_pax_destinations_new_change(); if( pax_destinations_last_change > current_pax_destinations ) { // new month started. calc_map(); } else if( pax_destinations_last_change < current_pax_destinations ) { // new pax_dest in city. const sparse_tpl<PIXVAL> *pax_dests = selected_city->get_pax_destinations_new(); koord pos, min, max; PIXVAL color; for( uint16 i = 0; i < pax_dests->get_data_count(); i++ ) { pax_dests->get_nonzero( i, pos, color ); min = koord(pos.x, pos.y); max = koord(pos.x + 1, pos.y + 1); pos.x = min.x; do { pos.y = min.y; do { set_map_color(pos, color); pos.y++; } while(pos.y < max.y); pos.x++; } while (pos.x < max.x); } } pax_destinations_last_change = selected_city->get_pax_destinations_new_change(); } if( (uint16)cur_size.w > map_data->get_width() ) { display_fillbox_wh_clip_rgb( pos.x+new_off.x+map_data->get_width(), new_off.y+pos.y, 32767, map_data->get_height(), color_idx_to_rgb(COL_BLACK), true); } if( (uint16)cur_size.h > map_data->get_height() ) { display_fillbox_wh_clip_rgb( pos.x+new_off.x, pos.y+new_off.y+map_data->get_height(), 32767, 32767, color_idx_to_rgb(COL_BLACK), true); } display_array_wh( cur_off.x+pos.x, new_off.y+pos.y, map_data->get_width(), map_data->get_height(), map_data->to_array()); if( !current_cnv.is_bound() && mode & MAP_LINES ) { vector_tpl<linehandle_t> linee; if( last_schedule_counter != world->get_schedule_counter() ) { // rebuild cache last_schedule_counter = world->get_schedule_counter(); schedule_cache.clear(); stop_cache.clear(); waypoint_hash.clear(); colore_idx = 0; for( int np = 0; np < MAX_PLAYER_COUNT; np++ ) { if( player_showed_on_map != -1 && player_showed_on_map != np ) { continue; } //cycle on players if( world->get_player( np ) && world->get_player( np )->simlinemgmt.get_line_count() > 0 ) { world->get_player( np )->simlinemgmt.get_lines( simline_t::line, &linee ); for( uint32 j = 0; j < linee.get_count(); j++ ) { //cycle on lines if( transport_type_showed_on_map != simline_t::line && linee[j]->get_linetype() != transport_type_showed_on_map ) { continue; } if( !is_matching_freight_catg( linee[j]->get_goods_catg_index() ) ) { continue; } // ware matches; now find at least a running convoi on this line ... convoihandle_t cnv; for( uint32 k = 0; k < linee[j]->count_convoys(); k++ ) { convoihandle_t test_cnv = linee[j]->get_convoy(k); if( test_cnv.is_bound() ) { int state = test_cnv->get_state(); if( state != convoi_t::INITIAL && state != convoi_t::ENTERING_DEPOT && state != convoi_t::SELF_DESTRUCT ) { cnv = test_cnv; break; } } } if( !cnv.is_bound() ) { continue; } int state = cnv->get_state(); if( state != convoi_t::INITIAL && state != convoi_t::ENTERING_DEPOT && state != convoi_t::SELF_DESTRUCT ) { add_to_schedule_cache( cnv, false ); } } } } // now add all unbound convois player_t * required_vehicle_owner = nullptr; if (player_showed_on_map != -1) { required_vehicle_owner = world->get_player(player_showed_on_map); } FOR( vector_tpl<convoihandle_t>, cnv, world->convoys() ) { if( !cnv.is_bound() || cnv->get_line().is_bound() ) { // not there or already part of a line continue; } if( required_vehicle_owner!= nullptr && required_vehicle_owner != cnv->get_owner() ) { continue; } if( transport_type_showed_on_map != simline_t::line ) { if( transport_type_showed_on_map != simline_t::waytype_to_linetype(cnv->front()->get_waytype()) ) { continue; } } int state = cnv->get_state(); if( state != convoi_t::INITIAL && state != convoi_t::ENTERING_DEPOT && state != convoi_t::SELF_DESTRUCT ) { if( !is_matching_freight_catg(cnv->get_goods_catg_index()) ) { continue; } add_to_schedule_cache( cnv, false ); } } } /************ ATTENTION: The schedule pointers schedule in the line segments ****************** ************ are invalid after this point! ******************/ } //end MAP_LINES bool showing_schedule = false; if( mode & MAP_LINES ) { showing_schedule = !schedule_cache.empty(); } else { schedule_cache.clear(); colore_idx = 0; last_schedule_counter = world->get_schedule_counter()-1; } // since the schedule whitens out the background, we have to draw it first int offset = 1; koord last_start(0,0), last_end(0,0); bool diagonal = false; if( showing_schedule ) { // lighten background if( isometric ) { // isometric => lighten in three parts scr_coord p1 = map_to_screen_coord( koord(0,0) ); scr_coord p2 = map_to_screen_coord( koord( world->get_size().x, 0 ) ); scr_coord p3 = map_to_screen_coord( koord( world->get_size().x, world->get_size().y ) ); scr_coord p4 = map_to_screen_coord( koord( 0, world->get_size().y ) ); // top and bottom part const int toplines = min( p4.y, p2.y ); for( scr_coord_val y = 0; y < toplines; y++ ) { display_blend_wh_rgb( pos.x+p1.x-2*y, pos.y+y, 4*y+4, 1, color_idx_to_rgb(COL_WHITE), 75 ); display_blend_wh_rgb( pos.x+p3.x-2*y, pos.y+p3.y-y-1, 4*y+4, 1, color_idx_to_rgb(COL_WHITE), 75 ); } // center area if( p1.x < p3.x ) { for( scr_coord_val y = toplines; y < p3.y-toplines; y++ ) { display_blend_wh_rgb( pos.x+(y-toplines)*2, pos.y+y, 4*toplines+4, 1, color_idx_to_rgb(COL_WHITE), 75 ); } } else { for( scr_coord_val y = toplines; y < p3.y-toplines; y++ ) { display_blend_wh_rgb( pos.x+(y-toplines)*2, pos.y+p3.y-y-1, 4*toplines+4, 1, color_idx_to_rgb(COL_WHITE), 75 ); } } } else { // easier with rectangular maps ... display_blend_wh_rgb( cur_off.x+pos.x, cur_off.y+pos.y, map_data->get_width(), map_data->get_height(), color_idx_to_rgb(COL_WHITE), 75 ); } scr_coord k1,k2; // DISPLAY STATIONS AND AIRPORTS: moved here so station spots are not overwritten by lines drawn FOR( vector_tpl<line_segment_t>, seg, schedule_cache ) { uint8 color = seg.colorcount; if( event_get_last_control_shift()==2 || current_cnv.is_bound() ) { // on control / single convoi use only player colors static uint8 last_color = color; color = seg.player->get_player_color1()+1; // all lines same thickness if same color if( color == last_color ) { offset = 0; } last_color = color; } if( seg.start != last_start || seg.end != last_end ) { last_start = seg.start; k1 = map_to_screen_coord( seg.start ); k1 += pos; last_end = seg.end; k2 = map_to_screen_coord( seg.end ); k2 += pos; // use same diagonal for all parallel segments diagonal = seg.start_diagonal; } // and finally draw ... line_segment_draw( seg.wtyp, k1, seg.start_offset*offset, k2, seg.end_offset*offset, diagonal, color_idx_to_rgb(color) ); } } const uint8 max_classes = max(goods_manager_t::passengers->get_number_of_classes(), goods_manager_t::mail->get_number_of_classes()); // display station information here (even without overlay) halthandle_t display_station; // only fill cache if needed if( mode & MAP_MODE_HALT_FLAGS && stop_cache.empty() ) { if( mode & MAP_ORIGIN ) { FOR( const vector_tpl<halthandle_t>, halt, haltestelle_t::get_alle_haltestellen() ) { if( halt->get_pax_enabled() || halt->get_mail_enabled() ) { stop_cache.append( halt ); } } } else if( mode & MAP_TRANSFER ) { FOR( const vector_tpl<halthandle_t>, halt, haltestelle_t::get_alle_haltestellen() ) { if( halt->is_transfer(goods_manager_t::INDEX_PAS, goods_manager_t::passengers->get_number_of_classes() - 1, max_classes) || halt->is_transfer(goods_manager_t::INDEX_MAIL, goods_manager_t::mail->get_number_of_classes() - 1, max_classes) ) { stop_cache.append( halt ); } else { // goods transfer? bool transfer = false; for( int i=goods_manager_t::INDEX_NONE+1 && !transfer; i<goods_manager_t::get_max_catg_index(); i ++ ) { transfer = halt->is_transfer( i, 0, max_classes ); } if( transfer ) { stop_cache.append( halt ); } } } } else if( mode&MAP_STATUS || mode&MAP_SERVICE || mode&MAP_WAITING || mode&MAP_WAITCHANGE ) { FOR( const vector_tpl<halthandle_t>, halt, haltestelle_t::get_alle_haltestellen() ) { stop_cache.append( halt ); } } } // now draw stop cache // if needed to get new values sint32 new_max_waiting_change = 1; FOR( vector_tpl<halthandle_t>, station, stop_cache ) { if( !station.is_bound() ) { // maybe deleted in the meanwhile continue; } int radius = 0; PIXVAL color; int diagonal_dist = 0; scr_coord temp_stop = map_to_screen_coord( station->get_basis_pos() ); temp_stop = temp_stop + pos; if( mode & MAP_STATUS ) { color = color_idx_to_rgb(station->get_status_farbe()); radius = number_to_radius( station->get_capacity(0) ); } else if( mode & MAP_SERVICE ) { const sint32 service = (sint32)station->get_finance_history( 1, HALT_CONVOIS_ARRIVED ); if( service > max_service ) { max_service = service; } color = calc_severity_color_log( service, max_service ); radius = log2( (uint32)( (service << 7) / max_service ) ); } else if( mode & MAP_WAITING ) { const sint32 waiting = (sint32)station->get_finance_history( 0, HALT_WAITING ); if( waiting > max_waiting ) { max_waiting = waiting; } color = calc_severity_color_log( waiting, max_waiting ); radius = number_to_radius( waiting ); } else if( mode & MAP_WAITCHANGE ) { const sint32 waiting_diff = (sint32)(station->get_finance_history( 0, HALT_WAITING ) - station->get_finance_history( 1, HALT_WAITING )); if( waiting_diff > new_max_waiting_change ) { new_max_waiting_change = waiting_diff; } if( waiting_diff < -new_max_waiting_change ) { new_max_waiting_change = -waiting_diff; } const sint32 span = max(new_max_waiting_change,max_waiting_change); const sint32 diff = waiting_diff + span; color = calc_severity_color( diff, span*2 ) ; radius = number_to_radius( abs(waiting_diff) ); } else if( mode & MAP_ORIGIN ) { if( !station->get_pax_enabled() && !station->get_mail_enabled() ) { continue; } const sint32 pax_origin = (sint32)(station->get_finance_history( 1, HALT_HAPPY ) + station->get_finance_history( 1, HALT_UNHAPPY ) + station->get_finance_history(1, HALT_TOO_WAITING) + station->get_finance_history(1, HALT_NOROUTE) + station->get_finance_history( 1, HALT_TOO_SLOW )); if( pax_origin > max_origin ) { max_origin = pax_origin; } color = calc_severity_color_log( pax_origin, max_origin ); radius = number_to_radius( pax_origin ); } else if( mode & MAP_TRANSFER ) { const sint32 transfer = (sint32)(station->get_finance_history( 1, HALT_ARRIVED ) + station->get_finance_history( 1, HALT_DEPARTED )); if( transfer > max_transfer ) { max_transfer = transfer; } color = calc_severity_color_log( transfer, max_transfer ); radius = number_to_radius( transfer ); } else { const int stype = station->get_station_type(); color = color_idx_to_rgb(station->get_owner()->get_player_color1()+3); // invalid=0, loadingbay=1, railstation = 2, dock = 4, busstop = 8, airstop = 16, monorailstop = 32, tramstop = 64, maglevstop=128, narrowgaugestop=256 if( stype > 0 ) { radius = 1; if( stype & ~(haltestelle_t::loadingbay | haltestelle_t::busstop | haltestelle_t::tramstop) ) { radius = 3; } } // with control, show only circles if( event_get_last_control_shift()!=2 ) { // else elongate them ... const int key = station->get_basis_pos().x + station->get_basis_pos().y * world->get_size().x; diagonal_dist = waypoint_hash.get( key ).get_count(); if( diagonal_dist ) { diagonal_dist--; } diagonal_dist = (diagonal_dist*3)-1; } // show the mode of transport of the station if( skinverwaltung_t::station_type ) { int icon = 0; for( int type=0; type<9; type++ ) { if( (stype>>type)&1 ) { image_id img = skinverwaltung_t::station_type->get_image_id(type); if( img!=IMG_EMPTY ) { display_color_img( img, temp_stop.x+diagonal_dist+4+(icon/2)*12, temp_stop.y+diagonal_dist+4+(icon&1)*12, station->get_owner()->get_player_nr(), false, false ); icon++; } } } } else { if( stype & haltestelle_t::airstop ) { display_airport( temp_stop.x+diagonal_dist, temp_stop.y+diagonal_dist, color ); } if( stype & haltestelle_t::dock ) { fabrik_t *fab = fabrik_t::get_fab(station->get_basis_pos()); if (fab && fab->get_sector() == fabrik_t::marine_resource && skinverwaltung_t::ind_sector_symbol) { display_color_img(skinverwaltung_t::ind_sector_symbol->get_image_id(0), temp_stop.x + diagonal_dist+4, temp_stop.y + diagonal_dist+4, 0, false, false); } else { display_harbor(temp_stop.x + diagonal_dist, temp_stop.y + diagonal_dist, color); } } } } // avoid too small circles when zoomed out if( zoom_in > 1 ) { radius ++; } int out_radius = (radius == 0) ? 1 : radius; display_filled_circle_rgb( temp_stop.x, temp_stop.y, radius, color ); display_circle_rgb( temp_stop.x, temp_stop.y, out_radius, color_idx_to_rgb(COL_BLACK) ); if( diagonal_dist>0 ) { display_filled_circle_rgb( temp_stop.x+diagonal_dist, temp_stop.y+diagonal_dist, radius, color ); display_circle_rgb( temp_stop.x+diagonal_dist, temp_stop.y+diagonal_dist, out_radius, color_idx_to_rgb(COL_BLACK) ); for( int i=1; i < diagonal_dist; i++ ) { display_filled_circle_rgb( temp_stop.x+i, temp_stop.y+i, radius, color ); } out_radius = sqrt_i32( 2*out_radius+1 ); display_direct_line_rgb( temp_stop.x+out_radius, temp_stop.y-out_radius, temp_stop.x+out_radius+diagonal_dist, temp_stop.y-out_radius+diagonal_dist, color_idx_to_rgb(COL_BLACK) ); display_direct_line_rgb( temp_stop.x-out_radius, temp_stop.y+out_radius, temp_stop.x-out_radius+diagonal_dist, temp_stop.y+out_radius+diagonal_dist, color_idx_to_rgb(COL_BLACK) ); } if( koord_distance( last_world_pos, station->get_basis_pos() ) <= 2 ) { // draw stop name with an index if close to mouse display_station = station; } } if( display_station.is_bound() ) { scr_coord temp_stop = map_to_screen_coord( display_station->get_basis_pos() ); temp_stop = temp_stop + pos; display_ddd_proportional_clip( temp_stop.x + 10, temp_stop.y + 7, proportional_string_width( display_station->get_name() ) + 8, 0, color_idx_to_rgb(display_station->get_owner()->get_player_color1()+3), color_idx_to_rgb(COL_WHITE), display_station->get_name(), false ); } max_waiting_change = new_max_waiting_change; // update waiting tendencies // if we do not do this here, vehicles would erase the town names // ADD: if CRTL key is pressed, temporary show the name if( mode & MAP_TOWN ) { const weighted_vector_tpl<stadt_t*>& staedte = world->get_cities(); const PIXVAL col = color_idx_to_rgb(showing_schedule ? COL_BLACK : COL_WHITE); FOR( weighted_vector_tpl<stadt_t*>, const city, staedte ) { const char * name = city->get_name(); scr_coord p = map_to_screen_coord( city->get_pos() ); p += pos; display_proportional_clip_rgb( p.x, p.y, name, ALIGN_LEFT, col, true ); } } // draw city limit if( mode & MAP_CITYLIMIT ) { // for all cities FOR( weighted_vector_tpl<stadt_t*>, const city, world->get_cities() ) { koord k[4]; k[0] = city->get_linksoben(); // top left k[2] = city->get_rechtsunten(); // bottom right k[1] = koord(k[0].x, k[2].y); // bottom left k[3] = koord(k[2].x, k[0].y); // top right // Ones on bottom and right must have 1 added to put dotted line "past" them k[1] += koord(0, 1); // bottom left k[2] += koord(1, 1); // bottom right k[3] += koord(1, 0); // top right // calculate and draw the rotated coordinates scr_coord adjustment = pos; if (isometric && zoom_out == 1) { // Correct adjustment is to the right (positive x) by // zoom_in * sqrt(2) * 1/2. Approximate sqrt(2)/2 by 7/10, // which is good enough up to at least 16x zoom-in. adjustment += scr_coord( zoom_in * 7 / 10, 0); } scr_coord c[4]; c[0] = map_to_screen_coord(k[0]) + adjustment; c[1] = map_to_screen_coord(k[1]) + adjustment; c[2] = map_to_screen_coord(k[2]) + adjustment; c[3] = map_to_screen_coord(k[3]) + adjustment; display_direct_line_dotted_rgb( c[0].x, c[0].y, c[1].x, c[1].y, 3, 3, color_idx_to_rgb(COL_ORANGE) ); display_direct_line_dotted_rgb( c[1].x, c[1].y, c[2].x, c[2].y, 3, 3, color_idx_to_rgb(COL_ORANGE) ); display_direct_line_dotted_rgb( c[2].x, c[2].y, c[3].x, c[3].y, 3, 3, color_idx_to_rgb(COL_ORANGE) ); display_direct_line_dotted_rgb( c[3].x, c[3].y, c[0].x, c[0].y, 3, 3, color_idx_to_rgb(COL_ORANGE) ); } } // since we do iterate the tourist info list, this must be done here // find tourist spots if( mode & MAP_TOURIST ) { FOR( weighted_vector_tpl<gebaeude_t*>, const gb, world->get_attractions() ) { if( gb->get_first_tile() == gb ) { scr_coord gb_pos = map_to_screen_coord( gb->get_pos().get_2d() ); gb_pos = gb_pos + pos; int const pax = gb->get_adjusted_visitor_demand(); if( max_tourist_ziele < pax ) { max_tourist_ziele = pax; } PIXVAL color = calc_severity_color_log(gb->get_adjusted_visitor_demand(), max_tourist_ziele); int radius = max( (number_to_radius( pax*4 )*zoom_in)/zoom_out, 1 ); display_filled_circle_rgb( gb_pos.x, gb_pos.y, radius, color ); display_circle_rgb( gb_pos.x, gb_pos.y, radius, color_idx_to_rgb(COL_BLACK) ); } // otherwise larger attraction will be shown more often ... } } if( mode & MAP_FACTORIES ) { FOR( vector_tpl<fabrik_t*>, const f, world->get_fab_list() ) { // filter check if (freight_type_group_index_showed_on_map == goods_manager_t::passengers) { if (!f->get_building()->get_adjusted_visitor_demand() && !f->get_building()->get_adjusted_jobs()) { continue; } } else if (freight_type_group_index_showed_on_map == goods_manager_t::mail) { if(!f->get_building()->get_adjusted_mail_demand()) { continue; } } else if ( ((freight_type_group_index_showed_on_map != nullptr && freight_type_group_index_showed_on_map != goods_manager_t::none) && !f->has_goods_catg_demand(freight_type_group_index_showed_on_map->get_catg_index()))) { continue; } // find top-left tile position koord3d fab_tl_pos = f->get_pos(); if (grund_t *gr = world->lookup(f->get_pos())) { if (gebaeude_t* gb = gr->find<gebaeude_t>()) { fab_tl_pos = gb->get_pos() - gb->get_tile()->get_offset(); } } scr_coord fab_pos = map_to_screen_coord( fab_tl_pos.get_2d() ); fab_pos = fab_pos + pos; koord size = f->get_desc()->get_building()->get_size(f->get_rotate()); sint16 x_size = max( 5, size.x*zoom_in ); sint16 y_size = max( 5, size.y*zoom_in ); display_fillbox_wh_clip_rgb( fab_pos.x-1, fab_pos.y-1, x_size+2, y_size+2, color_idx_to_rgb(COL_BLACK), false ); display_fillbox_wh_clip_rgb( fab_pos.x, fab_pos.y, x_size, y_size, f->get_color(), false ); } } if( mode & MAP_DEPOT ) { FOR( slist_tpl<depot_t*>, const d, depot_t::get_depot_list() ) { if( d->get_owner() == world->get_active_player() ) { scr_coord depot_pos = map_to_screen_coord( d->get_pos().get_2d() ); depot_pos = depot_pos + pos; // offset of one to avoid static uint8 depot_typ_to_color[19]={ COL_ORANGE, COL_YELLOW, COL_RED, 0, 0, 0, 0, 0, 0, COL_PURPLE, COL_DARK_RED, COL_DARK_ORANGE, 0, 0, 0, 0, 0, 0, COL_LIGHT_RED }; display_filled_circle_rgb( depot_pos.x, depot_pos.y, 4, color_idx_to_rgb(depot_typ_to_color[d->get_typ() - obj_t::bahndepot]) ); display_circle_rgb( depot_pos.x, depot_pos.y, 4, color_idx_to_rgb(COL_BLACK) ); } } } // zoom/resize "selection box" in map // this must be rotated by 45 degree (sin45=cos45=0,5*sqrt(2)=0.707...) const sint16 raster=get_tile_raster_width(); // calculate and draw the rotated coordinates koord ij = world->get_viewport()->get_world_position(); const koord diff = koord( display_get_width()/(2*raster), display_get_height()/raster ); koord view[4]; scr_coord test[4]; // default coordinates - may be off if screen shows high mountains view[0] = ij + koord( -diff.y+diff.x, -diff.y-diff.x ); view[1] = ij + koord( -diff.y-diff.x, -diff.y+diff.x ); view[2] = ij + koord( diff.y-diff.x, diff.y+diff.x ); view[3] = ij + koord( diff.y+diff.x, diff.y-diff.x ); // try to find tile under the four corners of the screen test[0] = scr_coord(display_get_width(),0); test[1] = scr_coord(0,0); test[2] = scr_coord(0,display_get_height()); test[3] = scr_coord(display_get_width(),display_get_height()); for(int i=0; i<4; i++) { sint32 dummy1, dummy2; if (grund_t *gr = world->get_viewport()->get_ground_on_screen_coordinate( test[i], dummy1, dummy2 ) ) { view[i] = gr->get_pos().get_2d(); } } scr_coord c[4]; // translate to coordinates in the minimap for( int i=0; i<4; i++ ) { c[i] = map_to_screen_coord( view[i] ) + pos; } for( int i=0; i<4; i++ ) { display_direct_line_rgb( c[i].x, c[i].y, c[(i+1)%4].x, c[(i+1)%4].y, color_idx_to_rgb(COL_YELLOW)); } if( !showing_schedule ) { // Add factory name tooltips and draw factory connections, if on a factory const fabrik_t* const fab = get_factory_near(last_world_pos, (mode & MAP_FACTORIES)); if(fab) { if (mode & MAP_FACTORIES) { draw_factory_connections(fab,event_get_last_control_shift() & 1, pos); } scr_coord fabpos = map_to_screen_coord( fab->get_pos().get_2d() ); scr_coord boxpos = fabpos + scr_coord(10, 0); const char * name = translator::translate(fab->get_name()); int name_width = proportional_string_width(name)+8; boxpos.x = clamp( boxpos.x, 0, 0+get_size().w-name_width ); boxpos += pos; display_ddd_proportional_clip(boxpos.x, boxpos.y, name_width, 0, color_idx_to_rgb(10), color_idx_to_rgb(COL_WHITE), name, true); } for (uint32 i = 0; i < win_get_open_count(); i++) { gui_frame_t *g = win_get_index(i); if(g->get_rdwr_id()== magic_factory_info) { // is a factory info window const fabrik_t * const fab = dynamic_cast<fabrik_info_t *>(g)->get_factory(); draw_factory_connections(fab, true, pos); draw_factory_connections(fab, false, pos); } } } } void minimap_t::set_selected_city( const stadt_t* _city ) { if( selected_city != _city ) { selected_city = _city; if( _city ) { pax_destinations_last_change = _city->get_pax_destinations_new_change(); } calc_map(); } } void minimap_t::rdwr(loadsave_t *file) { file->rdwr_short(zoom_out); file->rdwr_short(zoom_in); file->rdwr_bool(isometric); } bool minimap_t::is_matching_freight_catg(const minivec_tpl<uint8> &goods_catg_index) { // does this line/convoi has a matching freight if( freight_type_group_index_showed_on_map == goods_manager_t::passengers ) { return goods_catg_index.is_contained(goods_manager_t::INDEX_PAS); } else if( freight_type_group_index_showed_on_map == goods_manager_t::mail ) { return goods_catg_index.is_contained(goods_manager_t::INDEX_MAIL); } else if( freight_type_group_index_showed_on_map == goods_manager_t::none ) { // all freights but not pax or mail for( uint8 i = 0; i < goods_catg_index.get_count(); i++ ) { if( goods_catg_index[i] > goods_manager_t::INDEX_NONE ) { return true; } } return false; } else if( freight_type_group_index_showed_on_map != nullptr) { for( uint8 i = 0; i < goods_catg_index.get_count(); i++ ) { if( goods_catg_index[i] == freight_type_group_index_showed_on_map->get_catg_index() ) { return true; } } return false; } /* This doesn't make sense anymore. * Formerly it did. // null show all but obey modes if( mode & MAP_STATION_COVERAGE ) { return goods_catg_index.is_contained(goods_manager_t::INDEX_PAS); } else if( mode & MAP_FREIGHT ) { // all freights but not pax or mail for( uint8 i = 0; i < goods_catg_index.get_count(); i++ ) { if( goods_catg_index[i]>2 ) { return true; } } return false; } */ // all true return true; }
31.504794
296
0.644547
lindleyw
66d886e7a1cf1bb3fa78dc1941c025f650a6dba9
13,762
cxx
C++
thirdparty/ConsoleDemoMod/ConsoleDemoMod.cxx
ph4m/DepthSenseGrabber
4a54ef0322a9221b8b89dc396cd980f496fe7563
[ "MIT" ]
27
2015-03-25T19:02:28.000Z
2021-11-23T03:57:31.000Z
thirdparty/ConsoleDemoMod/ConsoleDemoMod.cxx
ph4m/DepthSenseGrabber
4a54ef0322a9221b8b89dc396cd980f496fe7563
[ "MIT" ]
2
2015-01-04T13:07:17.000Z
2021-05-16T22:50:04.000Z
thirdparty/ConsoleDemoMod/ConsoleDemoMod.cxx
ph4m/DepthSenseGrabber
4a54ef0322a9221b8b89dc396cd980f496fe7563
[ "MIT" ]
18
2015-03-31T11:30:38.000Z
2020-01-29T21:28:35.000Z
//////////////////////////////////////////////////////////////////////////////// // SoftKinetic DepthSense SDK // // COPYRIGHT AND CONFIDENTIALITY NOTICE - SOFTKINETIC CONFIDENTIAL // INFORMATION // // All rights reserved to SOFTKINETIC SENSORS NV (a // company incorporated and existing under the laws of Belgium, with // its principal place of business at Boulevard de la Plainelaan 15, // 1050 Brussels (Belgium), registered with the Crossroads bank for // enterprises under company number 0811 341 454 - "Softkinetic // Sensors"). // // The source code of the SoftKinetic DepthSense Camera Drivers is // proprietary and confidential information of Softkinetic Sensors NV. // // For any question about terms and conditions, please contact: // info@softkinetic.com Copyright (c) 2002-2012 Softkinetic Sensors NV //////////////////////////////////////////////////////////////////////////////// // Some OpenCV mods added below for viewing and saving - Damian Lyons, dlyons@fordham.edu #ifdef _MSC_VER #include <windows.h> #endif #include <stdio.h> #include <time.h> #include <vector> #include <exception> #include "cv.h" #include "highgui.h" #include <DepthSense.hxx> using namespace DepthSense; using namespace std; // Open CV vars IplImage *g_depthImage=NULL, *g_videoImage=NULL; // initialized in main, used in CBs CvSize g_szDepth=cvSize(160,120), // QQVGA g_szVideo=cvSize(640,480); //VGA bool g_saveImageFlag=false, g_saveDepthFlag=false; Context g_context; DepthNode g_dnode; ColorNode g_cnode; AudioNode g_anode; uint32_t g_aFrames = 0; uint32_t g_cFrames = 0; uint32_t g_dFrames = 0; clock_t g_fTime; bool g_bDeviceFound = false; ProjectionHelper* g_pProjHelper = NULL; StereoCameraParameters g_scp; // From SoftKinetic // convert a YUY2 image to RGB void yuy2rgb(unsigned char *dst, const unsigned char *src, const int width, const int height) { int x, y; const int width2 = width * 2; const int width4 = width * 3; const unsigned char *src1 = src; unsigned char *dst1 = dst; for (y=0; y<height; y++) { for (x=0; x<width; x+=2) { int x2=x*2; int y1 = src1[x2 ]; int y2 = src1[x2+2]; int u = src1[x2+1] - 128; int v = src1[x2+3] - 128; int uvr = ( 15748 * v) / 10000; int uvg = (-1873 * u - 4681 * v) / 10000; int uvb = (18556 * u ) / 10000; int x4=x*3; int r1 = y1 + uvr; int r2 = y2 + uvr; int g1 = y1 + uvg; int g2 = y2 + uvg; int b1 = y1 + uvb; int b2 = y2 + uvb; dst1[x4+0] = (b1 > 255) ? 255 : ((b1 < 0) ? 0 : b1); dst1[x4+1] = (g1 > 255) ? 255 : ((g1 < 0) ? 0 : g1); dst1[x4+2] = (r1 > 255) ? 255 : ((r1 < 0) ? 0 : r1); //dst1[x4+3] = 255; dst1[x4+3] = (b2 > 255) ? 255 : ((b2 < 0) ? 0 : b2); dst1[x4+4] = (g2 > 255) ? 255 : ((g2 < 0) ? 0 : g2); dst1[x4+5] = (r2 > 255) ? 255 : ((r2 < 0) ? 0 : r2); } src1 += width2; dst1 += width4; } } /*----------------------------------------------------------------------------*/ // New audio sample event handler void onNewAudioSample(AudioNode node, AudioNode::NewSampleReceivedData data) { // printf("A#%u: %d\n",g_aFrames,data.audioData.size()); g_aFrames++; } /*----------------------------------------------------------------------------*/ // New color sample event handler /* Comments from SoftKinetic From data you can get ::DepthSense::Pointer< uint8_t > colorMap The color map. If captureConfiguration::compression is DepthSense::COMPRESSION_TYPE_MJPEG, the output format is BGR, otherwise the output format is YUY2. */ void onNewColorSample(ColorNode node, ColorNode::NewSampleReceivedData data) { //printf("C#%u: %d\n",g_cFrames,data.colorMap.size()); int32_t w, h; FrameFormat_toResolution(data.captureConfiguration.frameFormat,&w,&h); yuy2rgb((unsigned char *)g_videoImage->imageData,data.colorMap,w,h); g_cFrames++; } /*----------------------------------------------------------------------------*/ // New depth sample event handler /* From SoftKinetic ::DepthSense::Pointer< int16_t > depthMap The depth map in fixed point format. This map represents the cartesian depth of each pixel, expressed in millimeters. Valid values lies in the range [0 - 31999]. Saturated pixels are given the special value 32002. • ::DepthSense::Pointer< float > depthMapFloatingPoint The depth map in floating point format. This map represents the cartesian depth of each pixel, expressed in meters. Saturated pixels are given the special value -2.0. */ void onNewDepthSample(DepthNode node, DepthNode::NewSampleReceivedData data) { //printf("Z#%u: %d\n",g_dFrames,data.vertices.size()); int32_t w, h; FrameFormat_toResolution(data.captureConfiguration.frameFormat,&w,&h); int count=0; // DS data index if (data.depthMapFloatingPoint!=0)// just in case ! for (int i=0; i<h; i++) for (int j=0; j<w; j++) { // some arbitrary scaling to make this visible float val = data.depthMapFloatingPoint[count++]; if (!g_saveImageFlag && !g_saveDepthFlag) val*=150; if (val<0) val=255; // catch the saturated points cvSet2D(g_depthImage,i,j,cvScalar(val)); } g_dFrames++; /* // Quit the main loop after 200 depth frames received if (g_dFrames == 20) { printf("Quitting main loop after MAX frames\n"); g_context.quit(); } */ /* OpenCV display - this will slow stuff down, should be in thread*/ cvShowImage("Video",g_videoImage); cvShowImage("Depth",g_depthImage); if (g_saveImageFlag || g_saveDepthFlag) { // save a timestamped image pair; synched by depth image time char filename[100]; g_fTime = clock(); sprintf(filename,"df%d.%d.jpg",(int)(g_fTime/CLOCKS_PER_SEC), (int)(g_fTime%CLOCKS_PER_SEC)); cvSaveImage(filename,g_depthImage); sprintf(filename,"vf%d.%d.jpg",(int)(g_fTime/CLOCKS_PER_SEC), (int)(g_fTime%CLOCKS_PER_SEC)); if (g_saveImageFlag) cvSaveImage(filename,g_videoImage); } // Allow OpenCV to shut down the program char key = cvWaitKey(10); if (key==27) { printf("Quitting main loop from OpenCV\n"); g_context.quit(); } else if (key=='W') g_saveImageFlag = !g_saveImageFlag; else if (key=='w') g_saveDepthFlag = !g_saveDepthFlag; } /*----------------------------------------------------------------------------*/ void configureAudioNode() { g_anode.newSampleReceivedEvent().connect(&onNewAudioSample); AudioNode::Configuration config = g_anode.getConfiguration(); config.sampleRate = 44100; try { g_context.requestControl(g_anode,0); g_anode.setConfiguration(config); g_anode.setInputMixerLevel(0.5f); } catch (ArgumentException& e) { printf("Argument Exception: %s\n",e.what()); } catch (UnauthorizedAccessException& e) { printf("Unauthorized Access Exception: %s\n",e.what()); } catch (ConfigurationException& e) { printf("Configuration Exception: %s\n",e.what()); } catch (StreamingException& e) { printf("Streaming Exception: %s\n",e.what()); } catch (TimeoutException&) { printf("TimeoutException\n"); } } /*----------------------------------------------------------------------------*/ void configureDepthNode() { g_dnode.newSampleReceivedEvent().connect(&onNewDepthSample); DepthNode::Configuration config = g_dnode.getConfiguration(); config.frameFormat = FRAME_FORMAT_QQVGA; config.framerate = 60; config.mode = DepthNode::CAMERA_MODE_CLOSE_MODE; config.saturation = true; // g_dnode.setEnableVertices(true); g_dnode.setEnableDepthMapFloatingPoint(true); try { g_context.requestControl(g_dnode,0); g_dnode.setConfiguration(config); } catch (ArgumentException& e) { printf("DEPTH Argument Exception: %s\n",e.what()); } catch (UnauthorizedAccessException& e) { printf("DEPTH Unauthorized Access Exception: %s\n",e.what()); } catch (IOException& e) { printf("DEPTH IO Exception: %s\n",e.what()); } catch (InvalidOperationException& e) { printf("DEPTH Invalid Operation Exception: %s\n",e.what()); } catch (ConfigurationException& e) { printf("DEPTH Configuration Exception: %s\n",e.what()); } catch (StreamingException& e) { printf("DEPTH Streaming Exception: %s\n",e.what()); } catch (TimeoutException&) { printf("DEPTH TimeoutException\n"); } } /*----------------------------------------------------------------------------*/ void configureColorNode() { // connect new color sample handler g_cnode.newSampleReceivedEvent().connect(&onNewColorSample); ColorNode::Configuration config = g_cnode.getConfiguration(); config.frameFormat = FRAME_FORMAT_QQVGA; config.compression = COMPRESSION_TYPE_MJPEG; //config.powerLineFrequency = POWER_LINE_FREQUENCY_50HZ; //config.framerate = 25; g_cnode.setEnableColorMap(true); try { g_context.requestControl(g_cnode,0); g_cnode.setConfiguration(config); } catch (ArgumentException& e) { printf("COLOR Argument Exception: %s\n",e.what()); } catch (UnauthorizedAccessException& e) { printf("COLOR Unauthorized Access Exception: %s\n",e.what()); } catch (IOException& e) { printf("COLOR IO Exception: %s\n",e.what()); } catch (InvalidOperationException& e) { printf("COLOR Invalid Operation Exception: %s\n",e.what()); } catch (ConfigurationException& e) { printf("COLOR Configuration Exception: %s\n",e.what()); } catch (StreamingException& e) { printf("COLOR Streaming Exception: %s\n",e.what()); } catch (TimeoutException&) { printf("COLOR TimeoutException\n"); } } /*----------------------------------------------------------------------------*/ void configureNode(Node node) { if ((node.is<DepthNode>())&&(!g_dnode.isSet())) { g_dnode = node.as<DepthNode>(); configureDepthNode(); g_context.registerNode(node); } if ((node.is<ColorNode>())&&(!g_cnode.isSet())) { g_cnode = node.as<ColorNode>(); configureColorNode(); g_context.registerNode(node); } if ((node.is<AudioNode>())&&(!g_anode.isSet())) { g_anode = node.as<AudioNode>(); configureAudioNode(); g_context.registerNode(node); } } /*----------------------------------------------------------------------------*/ void onNodeConnected(Device device, Device::NodeAddedData data) { configureNode(data.node); } /*----------------------------------------------------------------------------*/ void onNodeDisconnected(Device device, Device::NodeRemovedData data) { if (data.node.is<AudioNode>() && (data.node.as<AudioNode>() == g_anode)) g_anode.unset(); if (data.node.is<ColorNode>() && (data.node.as<ColorNode>() == g_cnode)) g_cnode.unset(); if (data.node.is<DepthNode>() && (data.node.as<DepthNode>() == g_dnode)) g_dnode.unset(); printf("Node disconnected\n"); } /*----------------------------------------------------------------------------*/ void onDeviceConnected(Context context, Context::DeviceAddedData data) { if (!g_bDeviceFound) { data.device.nodeAddedEvent().connect(&onNodeConnected); data.device.nodeRemovedEvent().connect(&onNodeDisconnected); g_bDeviceFound = true; } } /*----------------------------------------------------------------------------*/ void onDeviceDisconnected(Context context, Context::DeviceRemovedData data) { g_bDeviceFound = false; printf("Device disconnected\n"); } /*----------------------------------------------------------------------------*/ int main(int argc, char* argv[]) { g_context = Context::create("localhost"); g_context.deviceAddedEvent().connect(&onDeviceConnected); g_context.deviceRemovedEvent().connect(&onDeviceDisconnected); // Get the list of currently connected devices vector<Device> da = g_context.getDevices(); // We are only interested in the first device if (da.size() >= 1) { g_bDeviceFound = true; da[0].nodeAddedEvent().connect(&onNodeConnected); da[0].nodeRemovedEvent().connect(&onNodeDisconnected); vector<Node> na = da[0].getNodes(); printf("Found %u nodes\n",na.size()); for (int n = 0; n < (int)na.size();n++) configureNode(na[n]); } /* Some OpenCV init; make windows and buffers to display the data */ // VGA format color image g_videoImage=cvCreateImage(g_szVideo,IPL_DEPTH_8U,3); if (g_videoImage==NULL) { printf("Unable to create video image buffer\n"); exit(0); } // QVGA format depth image g_depthImage=cvCreateImage(g_szDepth,IPL_DEPTH_8U,1); if (g_depthImage==NULL) { printf("Unable to create depth image buffer\n"); exit(0);} printf("dml@Fordham version of DS ConsoleDemo. June 2013.\n"); printf("Click onto in image for commands. ESC to exit.\n"); printf("Use \'W\' to toggle dumping of depth and visual images.\n"); printf("Use \'w\' to toggle dumping of depth images only.\n\n"); g_context.startNodes(); g_context.run(); g_context.stopNodes(); if (g_cnode.isSet()) g_context.unregisterNode(g_cnode); if (g_dnode.isSet()) g_context.unregisterNode(g_dnode); if (g_anode.isSet()) g_context.unregisterNode(g_anode); if (g_pProjHelper) delete g_pProjHelper; return 0; }
28.670833
107
0.59519
ph4m
66d8c90e0b7c4107814b87356c117caff234d421
3,306
cpp
C++
test/unit/math/mix/scal/fun/bessel_second_kind_test.cpp
jrmie/math
2850ec262181075a5843968e805dc9ad1654e069
[ "BSD-3-Clause" ]
1
2019-09-06T15:53:17.000Z
2019-09-06T15:53:17.000Z
test/unit/math/mix/scal/fun/bessel_second_kind_test.cpp
jrmie/math
2850ec262181075a5843968e805dc9ad1654e069
[ "BSD-3-Clause" ]
8
2019-01-17T18:51:16.000Z
2019-01-17T18:51:39.000Z
test/unit/math/mix/scal/fun/bessel_second_kind_test.cpp
jrmie/math
2850ec262181075a5843968e805dc9ad1654e069
[ "BSD-3-Clause" ]
null
null
null
#include <stan/math/mix/scal.hpp> #include <gtest/gtest.h> #include <test/unit/math/rev/scal/fun/util.hpp> #include <test/unit/math/mix/scal/fun/nan_util.hpp> TEST(AgradFwdBesselSecondKind, FvarVar_1stDeriv) { using stan::math::bessel_second_kind; using stan::math::fvar; using stan::math::var; fvar<var> z(3.0, 2.0); fvar<var> a = bessel_second_kind(1, z); EXPECT_FLOAT_EQ(bessel_second_kind(1, 3.0), a.val_.val()); EXPECT_FLOAT_EQ(0.53725040349771411, a.d_.val()); AVEC y = createAVEC(z.val_); VEC g; a.val_.grad(y, g); EXPECT_FLOAT_EQ(0.53725040349771411 / 2.0, g[0]); } TEST(AgradFwdBesselSecondKind, FvarVar_2ndDeriv) { using stan::math::bessel_second_kind; using stan::math::fvar; using stan::math::var; fvar<var> z(3.0, 2.0); fvar<var> a = bessel_second_kind(1, z); AVEC y = createAVEC(z.val_); VEC g; a.d_.grad(y, g); EXPECT_FLOAT_EQ(-0.75628245, g[0]); } TEST(AgradFwdBesselSecondKind, FvarFvarVar_1stDeriv) { using stan::math::bessel_second_kind; using stan::math::fvar; using stan::math::var; fvar<fvar<var> > y; y.val_.val_ = 3.0; y.d_.val_ = 2.0; fvar<fvar<var> > a = stan::math::bessel_second_kind(1, y); EXPECT_FLOAT_EQ(stan::math::bessel_second_kind(1, 3.0), a.val_.val_.val()); EXPECT_FLOAT_EQ(0, a.val_.d_.val()); EXPECT_FLOAT_EQ(0.53725040349771411, a.d_.val_.val()); EXPECT_FLOAT_EQ(0, a.d_.d_.val()); AVEC p = createAVEC(y.val_.val_); VEC g; a.val_.val_.grad(p, g); EXPECT_FLOAT_EQ(0.53725040349771411 / 2.0, g[0]); fvar<fvar<var> > x; x.val_.val_ = 3.0; x.val_.d_ = 2.0; fvar<fvar<var> > b = stan::math::bessel_second_kind(1, x); EXPECT_FLOAT_EQ(stan::math::bessel_second_kind(1, 3.0), b.val_.val_.val()); EXPECT_FLOAT_EQ(0.53725040349771411, b.val_.d_.val()); EXPECT_FLOAT_EQ(0, b.d_.val_.val()); EXPECT_FLOAT_EQ(0, b.d_.d_.val()); AVEC q = createAVEC(x.val_.val_); VEC r; b.val_.val_.grad(q, r); EXPECT_FLOAT_EQ(0.53725040349771411 / 2.0, r[0]); } TEST(AgradFwdBesselSecondKind, FvarFvarVar_2ndDeriv) { using stan::math::bessel_second_kind; using stan::math::fvar; using stan::math::var; fvar<fvar<var> > y; y.val_.val_ = 3.0; y.d_.val_ = 2.0; fvar<fvar<var> > a = stan::math::bessel_second_kind(1, y); AVEC p = createAVEC(y.val_.val_); VEC g; a.d_.val_.grad(p, g); EXPECT_FLOAT_EQ(-0.75628245, g[0]); fvar<fvar<var> > x; x.val_.val_ = 3.0; x.val_.d_ = 2.0; fvar<fvar<var> > b = stan::math::bessel_second_kind(1, x); AVEC q = createAVEC(x.val_.val_); VEC r; b.val_.d_.grad(q, r); EXPECT_FLOAT_EQ(-0.75628245, r[0]); } TEST(AgradFwdBesselSecondKind, FvarFvarVar_3rdDeriv) { using stan::math::bessel_second_kind; using stan::math::fvar; using stan::math::var; fvar<fvar<var> > y; y.val_.val_ = 3.0; y.d_.val_ = 1.0; y.val_.d_ = 1.0; fvar<fvar<var> > a = stan::math::bessel_second_kind(1, y); AVEC p = createAVEC(y.val_.val_); VEC g; a.d_.d_.grad(p, g); EXPECT_FLOAT_EQ(-0.1069335956566158198, g[0]); } struct bessel_second_kind_fun { template <typename T0> inline T0 operator()(const T0& arg1) const { return bessel_second_kind(1, arg1); } }; TEST(AgradFwdBesselSecondKind, bessel_second_kind_NaN) { bessel_second_kind_fun bessel_second_kind_; test_nan_mix(bessel_second_kind_, false); }
25.627907
77
0.676346
jrmie
66dd2acc37aff7b61297334204ac1c67bbfb8397
3,933
cpp
C++
source/netadr.cpp
vindemiator/gm_sourcenet
5c0e48899d3be833fdb5cd03b2545a685d01d749
[ "BSD-3-Clause" ]
62
2016-02-02T01:38:31.000Z
2022-02-08T05:36:40.000Z
source/netadr.cpp
vindemiator/gm_sourcenet
5c0e48899d3be833fdb5cd03b2545a685d01d749
[ "BSD-3-Clause" ]
39
2016-09-16T13:01:48.000Z
2022-01-16T16:53:28.000Z
source/netadr.cpp
vindemiator/gm_sourcenet
5c0e48899d3be833fdb5cd03b2545a685d01d749
[ "BSD-3-Clause" ]
23
2016-05-14T11:20:06.000Z
2022-03-27T01:33:42.000Z
#include "netadr.hpp" #include "netadr.h" namespace netadr { static int32_t metatype = 0; static const char *metaname = "netadr_t"; void Push( GarrysMod::Lua::ILuaBase *LUA, const netadr_t &netadr ) { netadr_t *adr = LUA->NewUserType<netadr_t>( metatype ); *adr = netadr; LUA->PushMetaTable( metatype ); LUA->SetMetaTable( -2 ); LUA->CreateTable( ); LUA->SetFEnv( -2 ); } static netadr_t *Get( GarrysMod::Lua::ILuaBase *LUA, int32_t index ) { global::CheckType( LUA, index, metatype, metaname ); return LUA->GetUserType<netadr_t>( index, metatype ); } LUA_FUNCTION_STATIC( gc ) { LUA->SetUserType( 1, nullptr ); return 0; } LUA_FUNCTION_STATIC( eq ) { netadr_t *adr1 = Get( LUA, 1 ); netadr_t *adr2 = Get( LUA, 2 ); bool baseonly = false; if( LUA->IsType( 3, GarrysMod::Lua::Type::BOOL ) ) baseonly = LUA->GetBool( 3 ); LUA->PushBool( adr1->CompareAdr( *adr2, baseonly ) ); return 1; } LUA_FUNCTION_STATIC( tostring ) { netadr_t *adr = Get( LUA, 1 ); bool baseonly = false; if( LUA->IsType( 2, GarrysMod::Lua::Type::BOOL ) ) baseonly = LUA->GetBool( 2 ); LUA->PushString( adr->ToString( baseonly ) ); return 1; } LUA_FUNCTION_STATIC( IsLocalhost ) { netadr_t *adr = Get( LUA, 1 ); LUA->PushBool( adr->IsLocalhost( ) ); return 1; } LUA_FUNCTION_STATIC( IsLoopback ) { netadr_t *adr = Get( LUA, 1 ); LUA->PushBool( adr->IsLoopback( ) ); return 1; } LUA_FUNCTION_STATIC( IsReservedAdr ) { netadr_t *adr = Get( LUA, 1 ); LUA->PushBool( adr->IsReservedAdr( ) ); return 1; } LUA_FUNCTION_STATIC( IsValid ) { netadr_t *adr = Get( LUA, 1 ); LUA->PushBool( adr->IsValid( ) ); return 1; } LUA_FUNCTION_STATIC( GetIP ) { netadr_t *adr = Get( LUA, 1 ); LUA->PushString( adr->ToString( true ) ); LUA->PushNumber( adr->GetIPHostByteOrder( ) ); return 2; } LUA_FUNCTION_STATIC( GetPort ) { netadr_t *adr = Get( LUA, 1 ); LUA->PushNumber( adr->GetPort( ) ); return 1; } LUA_FUNCTION_STATIC( GetSteamID ) { netadr_t *adr = Get( LUA, 1 ); const CSteamID &steamID = adr->GetSteamID( ); EAccountType type = steamID.GetEAccountType( ); if( type == k_EAccountTypeInvalid || type == k_EAccountTypeIndividual ) { AccountID_t accountID = steamID.GetAccountID( ); LUA->PushFormattedString( "STEAM_0:%u:%u", accountID % 2, accountID / 2 ); } else LUA->PushFormattedString( "%llu", steamID.ConvertToUint64( ) ); return 1; } LUA_FUNCTION_STATIC( GetType ) { netadr_t *adr = Get( LUA, 1 ); LUA->PushNumber( adr->GetType( ) ); return 1; } void Initialize( GarrysMod::Lua::ILuaBase *LUA ) { metatype = LUA->CreateMetaTable( metaname ); LUA->PushCFunction( gc ); LUA->SetField( -2, "__gc" ); LUA->PushCFunction( eq ); LUA->SetField( -2, "__eq" ); LUA->PushCFunction( tostring ); LUA->SetField( -2, "__tostring" ); LUA->PushCFunction( global::index ); LUA->SetField( -2, "__index" ); LUA->PushCFunction( global::newindex ); LUA->SetField( -2, "__newindex" ); LUA->PushCFunction( tostring ); LUA->SetField( -2, "ToString" ); LUA->PushCFunction( global::GetTable ); LUA->SetField( -2, "GetTable" ); LUA->PushCFunction( IsLocalhost ); LUA->SetField( -2, "IsLocalhost" ); LUA->PushCFunction( IsLoopback ); LUA->SetField( -2, "IsLoopback" ); LUA->PushCFunction( IsReservedAdr ); LUA->SetField( -2, "IsReservedAdr" ); LUA->PushCFunction( IsValid ); LUA->SetField( -2, "IsValid" ); LUA->PushCFunction( GetIP ); LUA->SetField( -2, "GetIP" ); LUA->PushCFunction( GetPort ); LUA->SetField( -2, "GetPort" ); LUA->PushCFunction( GetSteamID ); LUA->SetField( -2, "GetSteamID" ); LUA->PushCFunction( GetType ); LUA->SetField( -2, "GetType" ); LUA->Pop( 1 ); } void Deinitialize( GarrysMod::Lua::ILuaBase *LUA ) { LUA->PushNil( ); LUA->SetField( GarrysMod::Lua::INDEX_REGISTRY, metaname ); } }
19.763819
77
0.636664
vindemiator
66df77d11dc300ae7b0ffbab6d6704c8db606ddc
101,210
cpp
C++
Engine/source/assets/assetManager.cpp
John3/t3d_benchmarking
27a5780ad704aa91b45ff1bb0d69ed07668d03be
[ "MIT" ]
10
2015-03-12T20:20:34.000Z
2021-02-03T08:07:31.000Z
Engine/source/assets/assetManager.cpp
John3/t3d_benchmarking
27a5780ad704aa91b45ff1bb0d69ed07668d03be
[ "MIT" ]
3
2015-07-04T23:50:43.000Z
2016-08-01T09:19:52.000Z
Engine/source/assets/assetManager.cpp
John3/t3d_benchmarking
27a5780ad704aa91b45ff1bb0d69ed07668d03be
[ "MIT" ]
6
2015-11-28T16:18:26.000Z
2020-03-29T17:14:56.000Z
//----------------------------------------------------------------------------- // Copyright (c) 2013 GarageGames, LLC // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. //----------------------------------------------------------------------------- #include "assetManager.h" #ifndef _ASSET_PTR_H_ #include "assetPtr.h" #endif #ifndef _REFERENCED_ASSETS_H_ #include "assets/referencedAssets.h" #endif #ifndef _DECLARED_ASSETS_H_ #include "assets/declaredAssets.h" #endif #ifndef _TAML_ASSET_REFERENCED_VISITOR_H_ #include "tamlAssetReferencedVisitor.h" #endif #ifndef _TAML_ASSET_DECLARED_VISITOR_H_ #include "tamlAssetDeclaredVisitor.h" #endif #ifndef _TAML_ASSET_DECLARED_UPDATE_VISITOR_H_ #include "tamlAssetDeclaredUpdateVisitor.h" #endif #ifndef _TAML_ASSET_REFERENCED_UPDATE_VISITOR_H_ #include "tamlAssetReferencedUpdateVisitor.h" #endif #ifndef _CONSOLETYPES_H_ #include "console/consoleTypes.h" #endif // Script bindings. #include "assetManager_ScriptBinding.h" //----------------------------------------------------------------------------- IMPLEMENT_CONOBJECT( AssetManager ); //----------------------------------------------------------------------------- AssetManager AssetDatabase; //----------------------------------------------------------------------------- AssetManager::AssetManager() : mLoadedInternalAssetsCount( 0 ), mLoadedExternalAssetsCount( 0 ), mLoadedPrivateAssetsCount( 0 ), mMaxLoadedInternalAssetsCount( 0 ), mMaxLoadedExternalAssetsCount( 0 ), mMaxLoadedPrivateAssetsCount( 0 ), mAcquiredReferenceCount( 0 ), mEchoInfo( false ), mIgnoreAutoUnload( true ) { } //----------------------------------------------------------------------------- bool AssetManager::onAdd() { // Call parent. if ( !Parent::onAdd() ) return false; return true; } //----------------------------------------------------------------------------- void AssetManager::onRemove() { // Do we have an asset tags manifest? if ( !mAssetTagsManifest.isNull() ) { // Yes, so remove it. mAssetTagsManifest->deleteObject(); } // Call parent. Parent::onRemove(); } //----------------------------------------------------------------------------- void AssetManager::initPersistFields() { // Call parent. Parent::initPersistFields(); addField( "EchoInfo", TypeBool, Offset(mEchoInfo, AssetManager), "Whether the asset manager echos extra information to the console or not." ); addField( "IgnoreAutoUnload", TypeBool, Offset(mIgnoreAutoUnload, AssetManager), "Whether the asset manager should ignore unloading of auto-unload assets or not." ); } //----------------------------------------------------------------------------- bool AssetManager::compileReferencedAssets( ModuleDefinition* pModuleDefinition ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_CompileReferencedAsset); // Sanity! AssertFatal( pModuleDefinition != NULL, "Cannot add declared assets using a NULL module definition" ); // Clear referenced assets. mReferencedAssets.clear(); // Iterate the module definition children. for( SimSet::iterator itr = pModuleDefinition->begin(); itr != pModuleDefinition->end(); ++itr ) { // Fetch the referenced assets. ReferencedAssets* pReferencedAssets = dynamic_cast<ReferencedAssets*>( *itr ); // Skip if it's not a referenced assets location. if ( pReferencedAssets == NULL ) continue; // Expand asset manifest location. char filePathBuffer[1024]; dSprintf( filePathBuffer, sizeof(filePathBuffer), "%s/%s", pModuleDefinition->getModulePath(), pReferencedAssets->getPath() ); // Scan referenced assets at location. if ( !scanReferencedAssets( filePathBuffer, pReferencedAssets->getExtension(), pReferencedAssets->getRecurse() ) ) { // Warn. Con::warnf( "AssetManager::compileReferencedAssets() - Could not scan for referenced assets at location '%s' with extension '%s'.", filePathBuffer, pReferencedAssets->getExtension() ); } } return true; } //----------------------------------------------------------------------------- bool AssetManager::addModuleDeclaredAssets( ModuleDefinition* pModuleDefinition ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_AddDeclaredAssets); // Sanity! AssertFatal( pModuleDefinition != NULL, "Cannot add declared assets using a NULL module definition" ); // Does the module have any assets associated with it? if ( pModuleDefinition->getModuleAssets().size() > 0 ) { // Yes, so warn. Con::warnf( "Asset Manager: Cannot add declared assets to module '%s' as it already has existing assets.", pModuleDefinition->getSignature() ); return false; } // Iterate the module definition children. for( SimSet::iterator itr = pModuleDefinition->begin(); itr != pModuleDefinition->end(); ++itr ) { // Fetch the declared assets. DeclaredAssets* pDeclaredAssets = dynamic_cast<DeclaredAssets*>( *itr ); // Skip if it's not a declared assets location. if ( pDeclaredAssets == NULL ) continue; // Expand asset manifest location. char filePathBuffer[1024]; String mdldfpth = pModuleDefinition->getModulePath(); String astfpth = pDeclaredAssets->getPath(); //dSprintf( filePathBuffer, sizeof(filePathBuffer), "%s/%s", pModuleDefinition->getModulePath(), pDeclaredAssets->getPath() ); dSprintf(filePathBuffer, sizeof(filePathBuffer), "%s/%s", pModuleDefinition->getModulePath(), pDeclaredAssets->getPath()); // Scan declared assets at location. if ( !scanDeclaredAssets( filePathBuffer, pDeclaredAssets->getExtension(), pDeclaredAssets->getRecurse(), pModuleDefinition ) ) { // Warn. Con::warnf( "AssetManager::addModuleDeclaredAssets() - Could not scan for declared assets at location '%s' with extension '%s'.", filePathBuffer, pDeclaredAssets->getExtension() ); } } return true; } //----------------------------------------------------------------------------- bool AssetManager::addDeclaredAsset( ModuleDefinition* pModuleDefinition, const char* pAssetFilePath ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_AddSingleDeclaredAsset); // Sanity! AssertFatal( pModuleDefinition != NULL, "Cannot add single declared asset using a NULL module definition" ); AssertFatal( pAssetFilePath != NULL, "Cannot add single declared asset using a NULL asset file-path." ); // Expand asset file-path. char assetFilePathBuffer[1024]; Con::expandPath( assetFilePathBuffer, sizeof(assetFilePathBuffer), pAssetFilePath ); // Find the final slash which should be just before the file. char* pFileStart = dStrrchr( assetFilePathBuffer, '/' ); // Did we find the final slash? if ( pFileStart == NULL ) { // No, so warn. Con::warnf( "AssetManager::addDeclaredAsset() - Could not add single declared asset file '%s' as file-path '%s' is not valid.", assetFilePathBuffer, pModuleDefinition->getModulePath() ); return false; } // Terminate path at slash. *pFileStart = 0; // Move to next character which should be the file start. pFileStart++; // Scan declared assets at location. if ( !scanDeclaredAssets( assetFilePathBuffer, pFileStart, false, pModuleDefinition ) ) { // Warn. Con::warnf( "AssetManager::addDeclaredAsset() - Could not scan declared assets at location '%s' with extension '%s'.", assetFilePathBuffer, pFileStart ); return false; } return true; } //----------------------------------------------------------------------------- StringTableEntry AssetManager::addPrivateAsset( AssetBase* pAssetBase ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_AddPrivateAsset); // Sanity! AssertFatal( pAssetBase != NULL, "Cannot add a NULL private asset." ); // Is the asset already added? if (pAssetBase->mpAssetDefinition->mAssetId != StringTable->EmptyString()) { // Yes, so warn. Con::warnf( "Cannot add private asset '%d' as it has already been assigned.", pAssetBase->mpAssetDefinition->mAssetId ); return StringTable->EmptyString(); } static U32 masterPrivateAssetId = 1; // Create asset definition. AssetDefinition* pAssetDefinition = new AssetDefinition(); // Fetch source asset definition. AssetDefinition* pSourceAssetDefinition = pAssetBase->mpAssetDefinition; // Configure asset. pAssetDefinition->mpAssetBase = pAssetBase; pAssetDefinition->mAssetDescription = pSourceAssetDefinition->mAssetDescription; pAssetDefinition->mAssetCategory = pSourceAssetDefinition->mAssetCategory; pAssetDefinition->mAssetAutoUnload = true; pAssetDefinition->mAssetRefreshEnable = false; pAssetDefinition->mAssetType = StringTable->insert( pAssetBase->getClassName() ); pAssetDefinition->mAssetLoadedCount = 0; pAssetDefinition->mAssetInternal = false; pAssetDefinition->mAssetPrivate = true; // Format asset name. char assetNameBuffer[256]; dSprintf(assetNameBuffer, sizeof(assetNameBuffer), "%s_%d", pAssetDefinition->mAssetType, masterPrivateAssetId++ ); // Set asset identity. pAssetDefinition->mAssetName = StringTable->insert( assetNameBuffer ); pAssetDefinition->mAssetId = pAssetDefinition->mAssetName; // Ensure that the source asset is fully synchronized with the new asset definition. pSourceAssetDefinition->mAssetName = pAssetDefinition->mAssetName; pSourceAssetDefinition->mAssetAutoUnload = pAssetDefinition->mAssetAutoUnload; pSourceAssetDefinition->mAssetInternal = pAssetDefinition->mAssetInternal; // Set ownership by asset manager. pAssetDefinition->mpAssetBase->setOwned( this, pAssetDefinition ); // Store in declared assets. mDeclaredAssets.insert( pAssetDefinition->mAssetId, pAssetDefinition ); // Increase the private loaded asset count. if ( ++mLoadedPrivateAssetsCount > mMaxLoadedPrivateAssetsCount ) mMaxLoadedPrivateAssetsCount = mLoadedPrivateAssetsCount; return pAssetDefinition->mAssetId; } //----------------------------------------------------------------------------- bool AssetManager::removeDeclaredAssets( ModuleDefinition* pModuleDefinition ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RemoveDeclaredAssets); // Sanity! AssertFatal( pModuleDefinition != NULL, "Cannot remove declared assets using a NULL module definition" ); // Fetch module assets. ModuleDefinition::typeModuleAssetsVector& moduleAssets = pModuleDefinition->getModuleAssets(); // Remove all module assets. while ( moduleAssets.size() > 0 ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = *moduleAssets.begin(); // Remove this asset. removeDeclaredAsset( pAssetDefinition->mAssetId ); } // Info. if ( mEchoInfo ) Con::printSeparator(); return true; } //----------------------------------------------------------------------------- bool AssetManager::removeDeclaredAsset( const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RemoveSingleDeclaredAsset); // Sanity! AssertFatal( pAssetId != NULL, "Cannot remove single declared asset using NULL asset Id." ); // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Find declared asset. typeDeclaredAssetsHash::iterator declaredAssetItr = mDeclaredAssets.find( assetId ); // Did we find the declared asset? if ( declaredAssetItr == mDeclaredAssets.end() ) { // No, so warn. Con::warnf( "Asset Manager: Cannot remove single asset Id '%s' it could not be found.", assetId ); return false; } // Fetch asset definition. AssetDefinition* pAssetDefinition = declaredAssetItr->value; // Is the asset private? if ( !pAssetDefinition->mAssetPrivate ) { // No, so fetch module assets. ModuleDefinition::typeModuleAssetsVector& moduleAssets = pAssetDefinition->mpModuleDefinition->getModuleAssets(); // Remove module asset. for ( ModuleDefinition::typeModuleAssetsVector::iterator moduleAssetItr = moduleAssets.begin(); moduleAssetItr != moduleAssets.end(); ++moduleAssetItr ) { if ( *moduleAssetItr == pAssetDefinition ) { moduleAssets.erase( moduleAssetItr ); break; } } // Remove asset dependencies. removeAssetDependencies( pAssetId ); } // Do we have an asset loaded? if ( pAssetDefinition->mpAssetBase != NULL ) { // Yes, so delete it. // NOTE: If anything is using this then this'll cause a crash. Objects should always use safe reference methods however. pAssetDefinition->mpAssetBase->deleteObject(); } // Remove from declared assets. mDeclaredAssets.erase( declaredAssetItr ); // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Removing Asset Id '%s' of type '%s' in asset file '%s'.", pAssetDefinition->mAssetId, pAssetDefinition->mAssetType, pAssetDefinition->mAssetBaseFilePath ); } // Destroy asset definition. delete pAssetDefinition; return true; } //----------------------------------------------------------------------------- StringTableEntry AssetManager::getAssetName( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return NULL; } return pAssetDefinition->mAssetName; } //----------------------------------------------------------------------------- StringTableEntry AssetManager::getAssetDescription( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return NULL; } return pAssetDefinition->mAssetDescription; } //----------------------------------------------------------------------------- StringTableEntry AssetManager::getAssetCategory( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return NULL; } return pAssetDefinition->mAssetCategory; } //----------------------------------------------------------------------------- StringTableEntry AssetManager::getAssetType( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return NULL; } return pAssetDefinition->mAssetType; } //----------------------------------------------------------------------------- StringTableEntry AssetManager::getAssetFilePath( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return StringTable->EmptyString(); } return pAssetDefinition->mAssetBaseFilePath; } //----------------------------------------------------------------------------- StringTableEntry AssetManager::getAssetPath( const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_GetAssetPath); // Fetch asset file-path. StringTableEntry assetFilePath = getAssetFilePath( pAssetId ); // Finish if no file-path. if ( assetFilePath == StringTable->EmptyString() ) return assetFilePath; // Find the final slash which should be just before the file. const char* pFinalSlash = dStrrchr( assetFilePath, '/' ); // Sanity! AssertFatal( pFinalSlash != NULL, "Should always be able to find final slash in the asset file-path." ); // Fetch asset path. return StringTable->insertn( assetFilePath, (U32)(pFinalSlash - assetFilePath) ); } //----------------------------------------------------------------------------- ModuleDefinition* AssetManager::getAssetModuleDefinition( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return NULL; } return pAssetDefinition->mpModuleDefinition; } //----------------------------------------------------------------------------- bool AssetManager::isAssetInternal( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return false; } return pAssetDefinition->mAssetInternal; } //----------------------------------------------------------------------------- bool AssetManager::isAssetPrivate( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return false; } return pAssetDefinition->mAssetPrivate; } //----------------------------------------------------------------------------- bool AssetManager::isAssetAutoUnload( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return false; } return pAssetDefinition->mAssetAutoUnload; } //----------------------------------------------------------------------------- bool AssetManager::isAssetLoaded( const char* pAssetId ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find asset Id '%s'.", pAssetId ); return false; } return pAssetDefinition->mpAssetBase != NULL; } //----------------------------------------------------------------------------- bool AssetManager::isDeclaredAsset( const char* pAssetId ) { return findAsset( pAssetId ) != NULL; } //----------------------------------------------------------------------------- bool AssetManager::doesAssetDependOn( const char* pAssetId, const char* pDependsOnAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_DoesAssetDependOn); // Sanity! AssertFatal( pAssetId != NULL, "Cannot use NULL asset Id." ); AssertFatal( pDependsOnAssetId != NULL, "Cannot use NULL depends-on asset Id." ); // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Fetch depends-on asset Id. StringTableEntry dependsOnAssetId = StringTable->insert( pDependsOnAssetId ); // Find depends-on entry. typeAssetDependsOnHash::Iterator dependsOnItr = mAssetDependsOn.find( assetId ); // Iterate all dependencies. while( dependsOnItr != mAssetDependsOn.end() && dependsOnItr->key == assetId ) { // Finish if a depends on. if ( dependsOnItr->value == dependsOnAssetId ) return true; // Next dependency. dependsOnItr++; } return false; } //----------------------------------------------------------------------------- bool AssetManager::isAssetDependedOn( const char* pAssetId, const char* pDependedOnByAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_IsAssetDependedOn); // Sanity! AssertFatal( pAssetId != NULL, "Cannot use NULL asset Id." ); AssertFatal( pDependedOnByAssetId != NULL, "Cannot use NULL depended-on-by asset Id." ); // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Fetch depended-on-by asset Id. StringTableEntry dependedOnByAssetId = StringTable->insert( pDependedOnByAssetId ); // Find depended-on-by entry. typeAssetDependsOnHash::Iterator dependedOnItr = mAssetIsDependedOn.find(assetId); // Iterate all dependencies. while( dependedOnItr != mAssetIsDependedOn.end() && dependedOnItr->key == assetId ) { // Finish if depended-on. if ( dependedOnItr->value == dependedOnByAssetId ) return true; // Next dependency. dependedOnItr++; } return false; } //----------------------------------------------------------------------------- bool AssetManager::isReferencedAsset( const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_IsReferencedAsset); // Sanity! AssertFatal( pAssetId != NULL, "Cannot check if NULL asset Id is referenced." ); // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Is asset Id the correct format? if ( StringUnit::getUnitCount( assetId, ASSET_SCOPE_TOKEN ) != 2 ) { // No, so warn. Con::warnf( "Asset Manager: Cannot check if asset Id '%s' is referenced as it is not the correct format.", assetId ); return false; } return mReferencedAssets.count( assetId ) > 0; } //----------------------------------------------------------------------------- bool AssetManager::renameDeclaredAsset( const char* pAssetIdFrom, const char* pAssetIdTo ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RenameDeclaredAsset); // Sanity! AssertFatal( pAssetIdFrom != NULL, "Cannot rename from NULL asset Id." ); AssertFatal( pAssetIdTo != NULL, "Cannot rename to NULL asset Id." ); // Fetch asset Ids. StringTableEntry assetIdFrom = StringTable->insert( pAssetIdFrom ); StringTableEntry assetIdTo = StringTable->insert( pAssetIdTo ); // Is asset Id from the correct format? if ( StringUnit::getUnitCount( assetIdFrom, ASSET_SCOPE_TOKEN ) != 2 ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename declared asset Id '%s' to asset Id '%s' as source asset Id is not the correct format.", assetIdFrom, assetIdTo ); return false; } // Is asset Id to the correct format? if ( StringUnit::getUnitCount( assetIdTo, ASSET_SCOPE_TOKEN ) != 2 ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename declared asset Id '%s' to asset Id '%s' as target asset Id is not the correct format.", assetIdFrom, assetIdTo ); return false; } // Does the asset Id from exist? if ( !mDeclaredAssets.contains( assetIdFrom ) ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename declared asset Id '%s' to asset Id '%s' as source asset Id is not declared.", assetIdFrom, assetIdTo ); return false; } // Does the asset Id to exist? if ( mDeclaredAssets.contains( assetIdTo ) ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename declared asset Id '%s' to asset Id '%s' as target asset Id is already declared.", assetIdFrom, assetIdTo ); return false; } // Split module Ids from asset Ids. StringTableEntry moduleIdFrom = StringTable->insert( StringUnit::getUnit( assetIdFrom, 0, ASSET_SCOPE_TOKEN ) ); StringTableEntry moduleIdTo = StringTable->insert( StringUnit::getUnit( assetIdTo, 0, ASSET_SCOPE_TOKEN ) ); // Are the module Ids the same? if ( moduleIdFrom != moduleIdTo ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename declared asset Id '%s' to asset Id '%s' as the module Id cannot be changed.", assetIdFrom, assetIdTo ); return false; } // Find asset definition. typeDeclaredAssetsHash::iterator assetDefinitionItr = mDeclaredAssets.find( assetIdFrom ); // Sanity! AssertFatal( assetDefinitionItr != mDeclaredAssets.end(), "Asset Manager: Failed to find asset." ); // Fetch asset definition. AssetDefinition* pAssetDefinition = assetDefinitionItr->value; // Is this a private asset? if ( pAssetDefinition->mAssetPrivate ) { // Yes, so warn. Con::warnf("Asset Manager: Cannot rename declared asset Id '%s' to asset Id '%s' as the source asset is private.", assetIdFrom, assetIdTo ); return false; } // Setup declared update visitor. TamlAssetDeclaredUpdateVisitor assetDeclaredUpdateVisitor; assetDeclaredUpdateVisitor.setAssetIdFrom( assetIdFrom ); assetDeclaredUpdateVisitor.setAssetIdTo( assetIdTo ); // Update asset file declaration. if ( !mTaml.parse( pAssetDefinition->mAssetBaseFilePath, assetDeclaredUpdateVisitor ) ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename declared asset Id '%s' to asset Id '%s' as the declared asset file could not be parsed: %s", assetIdFrom, assetIdTo, pAssetDefinition->mAssetBaseFilePath ); return false; } // Update asset definition. pAssetDefinition->mAssetId = assetIdTo; pAssetDefinition->mAssetName = StringTable->insert( StringUnit::getUnit( assetIdTo, 1, ASSET_SCOPE_TOKEN ) ); // Reinsert declared asset. mDeclaredAssets.erase( assetIdFrom ); mDeclaredAssets.insert( assetIdTo, pAssetDefinition ); // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Renaming declared Asset Id '%s' to Asset Id '%s'.", assetIdFrom, assetIdTo ); Con::printSeparator(); } // Rename asset dependencies. renameAssetDependencies( assetIdFrom, assetIdTo ); // Do we have an asset tags manifest? if ( !mAssetTagsManifest.isNull() ) { // Yes, so rename any assets. mAssetTagsManifest->renameAssetId( pAssetIdFrom, pAssetIdTo ); // Save the asset tags. saveAssetTags(); } return true; } //----------------------------------------------------------------------------- bool AssetManager::renameReferencedAsset( const char* pAssetIdFrom, const char* pAssetIdTo ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RenameReferencedAsset); // Sanity! AssertFatal( pAssetIdFrom != NULL, "Cannot rename from NULL asset Id." ); AssertFatal( pAssetIdTo != NULL, "Cannot rename to NULL asset Id." ); // Fetch asset Ids. StringTableEntry assetIdFrom = StringTable->insert( pAssetIdFrom ); StringTableEntry assetIdTo = StringTable->insert( pAssetIdTo ); // Is asset Id from the correct format? if ( StringUnit::getUnitCount( assetIdFrom, ASSET_SCOPE_TOKEN ) != 2 ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename referenced asset Id '%s' to asset Id '%s' as source asset Id is not the correct format.", assetIdFrom, assetIdTo ); return false; } // Is asset Id to the correct format? if ( StringUnit::getUnitCount( assetIdTo, ASSET_SCOPE_TOKEN ) != 2 ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename referenced asset Id '%s' to asset Id '%s' as target asset Id is not the correct format.", assetIdFrom, assetIdTo ); return false; } // Does the asset Id to exist? if ( !mDeclaredAssets.contains( assetIdTo ) ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename referenced asset Id '%s' to asset Id '%s' as target asset Id is not declared.", assetIdFrom, assetIdTo ); return false; } // Rename asset references. renameAssetReferences( assetIdFrom, assetIdTo ); // Info. if ( mEchoInfo ) Con::printSeparator(); return true; } //----------------------------------------------------------------------------- bool AssetManager::releaseAsset( const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_ReleaseAsset); // Sanity! AssertFatal( pAssetId != NULL, "Cannot release NULL asset Id." ); // Find asset. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Failed to release asset Id '%s' as it does not exist.", pAssetId ); return false; } // Is the asset loaded? if ( pAssetDefinition->mpAssetBase == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Failed to release asset Id '%s' as it is not acquired.", pAssetId ); return false; } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Started releasing Asset Id '%s'...", pAssetId ); } // Release asset reference. if ( pAssetDefinition->mpAssetBase->releaseAssetReference() ) { // Are we ignoring auto-unloaded assets? if ( mIgnoreAutoUnload ) { // Yes, so info. if ( mEchoInfo ) { Con::printf( "Asset Manager: > Releasing to idle state." ); } } else { // No, so info. if ( mEchoInfo ) { Con::printf( "Asset Manager: > Unload the asset from memory." ); } // Unload the asset. unloadAsset( pAssetDefinition ); } } // Info. else if ( mEchoInfo ) { Con::printf( "Asset Manager: > Reference count now '%d'.", pAssetDefinition->mpAssetBase->getAcquiredReferenceCount() ); } // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: > Finished releasing Asset Id '%s'.", pAssetId ); Con::printSeparator(); } return true; } //----------------------------------------------------------------------------- void AssetManager::purgeAssets( void ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_PurgeAssets); // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Started purging assets..." ); } // Iterate asset definitions. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Skip asset if private, not loaded or referenced. if ( pAssetDefinition->mAssetPrivate || pAssetDefinition->mpAssetBase == NULL || pAssetDefinition->mpAssetBase->getAcquiredReferenceCount() > 0 ) continue; // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Purging asset Id '%s'...", pAssetDefinition->mAssetId ); } // Unload the asset. unloadAsset( pAssetDefinition ); } // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: ... Finished purging assets." ); } } //----------------------------------------------------------------------------- bool AssetManager::deleteAsset( const char* pAssetId, const bool deleteLooseFiles, const bool deleteDependencies ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_DeleteAsset); // Sanity! AssertFatal( pAssetId != NULL, "Cannot delete NULL asset Id." ); // Find asset. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Failed to delete asset Id '%s' as it does not exist.", pAssetId ); return false; } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Started deleting Asset Id '%s'...", pAssetId ); } // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Are we deleting dependencies? if ( deleteDependencies ) { Vector<typeAssetId> dependantAssets; // Yes, so find depended-on-by entry. typeAssetDependsOnHash::Iterator dependedOnItr = mAssetIsDependedOn.find( assetId ); // Iterate all dependencies. while( dependedOnItr != mAssetIsDependedOn.end() && dependedOnItr->key == assetId ) { // Store asset Id. dependantAssets.push_back( dependedOnItr->value ); // Next dependency. dependedOnItr++; } // Do we have any dependants? if ( dependantAssets.size() > 0 ) { // Yes, so iterate dependants. for( Vector<typeAssetId>::const_iterator assetItr = dependantAssets.begin(); assetItr != dependantAssets.end(); ++assetItr ) { StringTableEntry dependentAssetId = *assetItr; // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Deleting Asset Id '%s' dependant of '%s.'", pAssetId, dependentAssetId ); } // Delete dependant. deleteAsset( dependentAssetId, deleteLooseFiles, deleteDependencies ); } } } // Remove asset references. removeAssetReferences( assetId ); // Are we deleting loose files? if ( deleteLooseFiles ) { // Yes, so remove loose files. Vector<StringTableEntry>& assetLooseFiles = pAssetDefinition->mAssetLooseFiles; for( Vector<StringTableEntry>::iterator looseFileItr = assetLooseFiles.begin(); looseFileItr != assetLooseFiles.end(); ++looseFileItr ) { // Fetch loose file. StringTableEntry looseFile = *looseFileItr; // Delete the loose file. if ( !dFileDelete( looseFile ) ) { // Failed so warn. Con::warnf( "Asset Manager: Failed to delete the loose file '%s' while deleting asset Id '%s'.", looseFile, pAssetId ); } } } // Fetch asset definition file. StringTableEntry assetDefinitionFile = pAssetDefinition->mAssetBaseFilePath; // Remove reference here as we're about to remove the declared asset. pAssetDefinition = NULL; // Remove asset. removeDeclaredAsset( pAssetId ); // Delete the asset definition file. if ( !dFileDelete( assetDefinitionFile ) ) { // Failed so warn. Con::warnf( "Asset Manager: Failed to delete the asset definition file '%s' while deleting asset Id '%s'.", assetDefinitionFile, pAssetId ); } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Finished deleting Asset Id '%s'.", pAssetId ); } return true; } //----------------------------------------------------------------------------- bool AssetManager::refreshAsset( const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RefreshAsset); // Sanity! AssertFatal( pAssetId != NULL, "Cannot refresh NULL asset Id." ); // Find asset. AssetDefinition* pAssetDefinition = findAsset( pAssetId ); // Did we find the asset? if ( pAssetDefinition == NULL ) { // No, so warn. Con::warnf( "Asset Manager: Failed to refresh asset Id '%s' as it does not exist.", pAssetId ); return false; } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Started refreshing Asset Id '%s'...", pAssetId ); } // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Is the asset private? if ( pAssetDefinition->mAssetPrivate ) { // Yes, so notify asset of asset refresh only. pAssetDefinition->mpAssetBase->onAssetRefresh(); // Asset refresh notifications. for( typeAssetPtrRefreshHash::iterator refreshNotifyItr = mAssetPtrRefreshNotifications.begin(); refreshNotifyItr != mAssetPtrRefreshNotifications.end(); ++refreshNotifyItr ) { // Fetch pointed asset. StringTableEntry pointedAsset = refreshNotifyItr->key->getAssetId(); // Ignore if the pointed asset is not the asset or a dependency. if ( pointedAsset == StringTable->EmptyString() || ( pointedAsset != assetId && !doesAssetDependOn( pointedAsset, assetId ) ) ) continue; // Perform refresh notification callback. refreshNotifyItr->value->onAssetRefreshed( refreshNotifyItr->key ); } } // Is the asset definition allowed to refresh? else if ( pAssetDefinition->mAssetRefreshEnable ) { // Yes, so fetch the asset. AssetBase* pAssetBase = pAssetDefinition->mpAssetBase; // Is the asset loaded? if ( pAssetBase != NULL ) { // Yes, so notify asset of asset refresh. pAssetBase->onAssetRefresh(); // Save asset. mTaml.write( pAssetBase, pAssetDefinition->mAssetBaseFilePath ); // Remove asset dependencies. removeAssetDependencies( pAssetId ); // Find any new dependencies. TamlAssetDeclaredVisitor assetDeclaredVisitor; // Parse the filename. if ( !mTaml.parse( pAssetDefinition->mAssetBaseFilePath, assetDeclaredVisitor ) ) { // Warn. Con::warnf( "Asset Manager: Failed to parse file containing asset declaration: '%s'.\nDependencies are now incorrect!", pAssetDefinition->mAssetBaseFilePath ); return false; } // Fetch asset dependencies. TamlAssetDeclaredVisitor::typeAssetIdVector& assetDependencies = assetDeclaredVisitor.getAssetDependencies(); // Are there any asset dependences? if ( assetDependencies.size() > 0 ) { // Yes, so iterate dependencies. for( TamlAssetDeclaredVisitor::typeAssetIdVector::iterator assetDependencyItr = assetDependencies.begin(); assetDependencyItr != assetDependencies.end(); ++assetDependencyItr ) { // Fetch dependency asset Id. StringTableEntry dependencyAssetId = *assetDependencyItr; // Insert depends-on. mAssetDependsOn.insertEqual( assetId, dependencyAssetId ); // Insert is-depended-on. mAssetIsDependedOn.insertEqual( dependencyAssetId, assetId ); } } // Fetch asset loose files. TamlAssetDeclaredVisitor::typeLooseFileVector& assetLooseFiles = assetDeclaredVisitor.getAssetLooseFiles(); // Clear any existing loose files. pAssetDefinition->mAssetLooseFiles.clear(); // Are there any loose files? if ( assetLooseFiles.size() > 0 ) { // Yes, so iterate loose files. for( TamlAssetDeclaredVisitor::typeLooseFileVector::iterator assetLooseFileItr = assetLooseFiles.begin(); assetLooseFileItr != assetLooseFiles.end(); ++assetLooseFileItr ) { // Store loose file. pAssetDefinition->mAssetLooseFiles.push_back( *assetLooseFileItr ); } } // Asset refresh notifications. for( typeAssetPtrRefreshHash::iterator refreshNotifyItr = mAssetPtrRefreshNotifications.begin(); refreshNotifyItr != mAssetPtrRefreshNotifications.end(); ++refreshNotifyItr ) { // Fetch pointed asset. StringTableEntry pointedAsset = refreshNotifyItr->key->getAssetId(); // Ignore if the pointed asset is not the asset or a dependency. if ( pointedAsset == StringTable->EmptyString() || ( pointedAsset != assetId && !doesAssetDependOn( pointedAsset, assetId ) ) ) continue; // Perform refresh notification callback. refreshNotifyItr->value->onAssetRefreshed( refreshNotifyItr->key ); } // Find is-depends-on entry. typeAssetIsDependedOnHash::Iterator isDependedOnItr = mAssetIsDependedOn.find( assetId ); // Is asset depended on? if ( isDependedOnItr != mAssetIsDependedOn.end() ) { // Yes, so compiled them. Vector<typeAssetId> dependedOn; // Iterate all dependencies. while( isDependedOnItr != mAssetIsDependedOn.end() && isDependedOnItr->key == assetId ) { dependedOn.push_back( isDependedOnItr->value ); // Next dependency. isDependedOnItr++; } // Refresh depended-on assets. for ( Vector<typeAssetId>::iterator isDependedOnItr = dependedOn.begin(); isDependedOnItr != dependedOn.end(); ++isDependedOnItr ) { // Refresh dependency asset. refreshAsset( *isDependedOnItr ); } } } } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Finished refreshing Asset Id '%s'.", pAssetId ); } return true; } //----------------------------------------------------------------------------- void AssetManager::refreshAllAssets( const bool includeUnloaded ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RefreshAllAssets); // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Started refreshing ALL assets." ); } Vector<typeAssetId> assetsToRelease; // Are we including unloaded assets? if ( includeUnloaded ) { // Yes, so prepare a list of assets to release and load them. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset Id. typeAssetId assetId = assetItr->key; // Skip if asset is loaded. if ( assetItr->value->mpAssetBase != NULL ) continue; // Note asset as needing a release. assetsToRelease.push_back( assetId ); // Acquire the asset. acquireAsset<AssetBase>( assetId ); } } // Refresh the current loaded assets. // NOTE: This will result in some assets being refreshed more than once due to asset dependencies. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Skip private assets. if ( assetItr->value->mAssetPrivate ) continue; // Refresh asset if it's loaded. refreshAsset( assetItr->key ); } // Are we including unloaded assets? if ( includeUnloaded ) { // Yes, so release the assets we loaded. for( Vector<typeAssetId>::iterator assetItr = assetsToRelease.begin(); assetItr != assetsToRelease.end(); ++assetItr ) { releaseAsset( *assetItr ); } } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Finished refreshing ALL assets." ); } } //----------------------------------------------------------------------------- void AssetManager::registerAssetPtrRefreshNotify( AssetPtrBase* pAssetPtrBase, AssetPtrCallback* pCallback ) { // Find an existing notification iterator. typeAssetPtrRefreshHash::iterator notificationItr = mAssetPtrRefreshNotifications.find( pAssetPtrBase ); // Do we have one? if ( notificationItr != mAssetPtrRefreshNotifications.end() ) { // Yes, so update the callback. notificationItr->value = pCallback; return; } // No, so add one. mAssetPtrRefreshNotifications.insert( pAssetPtrBase, pCallback ); } //----------------------------------------------------------------------------- void AssetManager::unregisterAssetPtrRefreshNotify( AssetPtrBase* pAssetPtrBase ) { mAssetPtrRefreshNotifications.erase( pAssetPtrBase ); } //----------------------------------------------------------------------------- bool AssetManager::loadAssetTags( ModuleDefinition* pModuleDefinition ) { // Sanity! AssertFatal( pModuleDefinition != NULL, "Cannot load asset tags manifest using a NULL module definition" ); // Expand manifest location. char assetTagsManifestFilePathBuffer[1024]; Con::expandPath( assetTagsManifestFilePathBuffer, sizeof(assetTagsManifestFilePathBuffer), pModuleDefinition->getAssetTagsManifest() ); // Do we already have a manifest? if ( !mAssetTagsManifest.isNull() ) { // Yes, so warn. Con::warnf( "Asset Manager: Cannot load asset tags manifest from module '%s' as one is already loaded.", pModuleDefinition->getSignature() ); return false; } // Is the specified file valid? if ( Platform::isFile( assetTagsManifestFilePathBuffer ) ) { // Yes, so read asset tags manifest. mAssetTagsManifest = mTaml.read<AssetTagsManifest>( assetTagsManifestFilePathBuffer ); // Did we read the manifest? if ( mAssetTagsManifest.isNull() ) { // No, so warn. Con::warnf( "Asset Manager: Failed to load asset tags manifest '%s' from module '%s'.", assetTagsManifestFilePathBuffer, pModuleDefinition->getSignature() ); return false; } // Set asset tags module definition. mAssetTagsModuleDefinition = pModuleDefinition; } else { // No, so generate a new asset tags manifest. mAssetTagsManifest = new AssetTagsManifest(); mAssetTagsManifest->registerObject(); // Set asset tags module definition. mAssetTagsModuleDefinition = pModuleDefinition; // Save the asset tags. saveAssetTags(); } return true; } //----------------------------------------------------------------------------- bool AssetManager::saveAssetTags( void ) { // Do we have an asset tags manifest? if ( mAssetTagsManifest.isNull() || mAssetTagsModuleDefinition.isNull() ) { // No, so warn. Con::warnf( "Asset Manager: Failed to save asset tags manifest as one is not loaded." ); return false; } // Expand manifest location. char assetTagsManifestFilePathBuffer[1024]; Con::expandPath( assetTagsManifestFilePathBuffer, sizeof(assetTagsManifestFilePathBuffer), mAssetTagsModuleDefinition->getAssetTagsManifest() ); // Save asset tags manifest. if ( !mTaml.write( mAssetTagsManifest, assetTagsManifestFilePathBuffer ) ) { // Failed so warn. Con::warnf( "Asset Manager: Failed to save asset tags manifest '%s' from module '%s'.", assetTagsManifestFilePathBuffer, mAssetTagsModuleDefinition->getSignature() ); return false; } return true; } //----------------------------------------------------------------------------- bool AssetManager::restoreAssetTags( void ) { // Do we already have a manifest? if ( mAssetTagsManifest.isNull() ) { // No, so warn. Con::warnf( "Asset Manager: Cannot restore asset tags manifest as one is not already loaded." ); return false; } // Sanity! AssertFatal( mAssetTagsModuleDefinition != NULL, "Cannot restore asset tags manifest as module definition is NULL." ); // Delete existing asset tags manifest. mAssetTagsManifest->deleteObject(); // Reload asset tags manifest. return loadAssetTags( mAssetTagsModuleDefinition ); } //----------------------------------------------------------------------------- S32 QSORT_CALLBACK descendingAssetDefinitionLoadCount(const void* a, const void* b) { // Debug Profiling. PROFILE_SCOPE(AssetManager_DescendingAssetDefinitionLoadCount); // Fetch asset definitions. const AssetDefinition* pAssetDefinitionA = *(AssetDefinition**)a; const AssetDefinition* pAssetDefinitionB = *(AssetDefinition**)b; // Sort. return pAssetDefinitionB->mAssetLoadedCount - pAssetDefinitionA->mAssetLoadedCount; } //----------------------------------------------------------------------------- void AssetManager::dumpDeclaredAssets( void ) const { Vector<const AssetDefinition*> assetDefinitions; // Iterate asset definitions. for( typeDeclaredAssetsHash::const_iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { assetDefinitions.push_back( assetItr->value ); } // Sort asset definitions. dQsort( assetDefinitions.address(), assetDefinitions.size(), sizeof(const AssetDefinition*), descendingAssetDefinitionLoadCount ); // Info. Con::printSeparator(); Con::printf( "Asset Manager: %d declared asset(s) dump as follows:", mDeclaredAssets.size() ); Con::printBlankLine(); // Iterate sorted asset definitions. for ( Vector<const AssetDefinition*>::iterator assetItr = assetDefinitions.begin(); assetItr != assetDefinitions.end(); ++assetItr ) { // Fetch asset definition. const AssetDefinition* pAssetDefinition = *assetItr; // Info. Con::printf( "AssetId:'%s', RefCount:%d, LoadCount:%d, UnloadCount:%d, AutoUnload:%d, Loaded:%d, Internal:%d, Private: %d, Type:'%s', Module/Version:'%s'/'%d', File:'%s'", pAssetDefinition->mAssetId, pAssetDefinition->mpAssetBase == NULL ? 0 : pAssetDefinition->mpAssetBase->getAcquiredReferenceCount(), pAssetDefinition->mAssetLoadedCount, pAssetDefinition->mAssetUnloadedCount, pAssetDefinition->mAssetAutoUnload, pAssetDefinition->mpAssetBase != NULL, pAssetDefinition->mAssetInternal, pAssetDefinition->mAssetPrivate, pAssetDefinition->mAssetType, pAssetDefinition->mpModuleDefinition->getModuleId(), pAssetDefinition->mpModuleDefinition->getVersionId(), pAssetDefinition->mAssetBaseFilePath ); } // Info. Con::printSeparator(); Con::printBlankLine(); } //----------------------------------------------------------------------------- S32 AssetManager::findAllAssets( AssetQuery* pAssetQuery, const bool ignoreInternal, const bool ignorePrivate ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAllAssets); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); // Reset result count. S32 resultCount = 0; // Iterate declared assets. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Skip if internal and we're ignoring them. if ( ignoreInternal && pAssetDefinition->mAssetInternal ) continue; // Skip if private and we're ignoring them. if ( ignorePrivate && pAssetDefinition->mAssetPrivate ) continue; // Store as result. pAssetQuery->mAssetList.push_back( pAssetDefinition->mAssetId ); // Increase result count. resultCount++; } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findAssetName( AssetQuery* pAssetQuery, const char* pAssetName, const bool partialName ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetName); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); AssertFatal( pAssetName != NULL, "Cannot use NULL asset name." ); // Reset asset name. StringTableEntry assetName = NULL; S32 partialAssetNameLength = 0; // Are we doing partial name search? if ( partialName ) { // Yes, so fetch length of partial name. partialAssetNameLength = dStrlen( pAssetName ); } else { // No, so fetch asset name. assetName = StringTable->insert( pAssetName ); } // Reset result count. S32 resultCount = 0; // Iterate declared assets. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Are we doing partial name search? if ( partialName ) { // Yes, so fetch the length of this asset name. const S32 currentAssetNameLength = dStrlen( pAssetDefinition->mAssetName ); // Skip if the query asset name is longer than the current asset name. if ( partialAssetNameLength > currentAssetNameLength ) continue; // Skip if this is not the asset we want. if ( dStrnicmp( pAssetDefinition->mAssetName, pAssetName, partialAssetNameLength ) != 0 ) continue; } else { // No, so skip if this is not the asset we want. if ( assetName != pAssetDefinition->mAssetName ) continue; } // Store as result. pAssetQuery->mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findAssetCategory( AssetQuery* pAssetQuery, const char* pAssetCategory, const bool assetQueryAsSource ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetCategory); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); AssertFatal( pAssetCategory != NULL, "Cannot use NULL asset category." ); // Fetch asset category. StringTableEntry assetCategory = StringTable->insert( pAssetCategory ); // Reset result count. S32 resultCount = 0; // Use asset-query as the source? if ( assetQueryAsSource ) { AssetQuery filteredAssets; // Yes, so iterate asset query. for (Vector<StringTableEntry>::iterator assetItr = pAssetQuery->mAssetList.begin(); assetItr != pAssetQuery->mAssetList.end(); ++assetItr) { // Fetch asset definition. AssetDefinition* pAssetDefinition = findAsset( *assetItr ); // Skip if this is not the asset we want. if ( pAssetDefinition == NULL || pAssetDefinition->mAssetCategory != assetCategory ) continue; // Store as result. filteredAssets.mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } // Set asset query. pAssetQuery->set( filteredAssets ); } else { // No, so iterate declared assets. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Skip if this is not the asset we want. if ( assetCategory != pAssetDefinition->mAssetCategory ) continue; // Store as result. pAssetQuery->mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } } return resultCount; } S32 AssetManager::findAssetAutoUnload( AssetQuery* pAssetQuery, const bool assetAutoUnload, const bool assetQueryAsSource ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetAutoUnload); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); // Reset result count. S32 resultCount = 0; // Use asset-query as the source? if ( assetQueryAsSource ) { AssetQuery filteredAssets; // Yes, so iterate asset query. for (Vector<StringTableEntry>::iterator assetItr = pAssetQuery->mAssetList.begin(); assetItr != pAssetQuery->mAssetList.end(); ++assetItr) { // Fetch asset definition. AssetDefinition* pAssetDefinition = findAsset( *assetItr ); // Skip if this is not the asset we want. if ( pAssetDefinition == NULL || pAssetDefinition->mAssetAutoUnload != assetAutoUnload ) continue; // Store as result. filteredAssets.mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } // Set asset query. pAssetQuery->set( filteredAssets ); } else { // No, so iterate declared assets. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Skip if this is not the asset we want. if ( assetAutoUnload != pAssetDefinition->mAssetAutoUnload ) continue; // Store as result. pAssetQuery->mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findAssetInternal( AssetQuery* pAssetQuery, const bool assetInternal, const bool assetQueryAsSource ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetInternal); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); // Reset result count. S32 resultCount = 0; // Use asset-query as the source? if ( assetQueryAsSource ) { AssetQuery filteredAssets; // Yes, so iterate asset query. for (Vector<StringTableEntry>::iterator assetItr = pAssetQuery->mAssetList.begin(); assetItr != pAssetQuery->mAssetList.end(); ++assetItr) { // Fetch asset definition. AssetDefinition* pAssetDefinition = findAsset( *assetItr ); // Skip if this is not the asset we want. if ( pAssetDefinition == NULL || pAssetDefinition->mAssetInternal != assetInternal ) continue; // Store as result. filteredAssets.mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } // Set asset query. pAssetQuery->set( filteredAssets ); } else { // No, so iterate declared assets. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Skip if this is not the asset we want. if ( assetInternal != pAssetDefinition->mAssetInternal ) continue; // Store as result. pAssetQuery->mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findAssetPrivate( AssetQuery* pAssetQuery, const bool assetPrivate, const bool assetQueryAsSource ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetPrivate); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); // Reset result count. S32 resultCount = 0; // Use asset-query as the source? if ( assetQueryAsSource ) { AssetQuery filteredAssets; // Yes, so iterate asset query. for (Vector<StringTableEntry>::iterator assetItr = pAssetQuery->mAssetList.begin(); assetItr != pAssetQuery->mAssetList.end(); ++assetItr) { // Fetch asset definition. AssetDefinition* pAssetDefinition = findAsset( *assetItr ); // Skip if this is not the asset we want. if ( pAssetDefinition == NULL || pAssetDefinition->mAssetPrivate != assetPrivate ) continue; // Store as result. filteredAssets.mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } // Set asset query. pAssetQuery->set( filteredAssets ); } else { // No, so iterate declared assets. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Skip if this is not the asset we want. if ( assetPrivate != pAssetDefinition->mAssetPrivate ) continue; // Store as result. pAssetQuery->mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findAssetType( AssetQuery* pAssetQuery, const char* pAssetType, const bool assetQueryAsSource ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetType); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); AssertFatal( pAssetType != NULL, "Cannot use NULL asset type." ); // Fetch asset type. StringTableEntry assetType = StringTable->insert( pAssetType ); // Reset result count. S32 resultCount = 0; // Use asset-query as the source? if ( assetQueryAsSource ) { AssetQuery filteredAssets; // Yes, so iterate asset query. for (Vector<StringTableEntry>::iterator assetItr = pAssetQuery->mAssetList.begin(); assetItr != pAssetQuery->mAssetList.end(); ++assetItr) { // Fetch asset definition. AssetDefinition* pAssetDefinition = findAsset( *assetItr ); // Skip if this is not the asset we want. if ( pAssetDefinition == NULL || pAssetDefinition->mAssetType != assetType ) continue; // Store as result. filteredAssets.mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } // Set asset query. pAssetQuery->set( filteredAssets ); } else { // No, so iterate declared assets. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Skip if this is not the asset we want. if ( assetType != pAssetDefinition->mAssetType ) continue; // Store as result. pAssetQuery->mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; } } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findAssetDependsOn( AssetQuery* pAssetQuery, const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetDependsOn); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); AssertFatal( pAssetId != NULL, "Cannot use NULL asset Id." ); // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Reset result count. S32 resultCount = 0; // Find depends-on entry. typeAssetDependsOnHash::Iterator dependsOnItr = mAssetDependsOn.find( assetId ); // Iterate all dependencies. while( dependsOnItr != mAssetDependsOn.end() && dependsOnItr->key == assetId ) { // Store as result. pAssetQuery->mAssetList.push_back(dependsOnItr->value); // Next dependency. dependsOnItr++; // Increase result count. resultCount++; } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findAssetIsDependedOn( AssetQuery* pAssetQuery, const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetIsDependedOn); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); AssertFatal( pAssetId != NULL, "Cannot use NULL asset Id." ); // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Reset result count. S32 resultCount = 0; // Find depended-on entry. typeAssetIsDependedOnHash::Iterator dependedOnItr = mAssetIsDependedOn.find( assetId ); // Iterate all dependencies. while( dependedOnItr != mAssetIsDependedOn.end() && dependedOnItr->key == assetId ) { // Store as result. pAssetQuery->mAssetList.push_back(dependedOnItr->value); // Next dependency. dependedOnItr++; // Increase result count. resultCount++; } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findInvalidAssetReferences( AssetQuery* pAssetQuery ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindInvalidAssetReferences); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); // Reset result count. S32 resultCount = 0; // Iterate referenced assets. for( typeReferencedAssetsHash::Iterator assetItr = mReferencedAssets.begin(); assetItr != mReferencedAssets.end(); ++assetItr ) { // Find asset definition. AssetDefinition* pAssetDefinition = findAsset( assetItr->key ); // Skip if the asset definition was found. if ( pAssetDefinition != NULL ) continue; // Store as result. pAssetQuery->mAssetList.push_back(assetItr->key); // Increase result count. resultCount++; } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findTaggedAssets( AssetQuery* pAssetQuery, const char* pAssetTagNames, const bool assetQueryAsSource ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindTaggedAssets); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); AssertFatal( pAssetTagNames != NULL, "Cannot use NULL asset tag name(s)." ); // Do we have an asset tag manifest? if ( mAssetTagsManifest.isNull() ) { // No, so warn. Con::warnf( "Asset Manager: Cannot find tagged assets as no asset tag manifest is present." ); return 0; } // Reset result count. S32 resultCount = 0; const char* pTagSeparators = " ,\t\n"; // Fetch tag count. U32 assetTagCount = StringUnit::getUnitCount( pAssetTagNames, pTagSeparators ); // Fetch asset tags. Vector<AssetTagsManifest::AssetTag*> assetTags; for( U32 tagIndex = 0; tagIndex < assetTagCount; ++tagIndex ) { // Fetch asset tag name. const char* pTagName = StringUnit::getUnit( pAssetTagNames, tagIndex, pTagSeparators ); // Fetch asset tag. AssetTagsManifest::AssetTag* pAssetTag = mAssetTagsManifest->findAssetTag( pTagName ); // Did we find the asset tag? if ( pAssetTag == NULL ) { // No, so warn. Con::warnf( "AssetTagsManifest: Asset Manager: Cannot find tagged assets of '%s' as it does not exist. Ignoring tag.", pTagName ); continue; } assetTags.push_back( pAssetTag ); } // Fetch found asset tag count. assetTagCount = assetTags.size(); // Did we find any tags? if ( assetTagCount == 0 ) { // No, so warn. Con::warnf( "AssetTagsManifest: Asset Manager: No specified tagged assets found in '%s'.", pAssetTagNames ); return 0; } // Use asset-query as the source? if ( assetQueryAsSource ) { AssetQuery filteredAssets; // Yes, so iterate asset query. for (Vector<StringTableEntry>::iterator assetItr = pAssetQuery->mAssetList.begin(); assetItr != pAssetQuery->mAssetList.end(); ++assetItr) { // Fetch asset Id. StringTableEntry assetId = *assetItr; // Skip if asset is not valid. if ( !isDeclaredAsset( assetId ) ) continue; // Reset matched flag. bool assetTagMatched = false; // Iterate asset tags. for ( Vector<AssetTagsManifest::AssetTag*>::iterator assetTagItr = assetTags.begin(); assetTagItr != assetTags.end(); ++assetTagItr ) { // Fetch asset tag. AssetTagsManifest::AssetTag* pAssetTag = *assetTagItr; // Skip if asset is not tagged. if ( !pAssetTag->containsAsset( assetId ) ) continue; // Flag as matched. assetTagMatched = true; break; } // Did we find a match? if ( assetTagMatched ) { // Yes, so is asset already present? if ( !filteredAssets.containsAsset( assetId ) ) { // No, so store as result. filteredAssets.mAssetList.push_back(assetId); // Increase result count. resultCount++; } } } // Set asset query. pAssetQuery->set( filteredAssets ); } else { // Iterate asset tags. for ( Vector<AssetTagsManifest::AssetTag*>::iterator assetTagItr = assetTags.begin(); assetTagItr != assetTags.end(); ++assetTagItr ) { // Fetch asset tag. AssetTagsManifest::AssetTag* pAssetTag = *assetTagItr; // Iterate tagged assets. for ( Vector<typeAssetId>::iterator assetItr = pAssetTag->mAssets.begin(); assetItr != pAssetTag->mAssets.end(); ++assetItr ) { // Fetch asset Id. StringTableEntry assetId = *assetItr; // Skip if asset Id is already present. if ( pAssetQuery->containsAsset( assetId ) ) continue; // Store as result. pAssetQuery->mAssetList.push_back(assetId); // Increase result count. resultCount++; } } } return resultCount; } //----------------------------------------------------------------------------- S32 AssetManager::findAssetLooseFile( AssetQuery* pAssetQuery, const char* pLooseFile, const bool assetQueryAsSource ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAssetLooseFile); // Sanity! AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." ); AssertFatal( pLooseFile != NULL, "Cannot use NULL loose file." ); // Expand loose file. char looseFileBuffer[1024]; Con::expandPath(looseFileBuffer, sizeof(looseFileBuffer), pLooseFile, NULL, false ); // Fetch asset loose file. StringTableEntry looseFile = StringTable->insert( looseFileBuffer ); // Reset result count. S32 resultCount = 0; // Use asset-query as the source? if ( assetQueryAsSource ) { AssetQuery filteredAssets; // Yes, so iterate asset query. for (Vector<StringTableEntry>::iterator assetItr = pAssetQuery->mAssetList.begin(); assetItr != pAssetQuery->mAssetList.end(); ++assetItr) { // Fetch asset definition. AssetDefinition* pAssetDefinition = findAsset( *assetItr ); // Fetch loose files. Vector<StringTableEntry>& assetLooseFiles = pAssetDefinition->mAssetLooseFiles; // Skip if this asset has no loose files. if ( assetLooseFiles.size() == 0 ) continue; // Search the assets loose files. for( Vector<StringTableEntry>::iterator looseFileItr = assetLooseFiles.begin(); looseFileItr != assetLooseFiles.end(); ++looseFileItr ) { // Is this the loose file we are searching for? if ( *looseFileItr != looseFile ) continue; // Store as result. filteredAssets.mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; break; } } // Set asset query. pAssetQuery->set( filteredAssets ); } else { // No, so iterate declared assets. for( typeDeclaredAssetsHash::iterator assetItr = mDeclaredAssets.begin(); assetItr != mDeclaredAssets.end(); ++assetItr ) { // Fetch asset definition. AssetDefinition* pAssetDefinition = assetItr->value; // Fetch loose files. Vector<StringTableEntry>& assetLooseFiles = pAssetDefinition->mAssetLooseFiles; // Skip if this asset has no loose files. if ( assetLooseFiles.size() == 0 ) continue; // Search the assets loose files. for( Vector<StringTableEntry>::iterator looseFileItr = assetLooseFiles.begin(); looseFileItr != assetLooseFiles.end(); ++looseFileItr ) { // Is this the loose file we are searching for? if ( *looseFileItr != looseFile ) continue; // Store as result. pAssetQuery->mAssetList.push_back(pAssetDefinition->mAssetId); // Increase result count. resultCount++; break; } } } return resultCount; } //----------------------------------------------------------------------------- bool AssetManager::scanDeclaredAssets( const char* pPath, const char* pExtension, const bool recurse, ModuleDefinition* pModuleDefinition ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_ScanDeclaredAssets); // Sanity! AssertFatal( pPath != NULL, "Cannot scan declared assets with NULL path." ); AssertFatal( pExtension != NULL, "Cannot scan declared assets with NULL extension." ); // Expand path location. char pathBuffer[1024]; Con::expandPath( pathBuffer, sizeof(pathBuffer), pPath ); // Find files. Vector<Platform::FileInfo> files; if ( !Platform::dumpPath( pathBuffer, files, recurse ? -1 : 0 ) ) { // Failed so warn. Con::warnf( "Asset Manager: Failed to scan declared assets in directory '%s'.", pathBuffer ); return false; } // Is the asset file-path located within the specified module? if ( !Con::isBasePath( pathBuffer, pModuleDefinition->getModulePath() ) ) { // No, so warn. Con::warnf( "Asset Manager: Could not add declared asset file '%s' as file does not exist with module path '%s'", pathBuffer, pModuleDefinition->getModulePath() ); return false; } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Scanning for declared assets in path '%s' for files with extension '%s'...", pathBuffer, pExtension ); } // Fetch extension length. const U32 extensionLength = dStrlen( pExtension ); // Fetch module assets. ModuleDefinition::typeModuleAssetsVector& moduleAssets = pModuleDefinition->getModuleAssets(); TamlAssetDeclaredVisitor assetDeclaredVisitor; // Iterate files. for ( Vector<Platform::FileInfo>::iterator fileItr = files.begin(); fileItr != files.end(); ++fileItr ) { // Fetch file info. Platform::FileInfo& fileInfo = *fileItr; // Fetch filename. const char* pFilename = fileInfo.pFileName; // Find filename length. const U32 filenameLength = dStrlen( pFilename ); // Skip if extension is longer than filename. if ( extensionLength > filenameLength ) continue; // Skip if extension not found. if ( dStricmp( pFilename + filenameLength - extensionLength, pExtension ) != 0 ) continue; // Clear declared assets. assetDeclaredVisitor.clear(); // Format full file-path. char assetFileBuffer[1024]; dSprintf( assetFileBuffer, sizeof(assetFileBuffer), "%s/%s", fileInfo.pFullPath, fileInfo.pFileName ); // Parse the filename. if ( !mTaml.parse( assetFileBuffer, assetDeclaredVisitor ) ) { // Warn. Con::warnf( "Asset Manager: Failed to parse file containing asset declaration: '%s'.", assetFileBuffer ); continue; } // Fetch asset definition. AssetDefinition& foundAssetDefinition = assetDeclaredVisitor.getAssetDefinition(); // Did we get an asset name? if ( foundAssetDefinition.mAssetName == StringTable->EmptyString() ) { // No, so warn. Con::warnf( "Asset Manager: Parsed file '%s' but did not encounter an asset.", assetFileBuffer ); continue; } // Set module definition. foundAssetDefinition.mpModuleDefinition = pModuleDefinition; // Format asset Id. char assetIdBuffer[1024]; dSprintf(assetIdBuffer, sizeof(assetIdBuffer), "%s%s%s", pModuleDefinition->getModuleId(), ASSET_SCOPE_TOKEN, foundAssetDefinition.mAssetName ); // Set asset Id. foundAssetDefinition.mAssetId = StringTable->insert( assetIdBuffer ); // Does this asset already exist? if ( mDeclaredAssets.contains( foundAssetDefinition.mAssetId ) ) { // Yes, so warn. Con::warnf( "Asset Manager: Encountered asset Id '%s' in asset file '%s' but it conflicts with existing asset Id in asset file '%s'.", foundAssetDefinition.mAssetId, foundAssetDefinition.mAssetBaseFilePath, mDeclaredAssets.find( foundAssetDefinition.mAssetId )->value->mAssetBaseFilePath ); continue; } // Create new asset definition. AssetDefinition* pAssetDefinition = new AssetDefinition( foundAssetDefinition ); // Store in declared assets. mDeclaredAssets.insert( pAssetDefinition->mAssetId, pAssetDefinition ); // Store in module assets. moduleAssets.push_back( pAssetDefinition ); // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Adding Asset Id '%s' of type '%s' in asset file '%s'.", pAssetDefinition->mAssetId, pAssetDefinition->mAssetType, pAssetDefinition->mAssetBaseFilePath ); } // Fetch asset Id. StringTableEntry assetId = pAssetDefinition->mAssetId; // Fetch asset dependencies. TamlAssetDeclaredVisitor::typeAssetIdVector& assetDependencies = assetDeclaredVisitor.getAssetDependencies(); // Are there any asset dependencies? if ( assetDependencies.size() > 0 ) { // Yes, so iterate dependencies. for( TamlAssetDeclaredVisitor::typeAssetIdVector::iterator assetDependencyItr = assetDependencies.begin(); assetDependencyItr != assetDependencies.end(); ++assetDependencyItr ) { // Fetch asset Ids. StringTableEntry dependencyAssetId = *assetDependencyItr; // Insert depends-on. mAssetDependsOn.insertEqual( assetId, dependencyAssetId ); // Insert is-depended-on. mAssetIsDependedOn.insertEqual( dependencyAssetId, assetId ); // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Asset Id '%s' has dependency of Asset Id '%s'", assetId, dependencyAssetId ); } } } // Fetch asset loose files. TamlAssetDeclaredVisitor::typeLooseFileVector& assetLooseFiles = assetDeclaredVisitor.getAssetLooseFiles(); // Are there any loose files? if ( assetLooseFiles.size() > 0 ) { // Yes, so iterate loose files. for( TamlAssetDeclaredVisitor::typeLooseFileVector::iterator assetLooseFileItr = assetLooseFiles.begin(); assetLooseFileItr != assetLooseFiles.end(); ++assetLooseFileItr ) { // Fetch loose file. StringTableEntry looseFile = *assetLooseFileItr; // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Asset Id '%s' has loose file '%s'.", assetId, looseFile ); } // Store loose file. pAssetDefinition->mAssetLooseFiles.push_back( looseFile ); } } } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: ... Finished scanning for declared assets in path '%s' for files with extension '%s'.", pathBuffer, pExtension ); Con::printSeparator(); Con::printBlankLine(); } return true; } //----------------------------------------------------------------------------- bool AssetManager::scanReferencedAssets( const char* pPath, const char* pExtension, const bool recurse ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_ScanReferencedAssets); // Sanity! AssertFatal( pPath != NULL, "Cannot scan referenced assets with NULL path." ); AssertFatal( pExtension != NULL, "Cannot scan referenced assets with NULL extension." ); // Expand path location. char pathBuffer[1024]; Con::expandPath( pathBuffer, sizeof(pathBuffer), pPath ); // Find files. Vector<Platform::FileInfo> files; if ( !Platform::dumpPath( pathBuffer, files, recurse ? -1 : 0 ) ) { // Failed so warn. Con::warnf( "Asset Manager: Failed to scan referenced assets in directory '%s'.", pathBuffer ); return false; } // Info. if ( mEchoInfo ) { Con::printSeparator(); Con::printf( "Asset Manager: Scanning for referenced assets in path '%s' for files with extension '%s'...", pathBuffer, pExtension ); } // Fetch extension length. const U32 extensionLength = dStrlen( pExtension ); TamlAssetReferencedVisitor assetReferencedVisitor; // Iterate files. for ( Vector<Platform::FileInfo>::iterator fileItr = files.begin(); fileItr != files.end(); ++fileItr ) { // Fetch file info. Platform::FileInfo& fileInfo = *fileItr; // Fetch filename. const char* pFilename = fileInfo.pFileName; // Find filename length. const U32 filenameLength = dStrlen( pFilename ); // Skip if extension is longer than filename. if ( extensionLength > filenameLength ) continue; // Skip if extension not found. if ( dStricmp( pFilename + filenameLength - extensionLength, pExtension ) != 0 ) continue; // Clear referenced assets. assetReferencedVisitor.clear(); // Format full file-path. char assetFileBuffer[1024]; dSprintf( assetFileBuffer, sizeof(assetFileBuffer), "%s/%s", fileInfo.pFullPath, fileInfo.pFileName ); // Format reference file-path. typeReferenceFilePath referenceFilePath = StringTable->insert( assetFileBuffer ); // Parse the filename. if ( !mTaml.parse( referenceFilePath, assetReferencedVisitor ) ) { // Warn. Con::warnf( "Asset Manager: Failed to parse file containing asset references: '%s'.", referenceFilePath ); continue; } // Fetch usage map. const TamlAssetReferencedVisitor::typeAssetReferencedHash& assetReferencedMap = assetReferencedVisitor.getAssetReferencedMap(); // Do we have any asset references? if ( assetReferencedMap.size() > 0 ) { // Info. if ( mEchoInfo ) { Con::printSeparator(); } // Iterate usage. for( TamlAssetReferencedVisitor::typeAssetReferencedHash::const_iterator usageItr = assetReferencedMap.begin(); usageItr != assetReferencedMap.end(); ++usageItr ) { // Fetch asset name. typeAssetId assetId = usageItr->key; // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Found referenced Asset Id '%s' in file '%s'.", assetId, referenceFilePath ); } // Add referenced asset. addReferencedAsset( assetId, referenceFilePath ); } } } // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: ... Finished scanning for referenced assets in path '%s' for files with extension '%s'.", pathBuffer, pExtension ); Con::printSeparator(); Con::printBlankLine(); } return true; } //----------------------------------------------------------------------------- AssetDefinition* AssetManager::findAsset( const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_FindAsset); // Sanity! AssertFatal( pAssetId != NULL, "Cannot find NULL asset Id." ); // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Find declared asset. typeDeclaredAssetsHash::iterator declaredAssetItr = mDeclaredAssets.find( assetId ); // Find if we didn't find a declared asset Id. if ( declaredAssetItr == mDeclaredAssets.end() ) return NULL; return declaredAssetItr->value; } //----------------------------------------------------------------------------- void AssetManager::addReferencedAsset( StringTableEntry assetId, StringTableEntry referenceFilePath ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_AddReferencedAsset); // Sanity! AssertFatal( assetId != NULL, "Cannot add referenced asset with NULL asset Id." ); AssertFatal( referenceFilePath != NULL, "Cannot add referenced asset with NULL reference file-path." ); // Find referenced asset. typeReferencedAssetsHash::Iterator referencedAssetItr = mReferencedAssets.find( assetId ); // Did we find the asset? if ( referencedAssetItr == mReferencedAssets.end() ) { // No, so add asset Id. mReferencedAssets.insertEqual( assetId, referenceFilePath ); } else { // Yes, so add asset Id with a unique file. while( true ) { // Finish if this file is already present. if ( referencedAssetItr->value == referenceFilePath ) return; // Move to next asset Id. referencedAssetItr++; // Is this the end of referenced assets or a different asset Id? if ( referencedAssetItr == mReferencedAssets.end() || referencedAssetItr->key != assetId ) { // Yes, so add asset reference. mReferencedAssets.insertEqual( assetId, referenceFilePath ); return; } }; } } //----------------------------------------------------------------------------- void AssetManager::renameAssetReferences( StringTableEntry assetIdFrom, StringTableEntry assetIdTo ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RenameAssetReferences); // Sanity! AssertFatal( assetIdFrom != NULL, "Cannot rename asset references using NULL asset Id from." ); AssertFatal( assetIdTo != NULL, "Cannot rename asset references using NULL asset Id to." ); // Finish if the asset is not referenced. if ( !mReferencedAssets.count( assetIdFrom ) ) return; // Setup referenced update visitor. TamlAssetReferencedUpdateVisitor assetReferencedUpdateVisitor; assetReferencedUpdateVisitor.setAssetIdFrom( assetIdFrom ); assetReferencedUpdateVisitor.setAssetIdTo( assetIdTo ); // Find first referenced asset Id. typeReferencedAssetsHash::Iterator referencedAssetItr = mReferencedAssets.find( assetIdFrom ); // Iterate references. while( true ) { // Finish if end of references. if ( referencedAssetItr == mReferencedAssets.end() || referencedAssetItr->key != assetIdFrom ) return; // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Renaming declared Asset Id '%s' to Asset Id '%s'. Updating referenced file '%s'", assetIdFrom, assetIdTo, referencedAssetItr->value ); } // Update asset file declaration. if ( !mTaml.parse( referencedAssetItr->value, assetReferencedUpdateVisitor ) ) { // No, so warn. Con::warnf("Asset Manager: Cannot rename referenced asset Id '%s' to asset Id '%s' as the referenced asset file could not be parsed: %s", assetIdFrom, assetIdTo, referencedAssetItr->value ); } // Move to next reference. referencedAssetItr++; } } //----------------------------------------------------------------------------- void AssetManager::removeAssetReferences( StringTableEntry assetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RemoveAssetReferences); // Sanity! AssertFatal( assetId != NULL, "Cannot rename asset references using NULL asset Id." ); // Finish if the asset is not referenced. if ( !mReferencedAssets.count( assetId ) ) return; // Setup referenced update visitor. TamlAssetReferencedUpdateVisitor assetReferencedUpdateVisitor; assetReferencedUpdateVisitor.setAssetIdFrom( assetId ); assetReferencedUpdateVisitor.setAssetIdTo( StringTable->EmptyString() ); // Find first referenced asset Id. typeReferencedAssetsHash::Iterator referencedAssetItr = mReferencedAssets.find(assetId); // Iterate references. while( true ) { // Finish if end of references. if ( referencedAssetItr == mReferencedAssets.end() || referencedAssetItr->key != assetId ) break; // Info. if ( mEchoInfo ) { Con::printf( "Asset Manager: Removing Asset Id '%s' references from file '%s'", assetId, referencedAssetItr->value ); } // Update asset file declaration. if ( !mTaml.parse( referencedAssetItr->value, assetReferencedUpdateVisitor ) ) { // No, so warn. Con::warnf("Asset Manager: Cannot remove referenced asset Id '%s' as the referenced asset file could not be parsed: %s", assetId, referencedAssetItr->value ); } // Move to next reference. referencedAssetItr++; } // Remove asset references. mReferencedAssets.erase( assetId ); } //----------------------------------------------------------------------------- void AssetManager::renameAssetDependencies( StringTableEntry assetIdFrom, StringTableEntry assetIdTo ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RenameAssetDependencies); // Sanity! AssertFatal( assetIdFrom != NULL, "Cannot rename asset dependencies using NULL asset Id from." ); AssertFatal( assetIdTo != NULL, "Cannot rename asset dependencies using NULL asset Id to." ); // Rename via depends-on... while( mAssetDependsOn.count( assetIdFrom ) > 0 ) { // Find depends-on. typeAssetDependsOnHash::Iterator dependsOnItr = mAssetDependsOn.find(assetIdFrom); // Fetch dependency asset Id. StringTableEntry dependencyAssetId = dependsOnItr->value; // Find is-depends-on entry. typeAssetIsDependedOnHash::Iterator isDependedOnItr = mAssetIsDependedOn.find(dependencyAssetId); // Sanity! AssertFatal( isDependedOnItr != mAssetIsDependedOn.end(), "Asset dependencies are corrupt!" ); while( isDependedOnItr != mAssetIsDependedOn.end() && isDependedOnItr->key == dependencyAssetId && isDependedOnItr->value != assetIdFrom ) { isDependedOnItr++; } // Sanity! AssertFatal( isDependedOnItr->key == dependencyAssetId && isDependedOnItr->value == assetIdFrom, "Asset dependencies are corrupt!" ); // Remove is-depended-on. mAssetIsDependedOn.erase( isDependedOnItr ); // Remove depends-on. mAssetDependsOn.erase( dependsOnItr ); // Insert depends-on. mAssetDependsOn.insertEqual( assetIdTo, dependencyAssetId ); // Insert is-depended-on. mAssetIsDependedOn.insertEqual( dependencyAssetId, assetIdTo ); } // Rename via is-depended-on... while( mAssetIsDependedOn.count( assetIdFrom ) > 0 ) { // Find is-depended-on. typeAssetIsDependedOnHash::Iterator isdependedOnItr = mAssetIsDependedOn.find(assetIdFrom); // Fetch dependency asset Id. StringTableEntry dependencyAssetId = isdependedOnItr->value; // Find depends-on entry. typeAssetDependsOnHash::Iterator dependsOnItr = mAssetDependsOn.find(dependencyAssetId); // Sanity! AssertFatal( dependsOnItr != mAssetDependsOn.end(), "Asset dependencies are corrupt!" ); while( dependsOnItr != mAssetDependsOn.end() && dependsOnItr->key == dependencyAssetId && dependsOnItr->value != assetIdFrom ) { dependsOnItr++; } // Sanity! AssertFatal( dependsOnItr->key == dependencyAssetId && dependsOnItr->value == assetIdFrom, "Asset dependencies are corrupt!" ); // Remove is-depended-on. mAssetIsDependedOn.erase( isdependedOnItr ); // Remove depends-on. mAssetDependsOn.erase( dependsOnItr ); // Insert depends-on. mAssetDependsOn.insertEqual( dependencyAssetId, assetIdTo ); // Insert is-depended-on. mAssetIsDependedOn.insertEqual( assetIdTo, dependencyAssetId ); } } //----------------------------------------------------------------------------- void AssetManager::removeAssetDependencies( const char* pAssetId ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_RemvoeAsetDependencies); // Sanity! AssertFatal( pAssetId != NULL, "Cannot remove asset dependencies using NULL asset Id." ); // Fetch asset Id. StringTableEntry assetId = StringTable->insert( pAssetId ); // Remove from depends-on assets. while( mAssetDependsOn.count( assetId ) > 0 ) { // Find depends-on. typeAssetDependsOnHash::Iterator dependsOnItr = mAssetDependsOn.find(assetId); // Fetch dependency asset Id. StringTableEntry dependencyAssetId = dependsOnItr->value; // Find is-depends-on entry. typeAssetIsDependedOnHash::Iterator isDependedOnItr = mAssetIsDependedOn.find(dependencyAssetId); // Sanity! AssertFatal( isDependedOnItr != mAssetIsDependedOn.end(), "Asset dependencies are corrupt!" ); while( isDependedOnItr != mAssetIsDependedOn.end() && isDependedOnItr->key == dependencyAssetId && isDependedOnItr->value != assetId ) { isDependedOnItr++; } // Sanity! AssertFatal( isDependedOnItr->key == dependencyAssetId && isDependedOnItr->value == assetId, "Asset dependencies are corrupt!" ); // Remove is-depended-on. mAssetIsDependedOn.erase( isDependedOnItr ); // Remove depends-on. mAssetDependsOn.erase( dependsOnItr ); } } //----------------------------------------------------------------------------- void AssetManager::unloadAsset( AssetDefinition* pAssetDefinition ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_UnloadAsset); // Destroy the asset. pAssetDefinition->mpAssetBase->deleteObject(); // Increase unloaded count. pAssetDefinition->mAssetUnloadedCount++; // Is the asset internal? if ( pAssetDefinition->mAssetInternal ) { // Yes, so decrease internal loaded asset count. mLoadedInternalAssetsCount--; } else { // No, so decrease external loaded assets count. mLoadedExternalAssetsCount--; } // Is the asset private? if ( pAssetDefinition->mAssetPrivate ) { // Yes, so decrease private loaded asset count. mLoadedPrivateAssetsCount--; // Remove it completely. removeDeclaredAsset( pAssetDefinition->mAssetId ); } } //----------------------------------------------------------------------------- void AssetManager::onModulePreLoad( ModuleDefinition* pModuleDefinition ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_OnModulePreLoad); // Add module declared assets. addModuleDeclaredAssets( pModuleDefinition ); // Is an asset tags manifest specified? if ( pModuleDefinition->getAssetTagsManifest() != StringTable->EmptyString() ) { // Yes, so load the asset tags manifest. loadAssetTags( pModuleDefinition ); } } //----------------------------------------------------------------------------- void AssetManager::onModulePreUnload( ModuleDefinition* pModuleDefinition ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_OnModulePreUnload); // Is an asset tags manifest specified? if ( pModuleDefinition->getAssetTagsManifest() != StringTable->EmptyString() ) { // Yes, so save the asset tags manifest. saveAssetTags(); // Do we have an asset tags manifest? if ( !mAssetTagsManifest.isNull() ) { // Yes, so remove it. mAssetTagsManifest->deleteObject(); mAssetTagsModuleDefinition = NULL; } } } //----------------------------------------------------------------------------- void AssetManager::onModulePostUnload( ModuleDefinition* pModuleDefinition ) { // Debug Profiling. PROFILE_SCOPE(AssetManager_OnModulePostUnload); // Remove declared assets. removeDeclaredAssets( pModuleDefinition ); }
33.535454
196
0.599298
John3
66dff57b67b1b5981e5d3a45cee4b4f61e6df27e
5,910
cpp
C++
Dependencies/Source/FreeImage/OpenEXR/Imath/ImathRandom.cpp
gamekit-developers/gamekit
74c896af5826ebe8fb72f2911015738f38ab7bb2
[ "Zlib", "MIT" ]
241
2015-01-04T00:36:58.000Z
2022-01-06T19:19:23.000Z
Dependencies/Source/FreeImage/OpenEXR/Imath/ImathRandom.cpp
gamekit-developers/gamekit
74c896af5826ebe8fb72f2911015738f38ab7bb2
[ "Zlib", "MIT" ]
10
2015-07-10T18:27:17.000Z
2019-06-26T20:59:59.000Z
Dependencies/Source/FreeImage/OpenEXR/Imath/ImathRandom.cpp
gamekit-developers/gamekit
74c896af5826ebe8fb72f2911015738f38ab7bb2
[ "Zlib", "MIT" ]
82
2015-01-25T18:02:35.000Z
2022-03-05T12:28:17.000Z
/////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Industrial Light & Magic nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // /////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // // Routines that generate pseudo-random numbers compatible // with the standard erand48(), nrand48(), etc. functions. // //----------------------------------------------------------------------------- #include "ImathRandom.h" #include "ImathInt64.h" namespace Imath { namespace { // // Static state used by Imath::drand48(), Imath::lrand48() and Imath::srand48() // unsigned short staticState[3] = {0, 0, 0}; void rand48Next (unsigned short state[3]) { // // drand48() and friends are all based on a linear congruential // sequence, // // x[n+1] = (a * x[n] + c) % m, // // where a and c are as specified below, and m == (1 << 48) // static const Int64 a = Int64 (0x5deece66dLL); static const Int64 c = Int64 (0xbLL); // // Assemble the 48-bit value x[n] from the // three 16-bit values stored in state. // Int64 x = (Int64 (state[2]) << 32) | (Int64 (state[1]) << 16) | Int64 (state[0]); // // Compute x[n+1], except for the "modulo m" part. // x = a * x + c; // // Disassemble the 48 least significant bits of x[n+1] into // three 16-bit values. Discard the 16 most significant bits; // this takes care of the "modulo m" operation. // // We assume that sizeof (unsigned short) == 2. // state[2] = x >> 32; state[1] = x >> 16; state[0] = x; } } // namespace double erand48 (unsigned short state[3]) { // // Generate double-precision floating-point values between 0.0 and 1.0: // // The exponent is set to 0x3ff, which indicates a value greater // than or equal to 1.0, and less than 2.0. The 48 most significant // bits of the significand (mantissa) are filled with pseudo-random // bits generated by rand48Next(). The remaining 4 bits are a copy // of the 4 most significant bits of the significand. This results // in bit patterns between 0x3ff0000000000000 and 0x3fffffffffffffff, // which correspond to uniformly distributed floating-point values // between 1.0 and 1.99999999999999978. Subtracting 1.0 from those // values produces numbers between 0.0 and 0.99999999999999978, that // is, between 0.0 and 1.0-DBL_EPSILON. // rand48Next (state); union {double d; Int64 i;} u; u.i = (Int64 (0x3ff) << 52) | // sign and exponent (Int64 (state[2]) << 36) | // significand (Int64 (state[1]) << 20) | (Int64 (state[0]) << 4) | (Int64 (state[2]) >> 12); return u.d - 1; } double drand48 () { return Imath::erand48 (staticState); } long int nrand48 (unsigned short state[3]) { // // Generate uniformly distributed integers between 0 and 0x7fffffff. // rand48Next (state); return ((long int) (state[2]) << 15) | ((long int) (state[1]) >> 1); } long int lrand48 () { return Imath::nrand48 (staticState); } void srand48 (long int seed) { staticState[2] = seed >> 16; staticState[1] = seed; staticState[0] = 0x330e; } float Rand32::nextf () { // // Generate single-precision floating-point values between 0.0 and 1.0: // // The exponent is set to 0x7f, which indicates a value greater than // or equal to 1.0, and less than 2.0. The 23 bits of the significand // (mantissa) are filled with pseudo-random bits generated by // Rand32::next(). This results in in bit patterns between 0x3f800000 // and 0x3fffffff, which correspond to uniformly distributed floating- // point values between 1.0 and 1.99999988. Subtracting 1.0 from // those values produces numbers between 0.0 and 0.99999988, that is, // between 0.0 and 1.0-FLT_EPSILON. // next (); union {float f; unsigned int i;} u; u.i = 0x3f800000 | (_state & 0x7fffff); return u.f - 1; } } // namespace Imath
30.153061
80
0.603892
gamekit-developers
66e0c4e7f326ea2990592d8fe14f78a0e7d93b33
911
cpp
C++
src/Tools/Interleaver/NO/Interleaver_core_NO.cpp
bonben/aff3ct
8e78123bfc0a377947ecb690ce1e0d70c0dc0a68
[ "MIT" ]
null
null
null
src/Tools/Interleaver/NO/Interleaver_core_NO.cpp
bonben/aff3ct
8e78123bfc0a377947ecb690ce1e0d70c0dc0a68
[ "MIT" ]
4
2018-09-27T16:46:31.000Z
2018-11-22T11:10:41.000Z
src/Tools/Interleaver/NO/Interleaver_core_NO.cpp
bonben/aff3ct
8e78123bfc0a377947ecb690ce1e0d70c0dc0a68
[ "MIT" ]
null
null
null
#include <numeric> #include "Interleaver_core_NO.hpp" using namespace aff3ct; using namespace aff3ct::tools; template <typename T> Interleaver_core_NO<T> ::Interleaver_core_NO(const int size, const int n_frames) : Interleaver_core<T>(size, "NO", false, n_frames) { } template <typename T> void Interleaver_core_NO<T> ::gen_lut(T *lut, const int frame_id) { std::iota(lut, lut + this->get_size(), 0); } // ==================================================================================== explicit template instantiation #include <cstdint> template class aff3ct::tools::Interleaver_core_NO<uint8_t >; template class aff3ct::tools::Interleaver_core_NO<uint16_t>; template class aff3ct::tools::Interleaver_core_NO<uint32_t>; template class aff3ct::tools::Interleaver_core_NO<uint64_t>; // ==================================================================================== explicit template instantiation
31.413793
119
0.63337
bonben
66e34d1dd12652b655b96f1e5bb9f8caf30a4101
1,451
cpp
C++
C++/354.russian-doll-envelopes.cpp
WilliamZhaoz/github
2aa0eb17e272249fc225cf2e9861c4c44bd0e265
[ "MIT" ]
1
2018-03-06T05:07:22.000Z
2018-03-06T05:07:22.000Z
C++/354.russian-doll-envelopes.cpp
WilliamZhaoz/github
2aa0eb17e272249fc225cf2e9861c4c44bd0e265
[ "MIT" ]
1
2021-12-24T16:41:02.000Z
2021-12-24T16:41:02.000Z
C++/354.russian-doll-envelopes.cpp
WilliamZhaoz/github
2aa0eb17e272249fc225cf2e9861c4c44bd0e265
[ "MIT" ]
null
null
null
class Solution { public: int maxEnvelopes(vector<pair<int, int>>& envelopes) { // version 1: BS & DP // after sorting increasing by the w and decreasing by the h, this problem is equle to "Longest Increasing Subsequence" // dp[i] means the min value of the last value of the size(dp) increasing subsequence // lower_bound function can implemented by Binary Search /* vector<int> dp; sort(envelopes.begin(), envelopes.end(), [](const pair<int, int> &a, const pair<int, int> &b){ if (a.first == b.first) return a.second > b.second; return a.first < b.first; }); for (int i = 0; i < envelopes.size(); ++i) { auto it = lower_bound(dp.begin(), dp.end(), envelopes[i].second); if (it == dp.end()) dp.push_back(envelopes[i].second); else *it = envelopes[i].second; } return dp.size(); */ // version 2: only traditional DP int res = 0, n = envelopes.size(); vector<int> dp(n, 1); sort(envelopes.begin(), envelopes.end()); for (int i = 0; i < n; ++i) { for (int j = 0; j < i; ++j) { if (envelopes[i].first > envelopes[j].first && envelopes[i].second > envelopes[j].second) { dp[i] = max(dp[i], dp[j] + 1); } } res = max(res, dp[i]); } return res; } };
41.457143
128
0.516885
WilliamZhaoz
66e4dbe357beef8bc07f3e102ae55275cf1fa874
550
cpp
C++
toki/src/Document.cpp
frankencode/fluxkit
0436454f0791d8fddf8e0adc383ef7c54080245d
[ "BSD-3-Clause" ]
3
2016-02-10T04:58:32.000Z
2020-09-15T06:39:43.000Z
toki/src/Document.cpp
frankencode/fluxkit
0436454f0791d8fddf8e0adc383ef7c54080245d
[ "BSD-3-Clause" ]
null
null
null
toki/src/Document.cpp
frankencode/fluxkit
0436454f0791d8fddf8e0adc383ef7c54080245d
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (C) 2007-2015 Frank Mertens. * * Use of this source is governed by a BSD-style license that can be * found in the LICENSE file. * */ #include <flux/File> #include <flux/toki/Document> namespace flux { namespace toki { Ref<Document> Document::load(String path) { return Document::create(File::open(path)->map(), path); } void Document::save() { File::save(path_, text_); } Document::Document(String text, String path) : path_(path), text_(text), spans_(Spans::create()) {} }} // namespace flux::toki
17.1875
68
0.656364
frankencode
66e4fbe64730e265caa10e05ef06110eed84543f
20,187
cc
C++
cartographer/mapping/internal/3d/scan_matching/fast_correlative_scan_matcher_3d.cc
sotnik-github/cartographer
73d18e5fc54bfa4e4e61fd7feb615b46834aa584
[ "Apache-2.0" ]
35
2018-08-02T02:38:20.000Z
2022-03-21T07:48:06.000Z
cartographer/mapping/internal/3d/scan_matching/fast_correlative_scan_matcher_3d.cc
sotnik-github/cartographer
73d18e5fc54bfa4e4e61fd7feb615b46834aa584
[ "Apache-2.0" ]
17
2017-06-02T01:55:21.000Z
2022-03-02T01:52:58.000Z
cartographer/mapping/internal/3d/scan_matching/fast_correlative_scan_matcher_3d.cc
sotnik-github/cartographer
73d18e5fc54bfa4e4e61fd7feb615b46834aa584
[ "Apache-2.0" ]
37
2018-07-26T00:07:40.000Z
2021-12-31T07:57:50.000Z
/* * Copyright 2016 The Cartographer Authors * * Licensed 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 "cartographer/mapping/internal/3d/scan_matching/fast_correlative_scan_matcher_3d.h" #include <algorithm> #include <cmath> #include <functional> #include <limits> #include "Eigen/Geometry" #include "cartographer/common/make_unique.h" #include "cartographer/common/math.h" #include "cartographer/mapping/internal/3d/scan_matching/low_resolution_matcher.h" #include "cartographer/mapping/proto/scan_matching//fast_correlative_scan_matcher_options_3d.pb.h" #include "cartographer/transform/transform.h" #include "glog/logging.h" namespace cartographer { namespace mapping { namespace scan_matching { proto::FastCorrelativeScanMatcherOptions3D CreateFastCorrelativeScanMatcherOptions3D( common::LuaParameterDictionary* const parameter_dictionary) { proto::FastCorrelativeScanMatcherOptions3D options; options.set_branch_and_bound_depth( parameter_dictionary->GetInt("branch_and_bound_depth")); options.set_full_resolution_depth( parameter_dictionary->GetInt("full_resolution_depth")); options.set_min_rotational_score( parameter_dictionary->GetDouble("min_rotational_score")); options.set_min_low_resolution_score( parameter_dictionary->GetDouble("min_low_resolution_score")); options.set_linear_xy_search_window( parameter_dictionary->GetDouble("linear_xy_search_window")); options.set_linear_z_search_window( parameter_dictionary->GetDouble("linear_z_search_window")); options.set_angular_search_window( parameter_dictionary->GetDouble("angular_search_window")); return options; } PrecomputationGridStack3D::PrecomputationGridStack3D( const HybridGrid& hybrid_grid, const proto::FastCorrelativeScanMatcherOptions3D& options) { CHECK_GE(options.branch_and_bound_depth(), 1); CHECK_GE(options.full_resolution_depth(), 1); precomputation_grids_.reserve(options.branch_and_bound_depth()); precomputation_grids_.push_back(ConvertToPrecomputationGrid(hybrid_grid)); Eigen::Array3i last_width = Eigen::Array3i::Ones(); for (int depth = 1; depth != options.branch_and_bound_depth(); ++depth) { const bool half_resolution = depth >= options.full_resolution_depth(); const Eigen::Array3i next_width = ((1 << depth) * Eigen::Array3i::Ones()); const int full_voxels_per_high_resolution_voxel = 1 << std::max(0, depth - options.full_resolution_depth()); const Eigen::Array3i shift = (next_width - last_width + (full_voxels_per_high_resolution_voxel - 1)) / full_voxels_per_high_resolution_voxel; precomputation_grids_.push_back( PrecomputeGrid(precomputation_grids_.back(), half_resolution, shift)); last_width = next_width; } } struct DiscreteScan3D { transform::Rigid3f pose; // Contains a vector of discretized scans for each 'depth'. std::vector<std::vector<Eigen::Array3i>> cell_indices_per_depth; float rotational_score; }; struct Candidate3D { Candidate3D(const int scan_index, const Eigen::Array3i& offset) : scan_index(scan_index), offset(offset) {} static Candidate3D Unsuccessful() { return Candidate3D(0, Eigen::Array3i::Zero()); } // Index into the discrete scans vectors. int scan_index; // Linear offset from the initial pose in cell indices. For lower resolution // candidates this is the lowest offset of the 2^depth x 2^depth x 2^depth // block of possibilities. Eigen::Array3i offset; // Score, higher is better. float score = -std::numeric_limits<float>::infinity(); // Score of the low resolution matcher. float low_resolution_score = 0.f; bool operator<(const Candidate3D& other) const { return score < other.score; } bool operator>(const Candidate3D& other) const { return score > other.score; } }; namespace { std::vector<std::pair<Eigen::VectorXf, float>> HistogramsAtAnglesFromNodes( const std::vector<TrajectoryNode>& nodes) { std::vector<std::pair<Eigen::VectorXf, float>> histograms_at_angles; for (const auto& node : nodes) { histograms_at_angles.emplace_back( node.constant_data->rotational_scan_matcher_histogram, transform::GetYaw( node.global_pose * transform::Rigid3d::Rotation( node.constant_data->gravity_alignment.inverse()))); } return histograms_at_angles; } } // namespace FastCorrelativeScanMatcher3D::FastCorrelativeScanMatcher3D( const HybridGrid& hybrid_grid, const HybridGrid* const low_resolution_hybrid_grid, const std::vector<TrajectoryNode>& nodes, const proto::FastCorrelativeScanMatcherOptions3D& options) : options_(options), resolution_(hybrid_grid.resolution()), width_in_voxels_(hybrid_grid.grid_size()), precomputation_grid_stack_( common::make_unique<PrecomputationGridStack3D>(hybrid_grid, options)), low_resolution_hybrid_grid_(low_resolution_hybrid_grid), rotational_scan_matcher_(HistogramsAtAnglesFromNodes(nodes)) {} FastCorrelativeScanMatcher3D::~FastCorrelativeScanMatcher3D() {} std::unique_ptr<FastCorrelativeScanMatcher3D::Result> FastCorrelativeScanMatcher3D::Match( const transform::Rigid3d& global_node_pose, const transform::Rigid3d& global_submap_pose, const TrajectoryNode::Data& constant_data, const float min_score) const { const auto low_resolution_matcher = scan_matching::CreateLowResolutionMatcher( low_resolution_hybrid_grid_, &constant_data.low_resolution_point_cloud); const SearchParameters search_parameters{ common::RoundToInt(options_.linear_xy_search_window() / resolution_), common::RoundToInt(options_.linear_z_search_window() / resolution_), options_.angular_search_window(), &low_resolution_matcher}; return MatchWithSearchParameters( search_parameters, global_node_pose.cast<float>(), global_submap_pose.cast<float>(), constant_data.high_resolution_point_cloud, constant_data.rotational_scan_matcher_histogram, constant_data.gravity_alignment, min_score); } std::unique_ptr<FastCorrelativeScanMatcher3D::Result> FastCorrelativeScanMatcher3D::MatchFullSubmap( const Eigen::Quaterniond& global_node_rotation, const Eigen::Quaterniond& global_submap_rotation, const TrajectoryNode::Data& constant_data, const float min_score) const { float max_point_distance = 0.f; for (const Eigen::Vector3f& point : constant_data.high_resolution_point_cloud) { max_point_distance = std::max(max_point_distance, point.norm()); } const int linear_window_size = (width_in_voxels_ + 1) / 2 + common::RoundToInt(max_point_distance / resolution_ + 0.5f); const auto low_resolution_matcher = scan_matching::CreateLowResolutionMatcher( low_resolution_hybrid_grid_, &constant_data.low_resolution_point_cloud); const SearchParameters search_parameters{ linear_window_size, linear_window_size, M_PI, &low_resolution_matcher}; return MatchWithSearchParameters( search_parameters, transform::Rigid3f::Rotation(global_node_rotation.cast<float>()), transform::Rigid3f::Rotation(global_submap_rotation.cast<float>()), constant_data.high_resolution_point_cloud, constant_data.rotational_scan_matcher_histogram, constant_data.gravity_alignment, min_score); } std::unique_ptr<FastCorrelativeScanMatcher3D::Result> FastCorrelativeScanMatcher3D::MatchWithSearchParameters( const FastCorrelativeScanMatcher3D::SearchParameters& search_parameters, const transform::Rigid3f& global_node_pose, const transform::Rigid3f& global_submap_pose, const sensor::PointCloud& point_cloud, const Eigen::VectorXf& rotational_scan_matcher_histogram, const Eigen::Quaterniond& gravity_alignment, const float min_score) const { const std::vector<DiscreteScan3D> discrete_scans = GenerateDiscreteScans( search_parameters, point_cloud, rotational_scan_matcher_histogram, gravity_alignment, global_node_pose, global_submap_pose); const std::vector<Candidate3D> lowest_resolution_candidates = ComputeLowestResolutionCandidates(search_parameters, discrete_scans); const Candidate3D best_candidate = BranchAndBound( search_parameters, discrete_scans, lowest_resolution_candidates, precomputation_grid_stack_->max_depth(), min_score); if (best_candidate.score > min_score) { return common::make_unique<Result>(Result{ best_candidate.score, GetPoseFromCandidate(discrete_scans, best_candidate).cast<double>(), discrete_scans[best_candidate.scan_index].rotational_score, best_candidate.low_resolution_score}); } return nullptr; } DiscreteScan3D FastCorrelativeScanMatcher3D::DiscretizeScan( const FastCorrelativeScanMatcher3D::SearchParameters& search_parameters, const sensor::PointCloud& point_cloud, const transform::Rigid3f& pose, const float rotational_score) const { std::vector<std::vector<Eigen::Array3i>> cell_indices_per_depth; const PrecomputationGrid3D& original_grid = precomputation_grid_stack_->Get(0); std::vector<Eigen::Array3i> full_resolution_cell_indices; for (const Eigen::Vector3f& point : sensor::TransformPointCloud(point_cloud, pose)) { full_resolution_cell_indices.push_back(original_grid.GetCellIndex(point)); } const int full_resolution_depth = std::min(options_.full_resolution_depth(), options_.branch_and_bound_depth()); CHECK_GE(full_resolution_depth, 1); for (int i = 0; i != full_resolution_depth; ++i) { cell_indices_per_depth.push_back(full_resolution_cell_indices); } const int low_resolution_depth = options_.branch_and_bound_depth() - full_resolution_depth; CHECK_GE(low_resolution_depth, 0); const Eigen::Array3i search_window_start( -search_parameters.linear_xy_window_size, -search_parameters.linear_xy_window_size, -search_parameters.linear_z_window_size); for (int i = 0; i != low_resolution_depth; ++i) { const int reduction_exponent = i + 1; const Eigen::Array3i low_resolution_search_window_start( search_window_start[0] >> reduction_exponent, search_window_start[1] >> reduction_exponent, search_window_start[2] >> reduction_exponent); cell_indices_per_depth.emplace_back(); for (const Eigen::Array3i& cell_index : full_resolution_cell_indices) { const Eigen::Array3i cell_at_start = cell_index + search_window_start; const Eigen::Array3i low_resolution_cell_at_start( cell_at_start[0] >> reduction_exponent, cell_at_start[1] >> reduction_exponent, cell_at_start[2] >> reduction_exponent); cell_indices_per_depth.back().push_back( low_resolution_cell_at_start - low_resolution_search_window_start); } } return DiscreteScan3D{pose, cell_indices_per_depth, rotational_score}; } std::vector<DiscreteScan3D> FastCorrelativeScanMatcher3D::GenerateDiscreteScans( const FastCorrelativeScanMatcher3D::SearchParameters& search_parameters, const sensor::PointCloud& point_cloud, const Eigen::VectorXf& rotational_scan_matcher_histogram, const Eigen::Quaterniond& gravity_alignment, const transform::Rigid3f& global_node_pose, const transform::Rigid3f& global_submap_pose) const { std::vector<DiscreteScan3D> result; // We set this value to something on the order of resolution to make sure that // the std::acos() below is defined. float max_scan_range = 3.f * resolution_; for (const Eigen::Vector3f& point : point_cloud) { const float range = point.norm(); max_scan_range = std::max(range, max_scan_range); } const float kSafetyMargin = 1.f - 1e-2f; const float angular_step_size = kSafetyMargin * std::acos(1.f - common::Pow2(resolution_) / (2.f * common::Pow2(max_scan_range))); const int angular_window_size = common::RoundToInt( search_parameters.angular_search_window / angular_step_size); std::vector<float> angles; for (int rz = -angular_window_size; rz <= angular_window_size; ++rz) { angles.push_back(rz * angular_step_size); } const transform::Rigid3f node_to_submap = global_submap_pose.inverse() * global_node_pose; const std::vector<float> scores = rotational_scan_matcher_.Match( rotational_scan_matcher_histogram, transform::GetYaw(node_to_submap.rotation() * gravity_alignment.inverse().cast<float>()), angles); for (size_t i = 0; i != angles.size(); ++i) { if (scores[i] < options_.min_rotational_score()) { continue; } const Eigen::Vector3f angle_axis(0.f, 0.f, angles[i]); // It's important to apply the 'angle_axis' rotation between the translation // and rotation of the 'initial_pose', so that the rotation is around the // origin of the range data, and yaw is in map frame. const transform::Rigid3f pose( node_to_submap.translation(), global_submap_pose.rotation().inverse() * transform::AngleAxisVectorToRotationQuaternion(angle_axis) * global_node_pose.rotation()); result.push_back( DiscretizeScan(search_parameters, point_cloud, pose, scores[i])); } return result; } std::vector<Candidate3D> FastCorrelativeScanMatcher3D::GenerateLowestResolutionCandidates( const FastCorrelativeScanMatcher3D::SearchParameters& search_parameters, const int num_discrete_scans) const { const int linear_step_size = 1 << precomputation_grid_stack_->max_depth(); const int num_lowest_resolution_linear_xy_candidates = (2 * search_parameters.linear_xy_window_size + linear_step_size) / linear_step_size; const int num_lowest_resolution_linear_z_candidates = (2 * search_parameters.linear_z_window_size + linear_step_size) / linear_step_size; const int num_candidates = num_discrete_scans * common::Power(num_lowest_resolution_linear_xy_candidates, 2) * num_lowest_resolution_linear_z_candidates; std::vector<Candidate3D> candidates; candidates.reserve(num_candidates); for (int scan_index = 0; scan_index != num_discrete_scans; ++scan_index) { for (int z = -search_parameters.linear_z_window_size; z <= search_parameters.linear_z_window_size; z += linear_step_size) { for (int y = -search_parameters.linear_xy_window_size; y <= search_parameters.linear_xy_window_size; y += linear_step_size) { for (int x = -search_parameters.linear_xy_window_size; x <= search_parameters.linear_xy_window_size; x += linear_step_size) { candidates.emplace_back(scan_index, Eigen::Array3i(x, y, z)); } } } } CHECK_EQ(candidates.size(), num_candidates); return candidates; } void FastCorrelativeScanMatcher3D::ScoreCandidates( const int depth, const std::vector<DiscreteScan3D>& discrete_scans, std::vector<Candidate3D>* const candidates) const { const int reduction_exponent = std::max(0, depth - options_.full_resolution_depth() + 1); for (Candidate3D& candidate : *candidates) { int sum = 0; const DiscreteScan3D& discrete_scan = discrete_scans[candidate.scan_index]; const Eigen::Array3i offset(candidate.offset[0] >> reduction_exponent, candidate.offset[1] >> reduction_exponent, candidate.offset[2] >> reduction_exponent); CHECK_LT(depth, discrete_scan.cell_indices_per_depth.size()); for (const Eigen::Array3i& cell_index : discrete_scan.cell_indices_per_depth[depth]) { const Eigen::Array3i proposed_cell_index = cell_index + offset; sum += precomputation_grid_stack_->Get(depth).value(proposed_cell_index); } candidate.score = PrecomputationGrid3D::ToProbability( sum / static_cast<float>(discrete_scan.cell_indices_per_depth[depth].size())); } std::sort(candidates->begin(), candidates->end(), std::greater<Candidate3D>()); } std::vector<Candidate3D> FastCorrelativeScanMatcher3D::ComputeLowestResolutionCandidates( const FastCorrelativeScanMatcher3D::SearchParameters& search_parameters, const std::vector<DiscreteScan3D>& discrete_scans) const { std::vector<Candidate3D> lowest_resolution_candidates = GenerateLowestResolutionCandidates(search_parameters, discrete_scans.size()); ScoreCandidates(precomputation_grid_stack_->max_depth(), discrete_scans, &lowest_resolution_candidates); return lowest_resolution_candidates; } transform::Rigid3f FastCorrelativeScanMatcher3D::GetPoseFromCandidate( const std::vector<DiscreteScan3D>& discrete_scans, const Candidate3D& candidate) const { return transform::Rigid3f::Translation( resolution_ * candidate.offset.matrix().cast<float>()) * discrete_scans[candidate.scan_index].pose; } Candidate3D FastCorrelativeScanMatcher3D::BranchAndBound( const FastCorrelativeScanMatcher3D::SearchParameters& search_parameters, const std::vector<DiscreteScan3D>& discrete_scans, const std::vector<Candidate3D>& candidates, const int candidate_depth, float min_score) const { if (candidate_depth == 0) { for (const Candidate3D& candidate : candidates) { if (candidate.score <= min_score) { // Return if the candidate is bad because the following candidate will // not have better score. return Candidate3D::Unsuccessful(); } const float low_resolution_score = (*search_parameters.low_resolution_matcher)( GetPoseFromCandidate(discrete_scans, candidate)); if (low_resolution_score >= options_.min_low_resolution_score()) { // We found the best candidate that passes the matching function. Candidate3D best_candidate = candidate; best_candidate.low_resolution_score = low_resolution_score; return best_candidate; } } // All candidates have good scores but none passes the matching function. return Candidate3D::Unsuccessful(); } Candidate3D best_high_resolution_candidate = Candidate3D::Unsuccessful(); best_high_resolution_candidate.score = min_score; for (const Candidate3D& candidate : candidates) { if (candidate.score <= min_score) { break; } std::vector<Candidate3D> higher_resolution_candidates; const int half_width = 1 << (candidate_depth - 1); for (int z : {0, half_width}) { if (candidate.offset.z() + z > search_parameters.linear_z_window_size) { break; } for (int y : {0, half_width}) { if (candidate.offset.y() + y > search_parameters.linear_xy_window_size) { break; } for (int x : {0, half_width}) { if (candidate.offset.x() + x > search_parameters.linear_xy_window_size) { break; } higher_resolution_candidates.emplace_back( candidate.scan_index, candidate.offset + Eigen::Array3i(x, y, z)); } } } ScoreCandidates(candidate_depth - 1, discrete_scans, &higher_resolution_candidates); best_high_resolution_candidate = std::max( best_high_resolution_candidate, BranchAndBound(search_parameters, discrete_scans, higher_resolution_candidates, candidate_depth - 1, best_high_resolution_candidate.score)); } return best_high_resolution_candidate; } } // namespace scan_matching } // namespace mapping } // namespace cartographer
43.694805
98
0.735077
sotnik-github
66e5e586be6f384bf06857a800b9d6927ffb16be
3,814
cpp
C++
vendor/android-tools/demangle/demangle.cpp
dylanh333/android-unmkbootimg
7c30a58b5bc3d208fbbbbc713717e2aae98df699
[ "MIT" ]
3
2018-04-01T18:35:29.000Z
2020-12-18T21:09:53.000Z
vendor/android-tools/demangle/demangle.cpp
dylanh333/android-unmkbootimg
7c30a58b5bc3d208fbbbbc713717e2aae98df699
[ "MIT" ]
2
2017-04-24T12:29:05.000Z
2017-05-09T12:27:10.000Z
vendor/android-tools/demangle/demangle.cpp
dylanh333/android-unmkbootimg
7c30a58b5bc3d208fbbbbc713717e2aae98df699
[ "MIT" ]
null
null
null
/* * Copyright (C) 2017 The Android Open Source Project * * Licensed 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 <getopt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <cctype> #include <string> #include <demangle.h> extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*); static void Usage(const char* prog_name) { printf("usage: %s [-c] [NAME_TO_DEMANGLE...]\n", prog_name); printf("\n"); printf("Demangles C++ mangled names if supplied on the command-line, or found\n"); printf("reading from stdin otherwise.\n"); printf("\n"); printf("-c\tCompare against __cxa_demangle\n"); printf("\n"); } static std::string DemangleWithCxa(const char* name) { const char* cxa_demangle = __cxa_demangle(name, nullptr, nullptr, nullptr); if (cxa_demangle == nullptr) { return name; } // The format of our demangler is slightly different from the cxa demangler // so modify the cxa demangler output. Specifically, for templates, remove // the spaces between '>' and '>'. std::string demangled_str; for (size_t i = 0; i < strlen(cxa_demangle); i++) { if (i > 2 && cxa_demangle[i] == '>' && std::isspace(cxa_demangle[i - 1]) && cxa_demangle[i - 2] == '>') { demangled_str.resize(demangled_str.size() - 1); } demangled_str += cxa_demangle[i]; } return demangled_str; } static void Compare(const char* name, const std::string& demangled_name) { std::string cxa_demangled_name(DemangleWithCxa(name)); if (cxa_demangled_name != demangled_name) { printf("\nMismatch!\n"); printf("\tmangled name: %s\n", name); printf("\tour demangle: %s\n", demangled_name.c_str()); printf("\tcxa demangle: %s\n", cxa_demangled_name.c_str()); exit(1); } } static int Filter(bool compare) { char* line = nullptr; size_t line_length = 0; while ((getline(&line, &line_length, stdin)) != -1) { char* p = line; char* name; while ((name = strstr(p, "_Z")) != nullptr) { // Output anything before the identifier. *name = 0; printf("%s", p); *name = '_'; // Extract the identifier. p = name; while (*p && (std::isalnum(*p) || *p == '_' || *p == '.' || *p == '$')) ++p; // Demangle and output. std::string identifier(name, p); std::string demangled_name = demangle(identifier.c_str()); printf("%s", demangled_name.c_str()); if (compare) Compare(identifier.c_str(), demangled_name); } // Output anything after the last identifier. printf("%s", p); } free(line); return 0; } int main(int argc, char** argv) { #ifdef __BIONIC__ const char* prog_name = getprogname(); #else const char* prog_name = argv[0]; #endif bool compare = false; int opt_char; while ((opt_char = getopt(argc, argv, "c")) != -1) { if (opt_char == 'c') { compare = true; } else { Usage(prog_name); return 1; } } // With no arguments, act as a filter. if (optind == argc) return Filter(compare); // Otherwise demangle each argument. while (optind < argc) { const char* name = argv[optind++]; std::string demangled_name = demangle(name); printf("%s\n", demangled_name.c_str()); if (compare) Compare(name, demangled_name); } return 0; }
28.462687
84
0.641059
dylanh333
66e8301ebdd578d6a0c203ed3642bdc9fbc94587
516
cpp
C++
variadic_templates/03.4.1.forwarding_simple.cpp
vnikolai/cpp_examples
a4686b0a0e0ed3da513621e309e8a511d9e44632
[ "MIT" ]
4
2021-09-21T16:23:00.000Z
2021-11-14T16:59:59.000Z
variadic_templates/03.4.1.forwarding_simple.cpp
vnikolai/cpp_examples
a4686b0a0e0ed3da513621e309e8a511d9e44632
[ "MIT" ]
null
null
null
variadic_templates/03.4.1.forwarding_simple.cpp
vnikolai/cpp_examples
a4686b0a0e0ed3da513621e309e8a511d9e44632
[ "MIT" ]
1
2021-09-21T17:06:17.000Z
2021-09-21T17:06:17.000Z
#include <iostream> #include <map> #include <tuple> #define PRINT_FUNCTION std::cout << __PRETTY_FUNCTION__ << std::endl struct A { A() { PRINT_FUNCTION; } A(const A&) { PRINT_FUNCTION; } A(A&&) { PRINT_FUNCTION; } }; template<typename... Args> void func(Args... args) { PRINT_FUNCTION; } template<typename... Args> void wrapper_simple(Args... args) { PRINT_FUNCTION; func(args...); } int main(int argc, const char** argv) { A a; wrapper_simple(a, std::move(a)); return 0; }
15.636364
68
0.631783
vnikolai
66e8c71ecbded88fa8638caa33c2f33e7c4a85d5
1,462
cpp
C++
snippets/cpp/VS_Snippets_CLR/math.atanx/CPP/atan.cpp
BohdanMosiyuk/samples
59d435ba9e61e0fc19f5176c96b1cdbd53596142
[ "CC-BY-4.0", "MIT" ]
2
2020-03-12T19:26:36.000Z
2022-01-10T21:45:33.000Z
snippets/cpp/VS_Snippets_CLR/math.atanx/CPP/atan.cpp
BohdanMosiyuk/samples
59d435ba9e61e0fc19f5176c96b1cdbd53596142
[ "CC-BY-4.0", "MIT" ]
555
2019-09-23T22:22:58.000Z
2021-07-15T18:51:12.000Z
snippets/cpp/VS_Snippets_CLR/math.atanx/CPP/atan.cpp
BohdanMosiyuk/samples
59d435ba9e61e0fc19f5176c96b1cdbd53596142
[ "CC-BY-4.0", "MIT" ]
3
2020-01-29T16:31:15.000Z
2021-08-24T07:00:15.000Z
//<snippet1> // This example demonstrates Math.Atan() // Math.Atan2() // Math.Tan() using namespace System; int main() { double x = 1.0; double y = 2.0; double angle; double radians; double result; // Calculate the tangent of 30 degrees. angle = 30; radians = angle * (Math::PI / 180); result = Math::Tan( radians ); Console::WriteLine( "The tangent of 30 degrees is {0}.", result ); // Calculate the arctangent of the previous tangent. radians = Math::Atan( result ); angle = radians * (180 / Math::PI); Console::WriteLine( "The previous tangent is equivalent to {0} degrees.", angle ); // Calculate the arctangent of an angle. String^ line1 = "{0}The arctangent of the angle formed by the x-axis and "; String^ line2 = "a vector to point ({0},{1}) is {2}, "; String^ line3 = "which is equivalent to {0} degrees."; radians = Math::Atan2( y, x ); angle = radians * (180 / Math::PI); Console::WriteLine( line1, Environment::NewLine ); Console::WriteLine( line2, x, y, radians ); Console::WriteLine( line3, angle ); } /* This example produces the following results: The tangent of 30 degrees is 0.577350269189626. The previous tangent is equivalent to 30 degrees. The arctangent of the angle formed by the x-axis and a vector to point (1,2) is 1.10714871779409, which is equivalent to 63.434948822922 degrees. */ //</snippet1>
30.458333
85
0.638167
BohdanMosiyuk
66e933ccfb90cdb9c2eea191569f2a23f2e94d15
1,001
cpp
C++
binary_tree/binary_tree/mid_num_heap/main.cpp
hcnhcn012/algorithms
856d3889dcaac65dd7ad7be1b50076393aa66088
[ "MIT" ]
1
2021-01-11T12:36:46.000Z
2021-01-11T12:36:46.000Z
binary_tree/binary_tree/mid_num_heap/main.cpp
hcnhcn012/algorithms
856d3889dcaac65dd7ad7be1b50076393aa66088
[ "MIT" ]
null
null
null
binary_tree/binary_tree/mid_num_heap/main.cpp
hcnhcn012/algorithms
856d3889dcaac65dd7ad7be1b50076393aa66088
[ "MIT" ]
null
null
null
// // main.cpp // mid_num_heap // // Created by ChengnanHu on 2/1/21. // #include <iostream> #include <queue> using namespace std; void Insert(int num); double GetMiddle(); priority_queue<int> max_heap; priority_queue<int, vector<int >, greater<int >> min_heap; int n = 0; int main(int argc, const char * argv[]) { vector<int> v = {5,2,3,4,1,6,7,0,8}; for (int i=0; i<v.size(); i++) { Insert(v[i]); } cout << GetMiddle() << endl; return 0; } void Insert(int num) { ++n; if (n == 1) max_heap.push(num); if (n == 2) min_heap.push(num); if (n % 2 == 0) { max_heap.push(num); min_heap.push(max_heap.top()); max_heap.pop(); } else { min_heap.push(num); max_heap.push(min_heap.top()); min_heap.pop(); } } double GetMiddle() { if (n % 2 == 0) return (double)((min_heap.top() + max_heap.top() + 0.0) / 2); else return (double)min_heap.top(); }
16.683333
69
0.531469
hcnhcn012
66ea9eba5315d728d1d4c4516081819217f8089d
181,043
cpp
C++
Sources/Rosetta/PlayMode/CardSets/DalaranCardsGen.cpp
Hearthstonepp/Hearthstonepp
ee17ae6de1ee0078dab29d75c0fbe727a14e850e
[ "MIT" ]
62
2017-08-21T14:11:00.000Z
2018-04-23T16:09:02.000Z
Sources/Rosetta/PlayMode/CardSets/DalaranCardsGen.cpp
Hearthstonepp/Hearthstonepp
ee17ae6de1ee0078dab29d75c0fbe727a14e850e
[ "MIT" ]
37
2017-08-21T11:13:07.000Z
2018-04-30T08:58:41.000Z
Sources/Rosetta/PlayMode/CardSets/DalaranCardsGen.cpp
Hearthstonepp/Hearthstonepp
ee17ae6de1ee0078dab29d75c0fbe727a14e850e
[ "MIT" ]
10
2017-08-21T03:44:12.000Z
2018-01-10T22:29:10.000Z
// This code is based on Sabberstone project. // Copyright (c) 2017-2021 SabberStone Team, darkfriend77 & rnilva // RosettaStone is hearthstone simulator using C++ with reinforcement learning. // Copyright (c) 2017-2021 Chris Ohk #include <Rosetta/PlayMode/Actions/CastSpell.hpp> #include <Rosetta/PlayMode/Actions/Choose.hpp> #include <Rosetta/PlayMode/Actions/Copy.hpp> #include <Rosetta/PlayMode/Actions/Generic.hpp> #include <Rosetta/PlayMode/Actions/Summon.hpp> #include <Rosetta/PlayMode/Auras/AdaptiveEffect.hpp> #include <Rosetta/PlayMode/Auras/SwitchingAura.hpp> #include <Rosetta/PlayMode/CardSets/DalaranCardsGen.hpp> #include <Rosetta/PlayMode/Cards/Cards.hpp> #include <Rosetta/PlayMode/Enchants/Enchants.hpp> #include <Rosetta/PlayMode/Enchants/OngoingEnchant.hpp> #include <Rosetta/PlayMode/Tasks/ComplexTask.hpp> #include <Rosetta/PlayMode/Tasks/SimpleTasks.hpp> #include <Rosetta/PlayMode/Zones/FieldZone.hpp> #include <Rosetta/PlayMode/Zones/HandZone.hpp> #include <Rosetta/PlayMode/Zones/SecretZone.hpp> #include <Rosetta/PlayMode/Zones/SetasideZone.hpp> #include <effolkronium/random.hpp> using Random = effolkronium::random_static; using namespace RosettaStone::PlayMode::SimpleTasks; namespace RosettaStone::PlayMode { using TagValues = std::vector<TagValue>; using PlayReqs = std::map<PlayReq, int>; using ChooseCardIDs = std::vector<std::string>; using Entourages = std::vector<std::string>; using TaskList = std::vector<std::shared_ptr<ITask>>; using EntityTypeList = std::vector<EntityType>; using SelfCondList = std::vector<std::shared_ptr<SelfCondition>>; using RelaCondList = std::vector<std::shared_ptr<RelaCondition>>; using EffectList = std::vector<std::shared_ptr<IEffect>>; void DalaranCardsGen::AddHeroes(std::map<std::string, CardDef>& cards) { (void)cards; } void DalaranCardsGen::AddHeroPowers(std::map<std::string, CardDef>& cards) { (void)cards; } void DalaranCardsGen::AddDruid(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ------------------------------------------ SPELL - DRUID // [DAL_256] The Forest's Aid - COST:8 // - Set: Dalaran, Rarity: Rare // - Spell School: Nature // -------------------------------------------------------- // Text: <b>Twinspell</b> Summon five 2/2 Treants. // -------------------------------------------------------- // GameTag: // - TWINSPELL_COPY = 52821 // - TWINSPELL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<SummonTask>("DAL_256t2", 5, SummonSide::SPELL)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 } }; cards.emplace("DAL_256", cardDef); // ------------------------------------------ SPELL - DRUID // [DAL_350] Crystal Power - COST:1 // - Faction: Neutral, Set: Dalaran, Rarity: Common // - Spell School: Nature // -------------------------------------------------------- // Text: <b>Choose One -</b> Deal 2 damage to a minion; // or Restore 5 Health. // -------------------------------------------------------- // GameTag: // - CHOOSE_ONE = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 } }; cardDef.property.chooseCardIDs = ChooseCardIDs{ "DAL_350a", "DAL_350b" }; cards.emplace("DAL_350", cardDef); // ------------------------------------------ SPELL - DRUID // [DAL_351] Blessing of the Ancients - COST:3 // - Set: Dalaran, Rarity: Common // - Spell School: Nature // -------------------------------------------------------- // Text: <b>Twinspell</b> Give your minions +1/+1. // -------------------------------------------------------- // GameTag: // - TWINSPELL_COPY = 54128 // - TWINSPELL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_351e", EntityType::MINIONS)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_351", cardDef); // ------------------------------------------ SPELL - DRUID // [DAL_352] Crystalsong Portal - COST:2 // - Set: Dalaran, Rarity: Epic // - Spell School: Nature // -------------------------------------------------------- // Text: <b>Discover</b> a Druid minion. // If your hand has no minions, keep all 3. // -------------------------------------------------------- // RefTag: // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::HasMinionInHand()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DiscoverTask>(CardType::MINION, CardClass::DRUID) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( false, TaskList{ std::make_shared<DiscoverTask>( CardType::MINION, CardClass::DRUID, Race::INVALID, Rarity::INVALID, ChoiceAction::HAND, 1, true) })); cards.emplace("DAL_352", cardDef); // ----------------------------------------- MINION - DRUID // [DAL_354] Acornbearer - COST:1 [ATK:2/HP:1] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Add two 1/1 Squirrels to your hand. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<AddCardTask>(EntityType::HAND, "DAL_354t", 2)); cards.emplace("DAL_354", cardDef); // ----------------------------------------- MINION - DRUID // [DAL_355] Lifeweaver - COST:3 [ATK:2/HP:5] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Whenever you restore Health, // add a random Druid spell to your hand. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::GIVE_HEAL)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY; cardDef.power.GetTrigger()->tasks = { std::make_shared<RandomCardTask>(CardType::SPELL, CardClass::DRUID), std::make_shared<AddStackToTask>(EntityType::HAND) }; cards.emplace("DAL_355", cardDef); // ----------------------------------------- MINION - DRUID // [DAL_357] Lucentbark - COST:8 [ATK:4/HP:8] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Taunt</b> // <b>Deathrattle:</b> Go dormant. // Restore 5 Health to awaken this minion. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - TAUNT = 1 // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<SummonTask>("DAL_357t", SummonSide::DEATHRATTLE)); cards.emplace("DAL_357", cardDef); // ----------------------------------------- MINION - DRUID // [DAL_732] Keeper Stalladris - COST:2 [ATK:2/HP:3] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: After you cast a <b>Choose One</b> spell, // add copies of both choices to your hand. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_CAST)); cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsChooseOneCard()) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<CustomTask>( [](Player* player, [[maybe_unused]] Entity* source, [[maybe_unused]] Playable* target) { const std::shared_ptr<IEffect> costEffect = Cost::Effect(EffectOperator::SET, target->card->GetCost()); for (auto& chooseCardID : target->card->chooseCardIDs) { const auto chooseCard = Entity::GetFromCard( player, Cards::FindCardByID(chooseCardID), std::nullopt, player->GetSetasideZone()); const auto copy = Generic::Copy(player, chooseCard, ZoneType::HAND); costEffect->ApplyTo(copy); } }) }; cards.emplace("DAL_732", cardDef); // ------------------------------------------ SPELL - DRUID // [DAL_733] Dreamway Guardians - COST:2 // - Faction: Neutral, Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Summon two 1/2 Dryads with <b>Lifesteal</b>. // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // -------------------------------------------------------- // RefTag: // - LIFESTEAL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<SummonTask>("DAL_733t", 2)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 } }; cards.emplace("DAL_733", cardDef); // ----------------------------------------- MINION - DRUID // [DAL_799] Crystal Stag - COST:5 [ATK:4/HP:4] // - Race: Beast, Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Rush</b>. <b>Battlecry:</b> If you've restored // 5 Health this game, summon a copy of this. // @ <i>({0} left!)</i>@ <i>(Ready!)</i> // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // - RUSH = 1 // - PLAYER_TAG_THRESHOLD_TAG_ID = 958 // - PLAYER_TAG_THRESHOLD_VALUE = 5 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::CheckThreshold(RelaSign::GEQ)) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<SummonCopyTask>( EntityType::SOURCE, false, false, SummonSide::RIGHT) })); cards.emplace("DAL_799", cardDef); } void DalaranCardsGen::AddDruidNonCollect(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ----------------------------------------- MINION - DRUID // [DAL_256t2] Treant (*) - COST:2 [ATK:2/HP:2] // - Set: Dalaran // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_256t2", cardDef); // ------------------------------------------ SPELL - DRUID // [DAL_256ts] The Forest's Aid (*) - COST:8 // - Set: Dalaran, Rarity: Rare // - Spell School: Nature // -------------------------------------------------------- // Text: Summon five 2/2 Treants. // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<SummonTask>("DAL_256t2", 5, SummonSide::SPELL)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 } }; cards.emplace("DAL_256ts", cardDef); // ------------------------------------------ SPELL - DRUID // [DAL_350a] Piercing Thorns (*) - COST:1 // - Faction: Neutral, Set: Dalaran // -------------------------------------------------------- // Text: Deal 2 damage to a minion. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DamageTask>(EntityType::TARGET, 2, true)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_350a", cardDef); // ------------------------------------------ SPELL - DRUID // [DAL_350b] Healing Blossom (*) - COST:1 // - Faction: Neutral, Set: Dalaran, // -------------------------------------------------------- // Text: Restore 5 Health. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<HealTask>(EntityType::TARGET, 5)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 } }; cards.emplace("DAL_350b", cardDef); // ------------------------------------------ SPELL - DRUID // [DAL_351ts] Blessing of the Ancients (*) - COST:3 // - Set: Dalaran, Rarity: Common // - Spell School: Nature // -------------------------------------------------------- // Text: Give your minions +1/+1. // -------------------------------------------------------- // PlayReq: // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_351e", EntityType::MINIONS)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_351ts", cardDef); // ----------------------------------------- MINION - DRUID // [DAL_354t] Squirrel (*) - COST:1 [ATK:1/HP:1] // - Race: Beast, Set: Dalaran // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_354t", cardDef); // ----------------------------------------- MINION - DRUID // [DAL_357t] Spirit of Lucentbark (*) - COST:11 [ATK:0/HP:1] // - Set: Dalaran // -------------------------------------------------------- // Text: When you restore 5 Health, awaken this minion. // <i>(@ left!)</i> // -------------------------------------------------------- // GameTag: // - TAG_SCRIPT_DATA_NUM_1 = 5 // - HIDE_STATS = 1 // - UNTOUCHABLE = 1 // - SCORE_VALUE_1 = 5 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TAKE_HEAL)); cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsEventSourceFriendly()) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<GetEventNumberTask>(), std::make_shared<GetGameTagTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_2, 0, 1), std::make_shared<MathNumberIndexTask>(0, 1, MathOperation::ADD), std::make_shared<NumberConditionTask>(5, RelaSign::GEQ), std::make_shared<FlagTask>( true, TaskList{ std::make_shared<ChangeEntityTask>("DAL_357") }), std::make_shared<FlagTask>( false, TaskList{ std::make_shared<SetGameTagNumberTask>( EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_2) }) }; cards.emplace("DAL_357t", cardDef); // ----------------------------------------- MINION - DRUID // [DAL_733t] Crystal Dryad (*) - COST:1 [ATK:1/HP:2] // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Lifesteal</b> // -------------------------------------------------------- // GameTag: // - LIFESTEAL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_733t", cardDef); } void DalaranCardsGen::AddHunter(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ----------------------------------------- SPELL - HUNTER // [DAL_371] Marked Shot - COST:4 // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: Deal 4 damage to a minion. <b>Discover</b> a spell. // -------------------------------------------------------- // GameTag: // - DISCOVER = 1 // - USE_DISCOVER_VISUALS = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- // RefTag: // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DamageTask>(EntityType::TARGET, 4, true)); cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(DiscoverType::SPELL)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_371", cardDef); // ---------------------------------------- MINION - HUNTER // [DAL_372] Arcane Fletcher - COST:4 [ATK:3/HP:3] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Whenever you play a 1-Cost minion, // draw a spell from your deck. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::PLAY_MINION)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY; cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsCost(1)) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<IncludeTask>(EntityType::DECK), std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsSpell()) }), std::make_shared<RandomTask>(EntityType::STACK, 1), std::make_shared<DrawStackTask>() }; cards.emplace("DAL_372", cardDef); // ----------------------------------------- SPELL - HUNTER // [DAL_373] Rapid Fire - COST:2 // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Twinspell</b> Deal 2 damage. // -------------------------------------------------------- // GameTag: // - TWINSPELL_COPY = 54143 // - TWINSPELL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DamageTask>(EntityType::TARGET, 2, true)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 } }; cards.emplace("DAL_373", cardDef); // ---------------------------------------- MINION - HUNTER // [DAL_376] Oblivitron - COST:6 [ATK:3/HP:4] // - Race: Mechanical, Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Summon a Mech from your hand // and trigger its <b>Deathrattle</b>. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<IncludeTask>(EntityType::HAND)); cardDef.power.AddDeathrattleTask(std::make_shared<FilterStackTask>( SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsRace(Race::MECHANICAL)) })); cardDef.power.AddDeathrattleTask( std::make_shared<RandomTask>(EntityType::STACK, 1)); cardDef.power.AddDeathrattleTask(std::make_shared<SummonStackTask>(true)); cardDef.power.AddDeathrattleTask( std::make_shared<ActivateDeathrattleTask>(EntityType::STACK)); cards.emplace("DAL_376", cardDef); // ----------------------------------------- SPELL - HUNTER // [DAL_377] Nine Lives - COST:3 // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Discover</b> a friendly <b>Deathrattle</b> minion that // died this game. Also trigger its <b>Deathrattle</b>. // -------------------------------------------------------- // PlayReq: // - REQ_FRIENDLY_DEATHRATTLE_MINION_DIED_THIS_GAME = 0 // -------------------------------------------------------- // RefTag: // - DEATHRATTLE = 1 // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(DiscoverType::DEATHRATTLE_MINION_DIED)); cardDef.power.AddAfterChooseTask( std::make_shared<ActivateDeathrattleTask>(EntityType::STACK)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_FRIENDLY_DEATHRATTLE_MINION_DIED_THIS_GAME, 0 } }; cards.emplace("DAL_377", cardDef); // ----------------------------------------- SPELL - HUNTER // [DAL_378] Unleash the Beast - COST:6 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Twinspell</b> Summon a 5/5 Wyvern with <b>Rush</b>. // -------------------------------------------------------- // GameTag: // - TWINSPELL_COPY = 54145 // - TWINSPELL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<SummonTask>("DAL_378t1")); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 } }; cards.emplace("DAL_378", cardDef); // ---------------------------------------- MINION - HUNTER // [DAL_379] Vereesa Windrunner - COST:7 [ATK:5/HP:6] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> Equip Thori'dal, the Stars' Fury. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<WeaponTask>("DAL_379t")); cards.emplace("DAL_379", cardDef); // ---------------------------------------- MINION - HUNTER // [DAL_587] Shimmerfly - COST:1 [ATK:1/HP:1] // - Race: Beast, Set: Dalaran, Rarity: rare // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Add a random Hunter spell to your hand. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<RandomCardTask>(CardType::SPELL, CardClass::HUNTER)); cardDef.power.AddDeathrattleTask( std::make_shared<AddStackToTask>(EntityType::HAND)); cards.emplace("DAL_587", cardDef); // ----------------------------------------- SPELL - HUNTER // [DAL_589] Hunting Party - COST:5 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Copy all Beasts in your hand. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::HAND)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsRace(Race::BEAST)) })); cardDef.power.AddPowerTask( std::make_shared<CopyTask>(EntityType::STACK, ZoneType::HAND)); cards.emplace("DAL_589", cardDef); // ---------------------------------------- MINION - HUNTER // [DAL_604] Ursatron - COST:3 [ATK:3/HP:3] // - Race: Mechanical, Faction: Neutral, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Draw a Mech from your deck. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<DrawRaceMinionTask>(Race::MECHANICAL, 1, false)); cards.emplace("DAL_604", cardDef); } void DalaranCardsGen::AddHunterNonCollect(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ----------------------------------------- SPELL - HUNTER // [DAL_373ts] Rapid Fire (*) - COST:2 // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: Deal 2 damage. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DamageTask>(EntityType::TARGET, 2, true)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 } }; cards.emplace("DAL_373ts", cardDef); // ---------------------------------------- MINION - HUNTER // [DAL_378t1] Wyvern (*) - COST:5 [ATK:5/HP:5] // - Race: Beast, Set: Dalaran // -------------------------------------------------------- // Text: <b>Rush</b> // -------------------------------------------------------- // GameTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_378t1", cardDef); // ----------------------------------------- SPELL - HUNTER // [DAL_378ts] Unleash the Beast (*) - COST:6 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Summon a 5/5 Wyvern with <b>Rush</b>. // -------------------------------------------------------- // GameTag: // - HIDE_ATTACK = 1 // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<SummonTask>("DAL_378t1")); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 } }; cards.emplace("DAL_378ts", cardDef); // ----------------------------------- ENCHANTMENT - HUNTER // [DAL_379e] Stars' Fury (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: You have <b>Spell Damage +2</b> this turn. // -------------------------------------------------------- // GameTag: // - TAG_ONE_TURN_EFFECT = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant( std::make_shared<Enchant>(GameTag::SPELLPOWER, EffectOperator::ADD, 2)); cardDef.power.GetEnchant()->isOneTurnEffect = true; cards.emplace("DAL_379e", cardDef); // ---------------------------------------- WEAPON - HUNTER // [DAL_379t] Thori'dal, the Stars' Fury (*) - COST:3 [ATK:2/HP:0] // - Set: Dalaran // -------------------------------------------------------- // Text: After your hero attacks, // gain <b>Spell Damage +2</b> this turn. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - DURABILITY = 3 // -------------------------------------------------------- // RefTag: // - SPELLPOWER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_ATTACK)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::HERO; cardDef.power.GetTrigger()->tasks = { std::make_shared<AddEnchantmentTask>( "DAL_379e", EntityType::HERO) }; cards.emplace("DAL_379t", cardDef); } void DalaranCardsGen::AddMage(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ------------------------------------------ MINION - MAGE // [DAL_163] Messenger Raven - COST:3 [ATK:3/HP:2] // - Race: Beast, Faction: Neutral, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> <b>Discover</b> a Mage minion. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(CardType::MINION, CardClass::MAGE)); cards.emplace("DAL_163", cardDef); // ------------------------------------------- SPELL - MAGE // [DAL_177] Conjurer's Calling - COST:3 // - Set: Dalaran, Rarity: Rare // - Spell School: Arcane // -------------------------------------------------------- // Text: <b>Twinspell</b> Destroy a minion. // Summon 2 minions of the same Cost to replace it. // -------------------------------------------------------- // GameTag: // - TWINSPELL_COPY = 52637 // - TWINSPELL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<GetGameTagTask>(EntityType::TARGET, GameTag::COST)); cardDef.power.AddPowerTask( std::make_shared<DestroyTask>(EntityType::TARGET, true)); cardDef.power.AddPowerTask(std::make_shared<EnqueueTask>( TaskList{ std::make_shared<ConditionTask>( EntityType::TARGET, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsFriendly()) }), std::make_shared<FlagTask>( true, TaskList{ std::make_shared<RandomMinionNumberTask>( GameTag::COST), std::make_shared<SummonTask>() }), std::make_shared<FlagTask>( false, TaskList{ std::make_shared<RandomMinionNumberTask>( GameTag::COST, true), std::make_shared<SummonOpTask>() }) }, 2)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_177", cardDef); // ------------------------------------------ MINION - MAGE // [DAL_182] Magic Dart Frog - COST:2 [ATK:1/HP:3] // - Race: Beast, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: After you cast a spell, deal 1 damage to a random enemy minion. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_CAST)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY; cardDef.power.GetTrigger()->tasks = { std::make_shared<IncludeTask>(EntityType::ENEMY_MINIONS), std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsNotDead()) }), std::make_shared<RandomTask>(EntityType::STACK, 1), std::make_shared<DamageTask>(EntityType::STACK, 1) }; cards.emplace("DAL_182", cardDef); // ------------------------------------------ MINION - MAGE // [DAL_575] Khadgar - COST:2 [ATK:2/HP:2] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: Your cards that summon minions summon twice as many. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_SUMMON)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY_EVENT_SOURCE; cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>([=](Playable* playable) -> bool { return playable->game->currentEventData->eventSource != playable && playable->GetGameTag(GameTag::COPIED_BY_KHADGAR) != 1; }) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<CustomTask>( []([[maybe_unused]] Player* player, [[maybe_unused]] Entity* source, Playable* target) { if (target->player->GetFieldZone()->IsFull()) { return; } std::map<GameTag, int> gameTags; gameTags.emplace(GameTag::COPIED_BY_KHADGAR, 1); const auto entity = Entity::GetFromCard( target->player, target->card, gameTags, player->GetFieldZone()); Generic::Summon(dynamic_cast<Minion*>(entity), target->GetZonePosition() + 1, source); }) }; cards.emplace("DAL_575", cardDef); // ------------------------------------------ MINION - MAGE // [DAL_576] Kirin Tor Tricaster - COST:4 [ATK:3/HP:3] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Spell Damage +3</b> Your spells cost (1) more. // -------------------------------------------------------- // GameTag: // - SPELLPOWER = 3 // - AURA = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddAura(std::make_shared<Aura>(AuraType::HAND, "DAL_576e")); { const auto aura = dynamic_cast<Aura*>(cardDef.power.GetAura()); aura->condition = std::make_shared<SelfCondition>(SelfCondition::IsSpell()); } cards.emplace("DAL_576", cardDef); // ------------------------------------------- SPELL - MAGE // [DAL_577] Ray of Frost - COST:1 // - Set: Dalaran, Rarity: Common // - Spell School: Frost // -------------------------------------------------------- // Text: <b>Twinspell</b> <b>Freeze</b> a minion. // If it's already <b>Frozen</b>, deal 2 damage to it. // -------------------------------------------------------- // GameTag: // - TWINSPELL_COPY = 54193 // - TWINSPELL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- // RefTag: // - FREEZE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::TARGET, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsFrozen()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DamageTask>(EntityType::TARGET, 2, true) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( false, TaskList{ std::make_shared<FreezeTask>(EntityType::TARGET) })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_577", cardDef); // ------------------------------------------- SPELL - MAGE // [DAL_578] Power of Creation - COST:8 // - Set: Dalaran, Rarity: Epic // - Spell School: Arcane // -------------------------------------------------------- // Text: <b>Discover</b> a 6-Cost minion. Summon two copies of it. // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // -------------------------------------------------------- // RefTag: // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(DiscoverType::SIX_COST_MINION_SUMMON)); cardDef.power.AddAfterChooseTask( std::make_shared<CopyTask>(EntityType::TARGET, ZoneType::PLAY)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 } }; cards.emplace("DAL_578", cardDef); // ------------------------------------------ MINION - MAGE // [DAL_603] Mana Cyclone - COST:2 [ATK:2/HP:2] // - Race: Elemental, Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Battlecry:</b> For each spell you've cast this turn, // add a random Mage spell to your hand. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<FuncNumberTask>([](Playable* playable) { int count = 0; for (auto& card : playable->player->cardsPlayedThisTurn) { if (card->GetCardType() == CardType::SPELL) { ++count; } } return count; })); cardDef.power.AddPowerTask(std::make_shared<EnqueueNumberTask>(TaskList{ std::make_shared<RandomCardTask>(CardType::SPELL, CardClass::MAGE), std::make_shared<AddStackToTask>(EntityType::HAND) })); cards.emplace("DAL_603", cardDef); // ------------------------------------------- SPELL - MAGE // [DAL_608] Magic Trick - COST:1 // - Set: Dalaran, Rarity: Rare // - Spell School: Arcane // -------------------------------------------------------- // Text: <b>Discover</b> a spell that costs (3) or less. // -------------------------------------------------------- // RefTag: // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(DiscoverType::SPELL_THREE_COST_OR_LESS)); cards.emplace("DAL_608", cardDef); // ------------------------------------------ MINION - MAGE // [DAL_609] Kalecgos - COST:9 [ATK:4/HP:12] // - Race: Dragon, Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: Your first spell each turn costs (0). // <b>Battlecry:</b> <b>Discover</b> a spell. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // - AURA = 1 // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddAura(std::make_shared<SwitchingAura>( AuraType::HAND, SelfCondition::SpellsCastThisTurn(0), TriggerType::CAST_SPELL, EffectList{ Effects::SetCost(0) })); { const auto aura = dynamic_cast<SwitchingAura*>(cardDef.power.GetAura()); aura->condition = std::make_shared<SelfCondition>(SelfCondition::IsSpell()); } cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(DiscoverType::SPELL)); cards.emplace("DAL_609", cardDef); } void DalaranCardsGen::AddMageNonCollect(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ------------------------------------------- SPELL - MAGE // [DAL_177ts] Conjurer's Calling (*) - COST:3 // - Set: Dalaran, Rarity: Rare // - Spell School: Arcane // -------------------------------------------------------- // Text: Destroy a minion. // Summon 2 minions of the same Cost to replace it. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<GetGameTagTask>(EntityType::TARGET, GameTag::COST)); cardDef.power.AddPowerTask( std::make_shared<DestroyTask>(EntityType::TARGET, true)); cardDef.power.AddPowerTask(std::make_shared<EnqueueTask>( TaskList{ std::make_shared<ConditionTask>( EntityType::TARGET, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsFriendly()) }), std::make_shared<FlagTask>( true, TaskList{ std::make_shared<RandomMinionNumberTask>( GameTag::COST), std::make_shared<SummonTask>() }), std::make_shared<FlagTask>( false, TaskList{ std::make_shared<RandomMinionNumberTask>( GameTag::COST, true), std::make_shared<SummonOpTask>() }) }, 2)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_177ts", cardDef); // ------------------------------------------- SPELL - MAGE // [DAL_577ts] Ray of Frost (*) - COST:1 // - Set: Dalaran, Rarity: Common // - Spell School: Frost // -------------------------------------------------------- // Text: <b>Freeze</b> a minion. // If it's already <b>Frozen</b>, deal 2 damage to it. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- // RefTag: // - FREEZE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::TARGET, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsFrozen()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DamageTask>(EntityType::TARGET, 2, true) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( false, TaskList{ std::make_shared<FreezeTask>(EntityType::TARGET) })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_577ts", cardDef); } void DalaranCardsGen::AddPaladin(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ---------------------------------------- SPELL - PALADIN // [DAL_141] Desperate Measures - COST:1 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Twinspell</b> Cast a random Paladin <b>Secret</b>. // -------------------------------------------------------- // GameTag: // - TWINSPELL_COPY = 54129 // - TWINSPELL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_SECRET_ZONE_CAP_FOR_NON_SECRET = 0 // -------------------------------------------------------- // RefTag: // - SECRET = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<CustomTask>( [](Player* player, [[maybe_unused]] Entity* source, [[maybe_unused]] Playable* target) { auto activeSecrets = player->GetSecretZone()->GetAll(); auto allCards = player->game->GetFormatType() == FormatType::STANDARD ? Cards::GetAllStandardCards() : Cards::GetAllWildCards(); std::vector<Card*> secrets; for (auto& card : allCards) { if (card->GetCardClass() == CardClass::PALADIN && card->IsSecret()) { bool isExist = false; for (auto& secret : activeSecrets) { if (card->id == secret->card->id) { isExist = true; break; } } if (!isExist) { secrets.emplace_back(card); } } } const auto idx = Random::get<std::size_t>(0, secrets.size() - 1); Playable* playable = Entity::GetFromCard(player, secrets.at(idx)); Generic::CastSpell(player, dynamic_cast<Spell*>(playable), nullptr, 0); })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_SECRET_ZONE_CAP_FOR_NON_SECRET, 0 } }; cards.emplace("DAL_141", cardDef); // --------------------------------------- MINION - PALADIN // [DAL_146] Bronze Herald - COST:3 [ATK:3/HP:2] // - Race: Dragon, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Add two 4/4 Dragons to your hand. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<AddCardTask>(EntityType::HAND, "DAL_146t", 2)); cards.emplace("DAL_146", cardDef); // --------------------------------------- MINION - PALADIN // [DAL_147] Dragon Speaker - COST:5 [ATK:3/HP:5] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Battlecry:</b> Give all Dragons in your hand +3/+3. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::HAND)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>( SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsRace(Race::DRAGON)) })); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_147e", EntityType::STACK)); cards.emplace("DAL_147", cardDef); // ---------------------------------------- SPELL - PALADIN // [DAL_568] Lightforged Blessing - COST:2 // - Set: Dalaran, Rarity: Common // - Spell School: Holy // -------------------------------------------------------- // Text: <b>Twinspell</b> Give a friendly minion <b>Lifesteal</b>. // -------------------------------------------------------- // GameTag: // - TWINSPELL_COPY = 54189 // - TWINSPELL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // - REQ_FRIENDLY_TARGET = 0 // -------------------------------------------------------- // RefTag: // - LIFESTEAL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_568e", EntityType::TARGET)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 } }; cards.emplace("DAL_568", cardDef); // ---------------------------------------- SPELL - PALADIN // [DAL_570] Never Surrender! - COST:1 // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Secret:</b> When your opponent casts a spell, // give your minions +2 Health. // -------------------------------------------------------- // GameTag: // - SECRET = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::CAST_SPELL)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::ENEMY_SPELLS; cardDef.power.GetTrigger()->tasks = ComplexTask::ActivateSecret( TaskList{ std::make_shared<AddEnchantmentTask>("DAL_570e", EntityType::MINIONS) }); cards.emplace("DAL_570", cardDef); // --------------------------------------- WEAPON - PALADIN // [DAL_571] Mysterious Blade - COST:2 [ATK:2/HP:0] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Battlecry:</b> If you control a // <b>Secret</b>, gain +1 Attack. // -------------------------------------------------------- // GameTag: // - DURABILITY = 2 // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - SECRET = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsControllingSecret()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<AddEnchantmentTask>( "DAL_571e", EntityType::SOURCE) })); cards.emplace("DAL_571", cardDef); // --------------------------------------- MINION - PALADIN // [DAL_573] Commander Rhyssa - COST:3 [ATK:4/HP:3] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: Your <b>Secrets</b> trigger twice. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - AURA = 1 // -------------------------------------------------------- // RefTag: // - SECRET = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddAura(std::make_shared<Aura>( AuraType::PLAYER, EffectList{ std::make_shared<Effect>(GameTag::EXTRA_TRIGGER_SECRET, EffectOperator::SET, 1) })); cards.emplace("DAL_573", cardDef); // --------------------------------------- MINION - PALADIN // [DAL_581] Nozari - COST:10 [ATK:4/HP:12] // - Race: Dragon, Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> Restore both heroes to full Health. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // - AFFECTED_BY_HEALING_DOES_DAMAGE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<HealFullTask>(EntityType::HEROES)); cards.emplace("DAL_581", cardDef); // ---------------------------------------- SPELL - PALADIN // [DAL_727] Call to Adventure - COST:3 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Draw the lowest Cost minion from your deck. Give it +2/+2. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DrawMinionTask>(DrawMinionType::LOWEST_COST, 1, true)); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_727e", EntityType::STACK)); cards.emplace("DAL_727", cardDef); // ---------------------------------------- SPELL - PALADIN // [DAL_731] Duel! - COST:5 // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Summon a minion from each player's deck. They fight! // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::DECK)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsMinion()) })); cardDef.power.AddPowerTask( std::make_shared<RandomTask>(EntityType::STACK, 1)); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::STACK, GameTag::ENTITY_ID)); cardDef.power.AddPowerTask(std::make_shared<SummonStackTask>(true)); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::ENEMY_DECK)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsMinion()) })); cardDef.power.AddPowerTask( std::make_shared<RandomTask>(EntityType::STACK, 1)); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::STACK, GameTag::ENTITY_ID, 0, 1)); cardDef.power.AddPowerTask(std::make_shared<SummonStackTask>(true)); cardDef.power.AddPowerTask(std::make_shared<AttackTask>( EntityType::STACK_NUM0, EntityType::STACK_NUM1)); cards.emplace("DAL_731", cardDef); } void DalaranCardsGen::AddPaladinNonCollect( std::map<std::string, CardDef>& cards) { CardDef cardDef; // ---------------------------------------- SPELL - PALADIN // [DAL_141ts] Desperate Measures (*) - COST:1 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Cast a random Paladin <b>Secret</b>. // -------------------------------------------------------- // PlayReq: // - REQ_SECRET_ZONE_CAP_FOR_NON_SECRET = 0 // -------------------------------------------------------- // RefTag: // - SECRET = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<CustomTask>( [](Player* player, [[maybe_unused]] Entity* source, [[maybe_unused]] Playable* target) { auto activeSecrets = player->GetSecretZone()->GetAll(); auto allCards = player->game->GetFormatType() == FormatType::STANDARD ? Cards::GetAllStandardCards() : Cards::GetAllWildCards(); std::vector<Card*> secrets; for (auto& card : allCards) { if (card->GetCardClass() == CardClass::PALADIN && card->IsSecret()) { bool isExist = false; for (auto& secret : activeSecrets) { if (card->id == secret->card->id) { isExist = true; break; } } if (!isExist) { secrets.emplace_back(card); } } } const auto idx = Random::get<std::size_t>(0, secrets.size() - 1); Playable* playable = Entity::GetFromCard(player, secrets.at(idx)); Generic::CastSpell(player, dynamic_cast<Spell*>(playable), nullptr, 0); })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_SECRET_ZONE_CAP_FOR_NON_SECRET, 0 } }; cards.emplace("DAL_141ts", cardDef); // --------------------------------------- MINION - PALADIN // [DAL_146t] Bronze Dragon (*) - COST:4 [ATK:4/HP:4] // - Race: Dragon, Set: Dalaran // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_146t", cardDef); // ---------------------------------- ENCHANTMENT - PALADIN // [DAL_568e] Lightforged Blessing (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Lifesteal</b> // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_568e")); cards.emplace("DAL_568e", cardDef); // ---------------------------------------- SPELL - PALADIN // [DAL_568ts] Lightforged Blessing (*) - COST:2 // - Set: Dalaran, Rarity: Common // - Spell School: Holy // -------------------------------------------------------- // Text: Give a friendly minion <b>Lifesteal</b>. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // - REQ_FRIENDLY_TARGET = 0 // -------------------------------------------------------- // RefTag: // - LIFESTEAL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_568e", EntityType::TARGET)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 } }; cards.emplace("DAL_568ts", cardDef); // ---------------------------------- ENCHANTMENT - PALADIN // [DAL_571e] Mysterious (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +1 Attack. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_571e")); cards.emplace("DAL_571e", cardDef); } void DalaranCardsGen::AddPriest(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ----------------------------------------- SPELL - PRIEST // [DAL_011] Lazul's Scheme - COST:0 // - Set: Dalaran, Rarity: Epic // - Spell School: Shadow // -------------------------------------------------------- // Text: Reduce the Attack of an enemy minion by // @ until your next turn. <i>(Upgrades each turn!)</i> // -------------------------------------------------------- // GameTag: // - TAG_SCRIPT_DATA_NUM_1 = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // - REQ_ENEMY_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1)); cardDef.power.AddPowerTask(std::make_shared<AddEnchantmentTask>( "DAL_011e", EntityType::TARGET, true)); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->triggerActivation = TriggerActivation::HAND; cardDef.power.GetTrigger()->tasks = { std::make_shared<GetGameTagTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1), std::make_shared<MathAddTask>(1), std::make_shared<SetGameTagNumberTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1) }; cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_ENEMY_TARGET, 0 } }; cards.emplace("DAL_011", cardDef); // ---------------------------------------- MINION - PRIEST // [DAL_030] Shadowy Figure - COST:2 [ATK:2/HP:2] // - Set: Dalaran, Rarity: Epic // - Spell School: Shadow // -------------------------------------------------------- // Text: <b>Battlecry:</b> Transform into a 2/2 copy of // a friendly <b>Deathrattle</b> minion. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_IF_AVAILABLE = 0 // - REQ_MINION_TARGET = 0 // - REQ_FRIENDLY_TARGET = 0 // - REQ_TARGET_WITH_DEATHRATTLE = 0 // -------------------------------------------------------- // RefTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<TransformCopyTask>(false, true)); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_030e", EntityType::STACK)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_IF_AVAILABLE, 0 }, { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 }, { PlayReq::REQ_TARGET_WITH_DEATHRATTLE, 0 } }; cards.emplace("DAL_030", cardDef); // ---------------------------------------- MINION - PRIEST // [DAL_039] Convincing Infiltrator - COST:5 [ATK:2/HP:6] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Taunt</b> // <b>Deathrattle:</b> Destroy a random enemy minion. // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask(ComplexTask::DestroyRandomEnemyMinion(1)); cards.emplace("DAL_039", cardDef); // ---------------------------------------- MINION - PRIEST // [DAL_040] Hench-Clan Shadequill - COST:4 [ATK:4/HP:7] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Restore 5 Health to the enemy hero. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // - AFFECTED_BY_HEALING_DOES_DAMAGE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<HealTask>(EntityType::ENEMY_HERO, 5)); cards.emplace("DAL_040", cardDef); // ----------------------------------------- SPELL - PRIEST // [DAL_065] Unsleeping Soul - COST:4 // - Set: Dalaran, Rarity: Common // - Spell School: Shadow // -------------------------------------------------------- // Text: <b>Silence</b> a friendly minion, then summon a copy of it. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // - REQ_FRIENDLY_TARGET = 0 // -------------------------------------------------------- // RefTag: // - SILENCE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<SilenceTask>(EntityType::TARGET)); cardDef.power.AddPowerTask( std::make_shared<SummonCopyTask>(EntityType::TARGET)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 } }; cards.emplace("DAL_065", cardDef); // ---------------------------------------- MINION - PRIEST // [DAL_413] EVIL Conscripter - COST:2 [ATK:2/HP:2] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Add a <b>Lackey</b> to your hand. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- // RefTag: // - MARK_OF_EVIL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask(std::make_shared<AddLackeyTask>(1)); cards.emplace("DAL_413", cardDef); // ---------------------------------------- MINION - PRIEST // [DAL_721] Catrina Muerte - COST:8 [ATK:6/HP:8] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: At the end of your turn, summon a friendly minion // that died this game. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->tasks = { std::make_shared<IncludeTask>(EntityType::GRAVEYARD), std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsDead()) }), std::make_shared<RandomTask>(EntityType::STACK, 1), std::make_shared<CopyTask>(EntityType::STACK, ZoneType::PLAY) }; cards.emplace("DAL_721", cardDef); // ----------------------------------------- SPELL - PRIEST // [DAL_723] Forbidden Words - COST:0 // - Set: Dalaran, Rarity: Rare // - Spell School: Shadow // -------------------------------------------------------- // Text: Spend all your Mana. Destroy a minion with that // much Attack or less. // -------------------------------------------------------- // PlayReq: // - REQ_MINION_TARGET = 0 // - REQ_TARGET_TO_PLAY = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<GetPlayerManaTask>()); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::TARGET, GameTag::ATK, 0, 1)); cardDef.power.AddPowerTask( std::make_shared<NumberConditionTask>(RelaSign::GEQ)); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DestroyTask>(EntityType::TARGET) })); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::SOURCE)); cardDef.power.AddPowerTask(std::make_shared<FuncPlayableTask>( [=](const std::vector<Playable*>& playables) { playables[0]->player->SetUsedMana( playables[0]->player->GetTotalMana() + playables[0]->player->GetTemporaryMana() - playables[0]->player->GetOverloadLocked()); return std::vector<Playable*>{}; })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_TARGET_TO_PLAY, 0 } }; cards.emplace("DAL_723", cardDef); // ----------------------------------------- SPELL - PRIEST // [DAL_724] Mass Resurrection - COST:9 // - Set: Dalaran, Rarity: Rare // - Spell School: Holy // -------------------------------------------------------- // Text: Summon 3 friendly minions that died this game. // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // - REQ_FRIENDLY_MINION_DIED_THIS_GAME = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::GRAVEYARD)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsDead()) })); cardDef.power.AddPowerTask( std::make_shared<RandomTask>(EntityType::STACK, 3)); cardDef.power.AddPowerTask( std::make_shared<CopyTask>(EntityType::STACK, ZoneType::PLAY)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 }, { PlayReq::REQ_FRIENDLY_MINION_DIED_THIS_GAME, 0 } }; cards.emplace("DAL_724", cardDef); // ---------------------------------------- MINION - PRIEST // [DAL_729] Madame Lazul - COST:3 [ATK:3/HP:2] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> <b>Discover</b> a // copy of a card in your opponent's hand. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(DiscoverType::MADAME_LAZUL)); cards.emplace("DAL_729", cardDef); } void DalaranCardsGen::AddPriestNonCollect(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ----------------------------------- ENCHANTMENT - PRIEST // [DAL_030e] Shade (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: 2/2. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_030e")); cards.emplace("DAL_030e", cardDef); } void DalaranCardsGen::AddRogue(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ------------------------------------------ SPELL - ROGUE // [DAL_010] Togwaggle's Scheme - COST:1 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Choose a minion. Shuffle @ (copy, copies) of it into your deck. // <i>(Upgrades each turn!)</i> // -------------------------------------------------------- // GameTag: // - TAG_SCRIPT_DATA_NUM_1 = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1)); cardDef.power.AddPowerTask(std::make_shared<EnqueueNumberTask>(TaskList{ std::make_shared<CopyTask>(EntityType::TARGET, ZoneType::DECK) })); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->triggerActivation = TriggerActivation::HAND; cardDef.power.GetTrigger()->tasks = { std::make_shared<GetGameTagTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1), std::make_shared<MathAddTask>(1), std::make_shared<SetGameTagNumberTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1) }; cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_010", cardDef); // ------------------------------------------ SPELL - ROGUE // [DAL_366] Unidentified Contract - COST:6 // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Destroy a minion. Gains a bonus effect in your hand. // -------------------------------------------------------- // Entourage: DAL_366t1, DAL_366t2, DAL_366t3, DAL_366t4 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DestroyTask>(EntityType::TARGET)); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::ZONE)); cardDef.power.GetTrigger()->triggerActivation = TriggerActivation::HAND; cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY; cardDef.power.GetTrigger()->removeAfterTriggered = true; cardDef.power.GetTrigger()->tasks = { std::make_shared<ChangeUnidentifiedTask>() }; cardDef.property.entourages = Entourages{ "DAL_366t1", "DAL_366t2", "DAL_366t3", "DAL_366t4" }; cards.emplace("DAL_366", cardDef); // ----------------------------------------- MINION - ROGUE // [DAL_415] EVIL Miscreant - COST:3 [ATK:1/HP:5] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Combo:</b> Add two random <b>Lackeys</b> to your hand. // -------------------------------------------------------- // GameTag: // - COMBO = 1 // -------------------------------------------------------- // RefTag: // - MARK_OF_EVIL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddComboTask(std::make_shared<AddLackeyTask>(2)); cards.emplace("DAL_415", cardDef); // ----------------------------------------- MINION - ROGUE // [DAL_416] Hench-Clan Burglar - COST:4 [ATK:4/HP:4] // - Race: Pirate, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> <b>Discover</b> a spell // from another class. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<DiscoverTask>( CardType::SPELL, CardClass::ANOTHER_CLASS)); cards.emplace("DAL_416", cardDef); // ----------------------------------------- MINION - ROGUE // [DAL_417] Heistbaron Togwaggle - COST:6 [ATK:5/HP:5] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> If you control a <b>Lackey</b>, // choose a fantastic treasure. // -------------------------------------------------------- // Entourage: LOOT_998h, LOOT_998j, LOOT_998l, LOOT_998k // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // - MULTIPLY_BUFF_VALUE = 1 // -------------------------------------------------------- // RefTag: // - MARK_OF_EVIL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::HERO, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsControllingLackey()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DiscoverTask>( DiscoverType::HEISTBARON_TOGWAGGLE, 4) })); cards.emplace("DAL_417", cardDef); // ----------------------------------------- MINION - ROGUE // [DAL_714] Underbelly Fence - COST:2 [ATK:2/HP:3] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Battlecry:</b> If you're holding a card from // another class, gain +1/+1 and <b>Rush</b>. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::HERO, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsHoldingAnotherClassCard()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<AddEnchantmentTask>( "DAL_714e", EntityType::SOURCE), std::make_shared<SetGameTagTask>(EntityType::SOURCE, GameTag::RUSH, 1) })); cards.emplace("DAL_714", cardDef); // ------------------------------------------ SPELL - ROGUE // [DAL_716] Vendetta - COST:4 // - Faction: Neutral, Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Deal 4 damage to a minion. Costs (0) if you're // holding a card from another class. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DamageTask>(EntityType::TARGET, 4, true)); cardDef.power.AddAura(std::make_shared<AdaptiveCostEffect>( [](Playable* playable) { return 0; }, EffectOperator::SET, SelfCondition::IsHoldingAnotherClassCard())); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_716", cardDef); // ----------------------------------------- MINION - ROGUE // [DAL_719] Tak Nozwhisker - COST:7 [ATK:6/HP:6] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: Whenever you shuffle a card into your deck, // add a copy to your hand. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::SHUFFLE_INTO_DECK)); cardDef.power.GetTrigger()->tasks = { std::make_shared<CopyTask>( EntityType::TARGET, ZoneType::HAND) }; cards.emplace("DAL_719", cardDef); // ----------------------------------------- WEAPON - ROGUE // [DAL_720] Waggle Pick - COST:4 [ATK:4/HP:0] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Return a random friendly // minion to your hand. It costs (2) less. // -------------------------------------------------------- // GameTag: // - DURABILITY = 2 // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<RandomTask>(EntityType::MINIONS, 1)); cardDef.power.AddDeathrattleTask( std::make_shared<ReturnHandTask>(EntityType::STACK)); cardDef.power.AddDeathrattleTask(std::make_shared<ApplyEffectTask>( EntityType::STACK, EffectList{ Effects::ReduceCost(2) })); cards.emplace("DAL_720", cardDef); // ------------------------------------------ SPELL - ROGUE // [DAL_728] Daring Escape - COST:1 // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: Return all friendly minions to your hand. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<ReturnHandTask>(EntityType::MINIONS)); cards.emplace("DAL_728", cardDef); } void DalaranCardsGen::AddRogueNonCollect(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ------------------------------------------ SPELL - ROGUE // [DAL_366t1] Assassin's Contract (*) - COST:6 // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Destroy a minion. Summon a 1/2 Patient Assassin. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DestroyTask>(EntityType::TARGET)); cardDef.power.AddPowerTask(std::make_shared<SummonTask>("EX1_522")); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_366t1", cardDef); // ------------------------------------------ SPELL - ROGUE // [DAL_366t2] Recruitment Contract (*) - COST:6 // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Destroy a minion. Add a copy of it to your hand. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DestroyTask>(EntityType::TARGET)); cardDef.power.AddPowerTask( std::make_shared<CopyTask>(EntityType::TARGET, ZoneType::HAND)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_366t2", cardDef); // ------------------------------------------ SPELL - ROGUE // [DAL_366t3] Lucrative Contract (*) - COST:6 // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Destroy a minion. Add 2 Coins to your hand. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DestroyTask>(EntityType::TARGET)); cardDef.power.AddPowerTask( std::make_shared<AddCardTask>(EntityType::HAND, "GAME_005", 2)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_366t3", cardDef); // ------------------------------------------ SPELL - ROGUE // [DAL_366t4] Turncoat Contract (*) - COST:6 // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Destroy a minion. It deals its damage to adjacent minions. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DestroyTask>(EntityType::TARGET)); cardDef.power.AddPowerTask( std::make_shared<GetGameTagTask>(EntityType::TARGET, GameTag::ATK)); cardDef.power.AddPowerTask( std::make_shared<IncludeAdjacentTask>(EntityType::TARGET)); cardDef.power.AddPowerTask( std::make_shared<DamageNumberTask>(EntityType::STACK)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_366t4", cardDef); } void DalaranCardsGen::AddShaman(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ----------------------------------------- SPELL - SHAMAN // [DAL_009] Hagatha's Scheme - COST:5 // - Set: Dalaran, Rarity: Rare // - Spell School: Nature // -------------------------------------------------------- // Text: Deal @ damage to all minions. // <i>(Upgrades each turn!)</i> // -------------------------------------------------------- // GameTag: // - TAG_SCRIPT_DATA_NUM_1 = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1)); cardDef.power.AddPowerTask( std::make_shared<DamageNumberTask>(EntityType::ALL_MINIONS, true)); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->triggerActivation = TriggerActivation::HAND; cardDef.power.GetTrigger()->tasks = { std::make_shared<GetGameTagTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1), std::make_shared<MathAddTask>(1), std::make_shared<SetGameTagNumberTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1) }; cards.emplace("DAL_009", cardDef); // ---------------------------------------- MINION - SHAMAN // [DAL_047] Walking Fountain - COST:8 [ATK:4/HP:8] // - Race: Elemental, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Lifesteal</b>, <b>Rush</b>, <b>Windfury</b> // -------------------------------------------------------- // GameTag: // - WINDFURY = 1 // - LIFESTEAL = 1 // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_047", cardDef); // ---------------------------------------- MINION - SHAMAN // [DAL_049] Underbelly Angler - COST:2 [ATK:2/HP:3] // - Race: Murloc, Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: After you play a Murloc, add a random Murloc to your hand. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_PLAY_MINION)); cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsRace(Race::MURLOC)) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<RandomCardTask>(CardType::MINION, CardClass::INVALID, Race::MURLOC), std::make_shared<AddStackToTask>(EntityType::HAND) }; cards.emplace("DAL_049", cardDef); // ---------------------------------------- MINION - SHAMAN // [DAL_052] Muckmorpher - COST:5 [ATK:4/HP:4] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Battlecry:</b> Transform into a 4/4 copy of // a different minion in your deck. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::DECK)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsMinion()) })); cardDef.power.AddPowerTask( std::make_shared<RandomTask>(EntityType::STACK, 1)); cardDef.power.AddPowerTask(std::make_shared<ChangeEntityTask>( EntityType::SOURCE, EntityType::STACK)); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_052e", EntityType::SOURCE)); cards.emplace("DAL_052", cardDef); // ----------------------------------------- SPELL - SHAMAN // [DAL_071] Mutate - COST:0 // - Set: Dalaran, Rarity: Common // - Spell School: Nature // -------------------------------------------------------- // Text: Transform a friendly minion into a random one // that costs (1) more. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_FRIENDLY_TARGET = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<TransformMinionTask>(EntityType::TARGET, 1)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_071", cardDef); // ---------------------------------------- MINION - SHAMAN // [DAL_431] Swampqueen Hagatha - COST:7 [ATK:5/HP:5] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> Add a 5/5 Horror to your hand. // Teach it two Shaman spells. // -------------------------------------------------------- // Entourage: DAL_431t // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(DiscoverType::SWAMPQUEEN_HAGATHA, 3, 2)); cardDef.power.AddAfterChooseTask(std::make_shared<CustomTask>( [](Player* player, Entity* source, [[maybe_unused]] Playable* target) { if (source->GetGameTag(GameTag::TAG_SCRIPT_DATA_ENT_2) > 0) { std::map<GameTag, int> tags; tags.emplace( GameTag::TAG_SCRIPT_DATA_ENT_1, source->GetGameTag(GameTag::TAG_SCRIPT_DATA_ENT_1)); tags.emplace( GameTag::TAG_SCRIPT_DATA_ENT_2, source->GetGameTag(GameTag::TAG_SCRIPT_DATA_ENT_2)); Playable* horror = Entity::GetFromCard(player, Cards::FindCardByID("DAL_431t"), tags, player->GetHandZone()); Generic::AddCardToHand(player, horror); } })); cards.emplace("DAL_431", cardDef); // ----------------------------------------- SPELL - SHAMAN // [DAL_432] Witch's Brew - COST:2 // - Set: Dalaran, Rarity: Epic // - Spell School: Nature // -------------------------------------------------------- // Text: Restore 4 Health. Repeatable this turn. // -------------------------------------------------------- // GameTag: // - NON_KEYWORD_ECHO = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<HealTask>(EntityType::TARGET, 4)); cardDef.power.AddPowerTask(ComplexTask::RepeatableThisTurn()); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 } }; cards.emplace("DAL_432", cardDef); // ---------------------------------------- MINION - SHAMAN // [DAL_433] Sludge Slurper - COST:1 [ATK:2/HP:1] // - Race: Murloc, Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Battlecry:</b> Add a <b>Lackey</b> to your hand. // <b>Overload:</b> (1) // -------------------------------------------------------- // GameTag: // - OVERLOAD = 1 // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - MARK_OF_EVIL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<AddLackeyTask>(1)); cards.emplace("DAL_433", cardDef); // ----------------------------------------- SPELL - SHAMAN // [DAL_710] Soul of the Murloc - COST:2 // - Faction: Neutral, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: Give your minions "<b>Deathrattle:</b> Summon a 1/1 Murloc." // -------------------------------------------------------- // RefTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_710e", EntityType::MINIONS)); cards.emplace("DAL_710", cardDef); // ---------------------------------------- MINION - SHAMAN // [DAL_726] Scargil - COST:4 [ATK:4/HP:4] // - Race: Murloc, Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: Your Murlocs cost (1). // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - AURA = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddAura(std::make_shared<Aura>(AuraType::HAND, "DAL_726e")); { const auto aura = dynamic_cast<Aura*>(cardDef.power.GetAura()); aura->condition = std::make_shared<SelfCondition>( SelfCondition::IsRace(Race::MURLOC)); } cards.emplace("DAL_726", cardDef); } void DalaranCardsGen::AddShamanNonCollect(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ---------------------------------------- MINION - SHAMAN // [DAL_431t] Drustvar Horror (*) - COST:5 [ATK:5/HP:5] // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Battlecry:</b> Cast {0} and {1}. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<CustomTask>( [](Player* player, Entity* source, Playable* target) { const int dbfID1 = source->GetGameTag(GameTag::TAG_SCRIPT_DATA_ENT_1); Playable* playable1 = Entity::GetFromCard(player, Cards::FindCardByDbfID(dbfID1)); Generic::CastSpell(player, dynamic_cast<Spell*>(playable1), dynamic_cast<Character*>(target), 0); const int dbfID2 = source->GetGameTag(GameTag::TAG_SCRIPT_DATA_ENT_2); Playable* playable2 = Entity::GetFromCard(player, Cards::FindCardByDbfID(dbfID2)); Generic::CastSpell(player, dynamic_cast<Spell*>(playable2), dynamic_cast<Character*>(target), 0); })); cards.emplace("DAL_431t", cardDef); // ----------------------------------- ENCHANTMENT - SHAMAN // [DAL_710e] Soul of the Murloc (*) - COST:0 // - Faction: Neutral, Set: Dalaran // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Summon a 1/1 Murloc. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<SummonTask>("EX1_506a", SummonSide::DEATHRATTLE)); cards.emplace("DAL_710e", cardDef); } void DalaranCardsGen::AddWarlock(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ---------------------------------------- SPELL - WARLOCK // [DAL_007] Rafaam's Scheme - COST:3 // - Set: Dalaran, Rarity: Common // - Spell School: Fire // -------------------------------------------------------- // Text: Summon @ 1/1 (Imp, Imps). <i>(Upgrades each turn!)</i> // -------------------------------------------------------- // GameTag: // - TAG_SCRIPT_DATA_NUM_1 = 1 // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1)); cardDef.power.AddPowerTask( std::make_shared<SummonNumberTask>("DAL_751t", false)); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->triggerActivation = TriggerActivation::HAND; cardDef.power.GetTrigger()->tasks = { std::make_shared<GetGameTagTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1), std::make_shared<MathAddTask>(1), std::make_shared<SetGameTagNumberTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1) }; cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 } }; cards.emplace("DAL_007", cardDef); // ---------------------------------------- SPELL - WARLOCK // [DAL_173] Darkest Hour - COST:6 // - Set: Dalaran, Rarity: Epic // - Spell School: Shadow // -------------------------------------------------------- // Text: Destroy all friendly minions. // For each one, summon a random minion from your deck. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::MINIONS)); cardDef.power.AddPowerTask(std::make_shared<CountTask>(EntityType::STACK)); cardDef.power.AddPowerTask( std::make_shared<DestroyTask>(EntityType::STACK, true)); cardDef.power.AddPowerTask(std::make_shared<EnqueueNumberTask>(TaskList{ std::make_shared<IncludeTask>(EntityType::DECK), std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsMinion()) }), std::make_shared<RandomTask>(EntityType::STACK, 1), std::make_shared<SummonStackTask>(true) })); cards.emplace("DAL_173", cardDef); // --------------------------------------- MINION - WARLOCK // [DAL_185] Aranasi Broodmother - COST:6 [ATK:4/HP:6] // - Race: Demon, Faction: Neutral, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Taunt</b> When you draw this, // restore 4 Health to your hero. // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // - TOPDECK = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTopdeckTask( std::make_shared<HealTask>(EntityType::HERO, 4)); cards.emplace("DAL_185", cardDef); // --------------------------------------- MINION - WARLOCK // [DAL_422] Arch-Villain Rafaam - COST:7 [ATK:7/HP:8] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Taunt</b> <b>Battlecry:</b> Replace your hand // and deck with <b>Legendary</b> minions. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - TAUNT = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::HAND)); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>( EntityType::DECK, std::vector<EntityType>(), true)); cardDef.power.AddPowerTask(std::make_shared<ChangeEntityTask>( EntityType::STACK, CardType::MINION, CardClass::INVALID, Race::INVALID, Rarity::LEGENDARY)); cards.emplace("DAL_422", cardDef); // --------------------------------------- MINION - WARLOCK // [DAL_561] Jumbo Imp - COST:10 [ATK:8/HP:8] // - Race: Demon, Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Costs (1) less whenever a friendly Demon dies // while this is in your hand. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::DEATH)); cardDef.power.GetTrigger()->triggerActivation = TriggerActivation::HAND; cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY; cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsRace(Race::DEMON)) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<AddEnchantmentTask>( "DAL_561e", EntityType::SOURCE) }; cards.emplace("DAL_561", cardDef); // --------------------------------------- MINION - WARLOCK // [DAL_563] Eager Underling - COST:4 [ATK:2/HP:2] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Give two random friendly minions +2/+2. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<RandomTask>(EntityType::MINIONS, 2)); cardDef.power.AddDeathrattleTask( std::make_shared<AddEnchantmentTask>("DAL_563e", EntityType::STACK)); cards.emplace("DAL_563", cardDef); // ---------------------------------------- SPELL - WARLOCK // [DAL_602] Plot Twist - COST:2 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Shuffle your hand into your deck. Draw that many cards. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::HAND)); cardDef.power.AddPowerTask(std::make_shared<CountTask>(EntityType::STACK)); cardDef.power.AddPowerTask( std::make_shared<MoveToDeckTask>(EntityType::STACK)); cardDef.power.AddPowerTask(std::make_shared<DrawNumberTask>()); cards.emplace("DAL_602", cardDef); // ---------------------------------------- SPELL - WARLOCK // [DAL_605] Impferno - COST:3 // - Set: Dalaran, Rarity: Rare // - Spell School: Fire // -------------------------------------------------------- // Text: Give your Demons +1 Attack. // Deal 1 damage to all enemy minions. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::MINIONS)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsRace(Race::DEMON)) })); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_605e", EntityType::STACK)); cardDef.power.AddPowerTask( std::make_shared<DamageTask>(EntityType::ENEMY_MINIONS, 1, true)); cards.emplace("DAL_605", cardDef); // --------------------------------------- MINION - WARLOCK // [DAL_606] EVIL Genius - COST:2 [ATK:2/HP:2] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> Destroy a friendly minion // to add 2 random <b>Lackeys</b> to your hand. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_IF_AVAILABLE = 0 // - REQ_FRIENDLY_TARGET = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- // RefTag: // - MARK_OF_EVIL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::HasTarget()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DestroyTask>(EntityType::TARGET), std::make_shared<AddLackeyTask>(2) })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_IF_AVAILABLE, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_606", cardDef); // --------------------------------------- MINION - WARLOCK // [DAL_607] Fel Lord Betrug - COST:8 [ATK:5/HP:7] // - Race: Demon, Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: Whenever you draw a minion, summon a copy // with <b>Rush</b> that dies at end of turn. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::DRAW_CARD)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY; cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsMinion()) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<CopyTask>(EntityType::TARGET, ZoneType::PLAY, 1, true), std::make_shared<AddEnchantmentTask>("DAL_607e", EntityType::STACK) }; cards.emplace("DAL_607", cardDef); } void DalaranCardsGen::AddWarlockNonCollect( std::map<std::string, CardDef>& cards) { CardDef cardDef; // ---------------------------------- ENCHANTMENT - WARLOCK // [DAL_605e] Imptastic (*) - COST:2 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: +1 Attack. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_605e")); cards.emplace("DAL_605e", cardDef); } void DalaranCardsGen::AddWarrior(std::map<std::string, CardDef>& cards) { CardDef cardDef; // ---------------------------------------- SPELL - WARRIOR // [DAL_008] Dr. Boom's Scheme - COST:4 // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: Gain @ Armor. <i>(Upgrades each turn!)</i> // -------------------------------------------------------- // GameTag: // - TAG_SCRIPT_DATA_NUM_1 = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1)); cardDef.power.AddPowerTask(std::make_shared<ArmorTask>(0, false, true)); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->triggerActivation = TriggerActivation::HAND; cardDef.power.GetTrigger()->tasks = { std::make_shared<GetGameTagTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1), std::make_shared<MathAddTask>(1), std::make_shared<SetGameTagNumberTask>(EntityType::SOURCE, GameTag::TAG_SCRIPT_DATA_NUM_1) }; cards.emplace("DAL_008", cardDef); // ---------------------------------------- SPELL - WARRIOR // [DAL_059] Dimensional Ripper - COST:10 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Summon 2 copies of a minion in your deck. // -------------------------------------------------------- // PlayReq: // - REQ_NUM_MINION_SLOTS = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::DECK)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsMinion()) })); cardDef.power.AddPowerTask( std::make_shared<RandomTask>(EntityType::STACK, 1)); cardDef.power.AddPowerTask( std::make_shared<CopyTask>(EntityType::STACK, ZoneType::PLAY, 2)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_NUM_MINION_SLOTS, 1 } }; cards.emplace("DAL_059", cardDef); // --------------------------------------- MINION - WARRIOR // [DAL_060] Clockwork Goblin - COST:3 [ATK:3/HP:3] // - Race: Mechanical, Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Battlecry:</b> Shuffle a Bomb into your opponent's deck. // When drawn, it explodes for 5 damage. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddCardTask>(EntityType::ENEMY_DECK, "BOT_511t")); cards.emplace("DAL_060", cardDef); // ---------------------------------------- SPELL - WARRIOR // [DAL_062] Sweeping Strikes - COST:2 // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Give a minion "Also damages minions next to whomever this attacks." // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_062e", EntityType::TARGET)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_062", cardDef); // --------------------------------------- WEAPON - WARRIOR // [DAL_063] Wrenchcalibur - COST:4 [ATK:3/HP:0] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: After your hero attacks, shuffle a Bomb // into your opponent's deck. // -------------------------------------------------------- // GameTag: // - DURABILITY = 2 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_ATTACK)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::HERO; cardDef.power.GetTrigger()->tasks = { std::make_shared<AddCardTask>( EntityType::ENEMY_DECK, "BOT_511t") }; cards.emplace("DAL_063", cardDef); // --------------------------------------- MINION - WARRIOR // [DAL_064] Blastmaster Boom - COST:7 [ATK:7/HP:7] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> Summon two 1/1 Boom Bots // for each Bomb in your opponent's deck. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::ENEMY_DECK)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>( SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsCardID("BOT_511t")) })); cardDef.power.AddPowerTask(std::make_shared<CountTask>(EntityType::STACK)); cardDef.power.AddPowerTask( std::make_shared<NumberConditionTask>(4, RelaSign::GEQ)); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<FuncNumberTask>( []([[maybe_unused]] Playable* playable) { return 3; }) })); cardDef.power.AddPowerTask(std::make_shared<EnqueueNumberTask>( TaskList{ std::make_shared<SummonTask>( "GVG_110t", 2, SummonSide::ALTERNATE_FRIENDLY) })); cards.emplace("DAL_064", cardDef); // --------------------------------------- MINION - WARRIOR // [DAL_070] The Boom Reaver - COST:10 [ATK:7/HP:9] // - Race: Mechanical, Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> Summon a copy of a minion in your deck. // Give it <b>Rush</b>. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::DECK)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsMinion()) })); cardDef.power.AddPowerTask( std::make_shared<RandomTask>(EntityType::STACK, 1)); cardDef.power.AddPowerTask( std::make_shared<CopyTask>(EntityType::STACK, ZoneType::PLAY, 1, true)); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_070e", EntityType::STACK)); cards.emplace("DAL_070", cardDef); // --------------------------------------- MINION - WARRIOR // [DAL_759] Vicious Scraphound - COST:2 [ATK:2/HP:2] // - Race: Mechanical, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: Whenever this minion deals damage, gain that much Armor. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::DEAL_DAMAGE)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::SELF; cardDef.power.GetTrigger()->tasks = { std::make_shared<GetEventNumberTask>(), std::make_shared<ArmorTask>(0, false, true) }; cards.emplace("DAL_759", cardDef); // ---------------------------------------- SPELL - WARRIOR // [DAL_769] Improve Morale - COST:1 // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: Deal 1 damage to a minion. // If it survives, add a <b>Lackey</b> to your hand. // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- // RefTag: // - MARK_OF_EVIL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DamageTask>(EntityType::TARGET, 1, true)); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::TARGET, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsNotDead()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<AddLackeyTask>(1) })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_769", cardDef); // --------------------------------------- MINION - WARRIOR // [DAL_770] Omega Devastator - COST:4 [ATK:4/HP:5] // - Race: Mechanical, Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Battlecry:</b> If you have 10 Mana Crystals, // deal 10 damage to a minion. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_IF_AVAILABLE = 0 // - REQ_MINION_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsManaCrystalFull()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DamageTask>(EntityType::TARGET, 10) })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_IF_AVAILABLE, 0 }, { PlayReq::REQ_MINION_TARGET, 0 } }; cards.emplace("DAL_770", cardDef); } void DalaranCardsGen::AddWarriorNonCollect( std::map<std::string, CardDef>& cards) { CardDef cardDef; // ---------------------------------- ENCHANTMENT - WARRIOR // [DAL_062e] Sweeping Strikes (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Damages minions adjacent to defender. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_ATTACK)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::ENCHANTMENT_TARGET; cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsEventTargetIs(CardType::MINION)) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<IncludeAdjacentTask>(EntityType::EVENT_TARGET), std::make_shared<GetGameTagTask>(EntityType::TARGET, GameTag::ATK), std::make_shared<DamageNumberTask>(EntityType::STACK) }; cards.emplace("DAL_062e", cardDef); // ---------------------------------- ENCHANTMENT - WARRIOR // [DAL_070e] Reaving (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Has <b>Rush</b>. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_070e")); cards.emplace("DAL_070e", cardDef); // ---------------------------------- ENCHANTMENT - WARRIOR // [DAL_742e] Whirling (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Mega-Windfury</b> // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(std::make_unique<Enchant>(GameTag::MEGA_WINDFURY, EffectOperator::SET, 1)); cards.emplace("DAL_742e", cardDef); } void DalaranCardsGen::AddNeutral(std::map<std::string, CardDef>& cards) { CardDef cardDef; // --------------------------------------- MINION - NEUTRAL // [DAL_058] Hecklebot - COST:4 [ATK:3/HP:8] // - Race: Mechanical, Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Taunt</b> <b>Battlecry:</b> Your opponent // summons a minion from their deck. // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::ENEMY_DECK)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsMinion()) })); cardDef.power.AddPowerTask( std::make_shared<RandomTask>(EntityType::STACK, 1)); cardDef.power.AddPowerTask(std::make_shared<SummonStackTask>(true)); cards.emplace("DAL_058", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_077] Toxfin - COST:1 [ATK:1/HP:2] // - Race: Murloc, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> Give a friendly Murloc <b>Poisonous</b>. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_IF_AVAILABLE = 0 // - REQ_MINION_TARGET = 0 // - REQ_FRIENDLY_TARGET = 0 // - REQ_TARGET_WITH_RACE = 14 // -------------------------------------------------------- // RefTag: // - POISONOUS = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_077e", EntityType::TARGET)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_IF_AVAILABLE, 0 }, { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 }, { PlayReq::REQ_TARGET_WITH_RACE, 14 } }; cards.emplace("DAL_077", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_078] Traveling Healer - COST:4 [ATK:3/HP:2] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Divine Shield</b> <b>Battlecry:</b> Restore 3 Health. // -------------------------------------------------------- // GameTag: // - DIVINE_SHIELD = 1 // - BATTLECRY = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_IF_AVAILABLE = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<HealTask>(EntityType::TARGET, 3)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_IF_AVAILABLE, 0 } }; cards.emplace("DAL_078", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_081] Spellward Jeweler - COST:3 [ATK:3/HP:4] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Battlecry:</b> Your hero can't be targeted by // spells or Hero Powers until your next turn. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_081e", EntityType::HERO)); cards.emplace("DAL_081", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_085] Dalaran Crusader - COST:5 [ATK:5/HP:4] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Divine Shield</b> // -------------------------------------------------------- // GameTag: // - DIVINE_SHIELD = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_085", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_086] Sunreaver Spy - COST:2 [ATK:2/HP:3] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> If you control a <b>Secret</b>, // gain +1/+1. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - SECRET = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsControllingSecret()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<AddEnchantmentTask>( "DAL_086e", EntityType::SOURCE) })); cards.emplace("DAL_086", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_087] Hench-Clan Hag - COST:4 [ATK:3/HP:3] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Battlecry:</b> Summon two 1/1 Amalgams // with all minion types. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<SummonTask>( "DAL_087t", 2, SummonSide::ALTERNATE_FRIENDLY)); cards.emplace("DAL_087", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_088] Safeguard - COST:6 [ATK:4/HP:5] // - Race: Mechanical, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Taunt</b> <b>Deathrattle:</b> Summon a 0/5 // Vault Safe with <b>Taunt</b>. // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<SummonTask>("DAL_088t2", SummonSide::DEATHRATTLE)); cards.emplace("DAL_088", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_089] Spellbook Binder - COST:2 [ATK:3/HP:2] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> If you have <b>Spell Damage</b>, // draw a card. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - SPELLPOWER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::HERO, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::HasPlayerSpellPower()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DrawTask>(1) })); cards.emplace("DAL_089", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_090] Hench-Clan Sneak - COST:3 [ATK:3/HP:3] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Stealth</b> // -------------------------------------------------------- // GameTag: // - STEALTH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_090", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_092] Arcane Servant - COST:2 [ATK:2/HP:3] // - Race: Elemental, Set: Dalaran, Rarity: Common // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_092", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_095] Violet Spellsword - COST:4 [ATK:1/HP:6] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> Gain +1 Attack // for each spell in your hand. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<IncludeTask>(EntityType::HAND)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsSpell()) })); cardDef.power.AddPowerTask(std::make_shared<CountTask>(EntityType::STACK)); cardDef.power.AddPowerTask(std::make_shared<AddEnchantmentTask>( "DAL_095e", EntityType::SOURCE, true)); cards.emplace("DAL_095", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_096] Violet Warden - COST:6 [ATK:4/HP:7] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Taunt</b> <b>Spell Damage +1</b> // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // - SPELLPOWER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_096", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_400] EVIL Cable Rat - COST:2 [ATK:1/HP:1] // - Race: Beast, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> Add a <b>Lackey</b> to your hand. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - MARK_OF_EVIL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<AddLackeyTask>(1)); cards.emplace("DAL_400", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_434] Arcane Watcher - COST:3 [ATK:5/HP:6] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Can't attack unless you have <b>Spell Damage</b>. // -------------------------------------------------------- // RefTag: // - SPELLPOWER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddAura(std::make_shared<AdaptiveEffect>( std::make_shared<SelfCondition>( SelfCondition::HasNotSpellDamageOnHero()), GameTag::CANT_ATTACK)); cards.emplace("DAL_434", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_538] Unseen Saboteur - COST:6 [ATK:5/HP:6] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Battlecry:</b> Your opponent casts a random spell // from their hand <i>(targets chosen randomly)</i>. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::ENEMY_HAND)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsSpell()) })); cardDef.power.AddPowerTask( std::make_shared<RandomTask>(EntityType::STACK, 1)); cardDef.power.AddPowerTask( std::make_shared<PlayTask>(PlayType::SPELL, true)); cards.emplace("DAL_538", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_539] Sunreaver Warmage - COST:5 [ATK:4/HP:4] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Battlecry:</b> If you're holding a spell that // costs (5) or more, deal 4 damage. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // PlayReq: // - REQ_DRAG_TO_PLAY = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::Has5MoreCostSpellInHand()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<DamageTask>(EntityType::TARGET, 4) })); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_DRAG_TO_PLAY, 0 } }; cards.emplace("DAL_539", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_544] Potion Vendor - COST:1 [ATK:1/HP:1] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> Restore 2 Health to all friendly characters. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<HealTask>(EntityType::FRIENDS, 2)); cards.emplace("DAL_544", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_546] Barista Lynchen - COST:5 [ATK:4/HP:5] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> Add a copy of each of your other // <b>Battlecry</b> minions to your hand. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<IncludeTask>(EntityType::MINIONS_NOSOURCE)); cardDef.power.AddPowerTask(std::make_shared<FilterStackTask>(SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsBattlecryCard()) })); cardDef.power.AddPowerTask( std::make_shared<CopyTask>(EntityType::STACK, ZoneType::HAND)); cards.emplace("DAL_546", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_548] Azerite Elemental - COST:5 [ATK:2/HP:7] // - Race: Elemental, Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: At the start of your turn, gain <b>Spell Damage +2</b>. // -------------------------------------------------------- // RefTag: // - SPELLPOWER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::TURN_START)); cardDef.power.GetTrigger()->tasks = { std::make_shared<AddEnchantmentTask>( "DAL_548e", EntityType::SOURCE) }; cards.emplace("DAL_548", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_550] Underbelly Ooze - COST:7 [ATK:3/HP:5] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: After this minion survives damage, summon a copy of it. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::TAKE_DAMAGE)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::SELF; cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsNotDead()) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<CopyTask>( EntityType::SOURCE, ZoneType::PLAY) }; cards.emplace("DAL_550", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_551] Proud Defender - COST:4 [ATK:2/HP:6] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Taunt</b> // Has +2 Attack while you have no other minions. // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddAura(std::make_shared<AdaptiveEffect>( GameTag::ATK, EffectOperator::ADD, [=](Playable* playable) { return playable->player->GetFieldZone()->GetCount() == 1 ? 2 : 0; })); cards.emplace("DAL_551", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_553] Big Bad Archmage - COST:10 [ATK:6/HP:6] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: At the end of your turn, summon a random // 6-Cost minion. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->tasks = { std::make_shared<RandomMinionTask>( TagValues{ { GameTag::COST, 6, RelaSign::EQ } }), std::make_shared<SummonTask>() }; cards.emplace("DAL_553", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_554] Chef Nomi - COST:7 [ATK:6/HP:6] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> If your deck is empty, // summon six 6/6 Greasefire Elementals. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsDeckEmpty()) })); cardDef.power.AddPowerTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<SummonTask>( "DAL_554t", 6, SummonSide::ALTERNATE_FRIENDLY) })); cards.emplace("DAL_554", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_558] Archmage Vargoth - COST:4 [ATK:2/HP:6] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: At the end of your turn, cast a spell // you've cast this turn <i>(targets are random)</i>. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->tasks = { std::make_shared<CustomTask>( [](Player* player, [[maybe_unused]] Entity* source, [[maybe_unused]] Playable* target) { std::vector<Card*> spellsPlayedThisTurn; for (auto& card : player->cardsPlayedThisTurn) { if (card->GetCardType() == CardType::SPELL) { spellsPlayedThisTurn.emplace_back(card); } } if (spellsPlayedThisTurn.empty()) { return; } auto idx = Random::get<std::size_t>(0, spellsPlayedThisTurn.size() - 1); Card* randSpellCard = spellsPlayedThisTurn[idx]; if (!randSpellCard->IsPlayableByCardReq(player) || (randSpellCard->IsSecret() && player->GetSecretZone()->IsFull()) || (randSpellCard->IsQuest() && player->GetSecretZone()->quest != nullptr)) { return; } Character* randTarget; std::vector<Character*> validTargets = randSpellCard->GetValidPlayTargets(player); if (validTargets.empty()) { randTarget = nullptr; } else { idx = Random::get<std::size_t>(0, validTargets.size() - 1); randTarget = validTargets[idx]; } if (randSpellCard->mustHaveToTargetToPlay && randTarget == nullptr) { return; } Spell* spellToCast = dynamic_cast<Spell*>( Entity::GetFromCard(player, randSpellCard)); const int randChooseOne = Random::get<int>(1, 2); Generic::CastSpell(player, spellToCast, randTarget, randChooseOne); while (player->choice != nullptr) { idx = Random::get<std::size_t>( 0, player->choice->choices.size() - 1); Generic::ChoicePick(player, static_cast<int>(idx)); } }) }; cards.emplace("DAL_558", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_560] Heroic Innkeeper - COST:8 [ATK:4/HP:4] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Taunt.</b> <b>Battlecry:</b> Gain +2/+2 // for each other friendly minion. // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<FuncNumberTask>([](Playable* playable) { return 2 * (playable->player->GetFieldZone()->GetCount() - 1); })); cardDef.power.AddPowerTask(std::make_shared<AddEnchantmentTask>( "DAL_560e2", EntityType::SOURCE, true)); cards.emplace("DAL_560", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_565] Portal Overfiend - COST:6 [ATK:5/HP:6] // - Race: Demon, Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Battlecry:</b> Shuffle 3 Portals into your deck. // When drawn, summon a 2/2 Demon with <b>Rush</b>. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddCardTask>(EntityType::DECK, "DAL_582t", 3)); cards.emplace("DAL_565", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_566] Eccentric Scribe - COST:6 [ATK:6/HP:4] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Deathrattle:</b> Summon four 1/1 Vengeful Scrolls. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<SummonTask>("DAL_566t", 4, SummonSide::DEATHRATTLE)); cards.emplace("DAL_566", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_582] Portal Keeper - COST:4 [ATK:5/HP:2] // - Race: Demon, Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Battlecry:</b> Shuffle 3 Portals into your deck. // When drawn, summon a 2/2 Demon with <b>Rush</b>. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddCardTask>(EntityType::DECK, "DAL_582t", 3)); cards.emplace("DAL_582", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_592] Batterhead - COST:8 [ATK:3/HP:12] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: <b>Rush</b>. After this attacks and kills a minion, // it may attack again. // -------------------------------------------------------- // GameTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_ATTACK)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::SELF; cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsDefenderDead()) }; cardDef.power.GetTrigger()->tasks = { std::make_shared<SetGameTagTask>( EntityType::SOURCE, GameTag::EXHAUSTED, 0), std::make_shared<SummonTask>() }; cards.emplace("DAL_592", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_735] Dalaran Librarian - COST:2 [ATK:2/HP:3] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> <b>Silence</b> adjacent minions. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - SILENCE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<IncludeAdjacentTask>(EntityType::SOURCE)); cardDef.power.AddPowerTask( std::make_shared<SilenceTask>(EntityType::STACK)); cards.emplace("DAL_735", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_736] Archivist Elysiana - COST:8 [ATK:7/HP:7] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> <b>Discover</b> 5 cards. // Replace your deck with 2 copies of each. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- // RefTag: // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<DiscoverTask>( CardType::INVALID, CardClass::INVALID, Race::INVALID, Rarity::INVALID, ChoiceAction::STACK, 5)); cardDef.power.AddAfterChooseTask( std::make_shared<MoveToSetasideTask>(EntityType::DECK)); cardDef.power.AddAfterChooseTask( std::make_shared<CopyTask>(EntityType::STACK, ZoneType::DECK, 2)); cards.emplace("DAL_736", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_742] Whirlwind Tempest - COST:8 [ATK:6/HP:6] // - Race: Elemental, Faction: Neutral, Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: Your minions with <b>Windfury</b> have <b>Mega-Windfury</b>. // -------------------------------------------------------- // GameTag: // - AURA = 1 // -------------------------------------------------------- // RefTag: // - WINDFURY = 1 // - MEGA_WINDFURY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddAura(std::make_shared<Aura>(AuraType::PLAYER, "DAL_742e")); { const auto aura = dynamic_cast<Aura*>(cardDef.power.GetAura()); aura->condition = std::make_shared<SelfCondition>(SelfCondition::HasWindfury()); } cards.emplace("DAL_742", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_743] Hench-Clan Hogsteed - COST:2 [ATK:2/HP:1] // - Race: Beast, Faction: Neutral, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Rush</b> <b>Deathrattle:</b> Summon a 1/1 Murloc. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<SummonTask>("DAL_743t", SummonSide::DEATHRATTLE)); cards.emplace("DAL_743", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_744] Faceless Rager - COST:3 [ATK:5/HP:1] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> Copy a friendly minion's Health. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_IF_AVAILABLE = 0 // - REQ_MINION_TARGET = 0 // - REQ_FRIENDLY_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<GetGameTagTask>(EntityType::TARGET, GameTag::HEALTH)); cardDef.power.AddPowerTask(std::make_shared<GetGameTagTask>( EntityType::TARGET, GameTag::DAMAGE, 0, 1)); cardDef.power.AddPowerTask( std::make_shared<MathNumberIndexTask>(0, 1, MathOperation::SUB)); cardDef.power.AddPowerTask(std::make_shared<AddEnchantmentTask>( "DAL_744e", EntityType::SOURCE, true)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_IF_AVAILABLE, 0 }, { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 } }; cards.emplace("DAL_744", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_747] Flight Master - COST:3 [ATK:3/HP:4] // - Faction: Alliance, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Battlecry:</b> Summon a 2/2 Gryphon for each player. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<SummonTask>("DAL_747t")); cardDef.power.AddPowerTask(std::make_shared<SummonOpTask>("DAL_747t")); cards.emplace("DAL_747", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_748] Mana Reservoir - COST:2 [ATK:0/HP:6] // - Race: Elemental, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Spell Damage +1</b> // -------------------------------------------------------- // GameTag: // - SPELLPOWER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_748", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_749] Recurring Villain - COST:5 [ATK:3/HP:6] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Deathrattle:</b> If this minion has 4 or more Attack, // resummon it. // -------------------------------------------------------- // GameTag: // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask(std::make_shared<ConditionTask>( EntityType::SOURCE, SelfCondList{ std::make_shared<SelfCondition>( SelfCondition::IsTagValue(GameTag::ATK, 4, RelaSign::GEQ)) })); cardDef.power.AddDeathrattleTask(std::make_shared<FlagTask>( true, TaskList{ std::make_shared<SummonTask>( "DAL_749", 1, SummonSide::DEATHRATTLE) })); cards.emplace("DAL_749", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_751] Mad Summoner - COST:6 [ATK:4/HP:4] // - Race: Demon, Faction: Alliance, Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Battlecry:</b> Fill each player's board with 1/1 Imps. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<CountTask>(ZoneType::PLAY, true, false)); cardDef.power.AddPowerTask(std::make_shared<SummonNumberTask>( "DAL_751t", false, SummonSide::ALTERNATE_FRIENDLY)); cardDef.power.AddPowerTask( std::make_shared<CountTask>(ZoneType::PLAY, true, true)); cardDef.power.AddPowerTask(std::make_shared<SummonNumberTask>( "DAL_751t", true, SummonSide::ALTERNATE_ENEMY)); cards.emplace("DAL_751", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_752] Jepetto Joybuzz - COST:8 [ATK:6/HP:6] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: <b>Battlecry:</b> Draw 2 minions from your deck. // Set their Attack, Health, and Cost to 1. // -------------------------------------------------------- // GameTag: // - ELITE = 1 // - BATTLECRY = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<DrawMinionTask>(2, true)); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_752e", EntityType::STACK)); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_752e2", EntityType::STACK)); cards.emplace("DAL_752", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_760] Burly Shovelfist - COST:9 [ATK:9/HP:9] // - Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: <b>Rush</b> // -------------------------------------------------------- // GameTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_760", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_771] Soldier of Fortune - COST:4 [ATK:5/HP:6] // - Race: Elemental, Set: Dalaran, Rarity: Common // -------------------------------------------------------- // Text: Whenever this minion attacks, give your opponent a Coin. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::ATTACK)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::SELF; cardDef.power.GetTrigger()->tasks = { std::make_shared<AddCardTask>( EntityType::ENEMY_HAND, "GAME_005") }; cards.emplace("DAL_771", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_773] Magic Carpet - COST:3 [ATK:1/HP:6] // - Set: Dalaran, Rarity: Epic // -------------------------------------------------------- // Text: After you play a 1-Cost minion, // give it +1 Attack and <b>Rush</b>. // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::AFTER_PLAY_MINION)); cardDef.power.GetTrigger()->conditions = SelfCondList{ std::make_shared<SelfCondition>(SelfCondition::IsTagValue( GameTag::TAG_LAST_KNOWN_COST_IN_HAND, 1)) }; cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY; cardDef.power.GetTrigger()->tasks = { std::make_shared<AddEnchantmentTask>( "DAL_773e", EntityType::TARGET) }; cards.emplace("DAL_773", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_774] Exotic Mountseller - COST:7 [ATK:5/HP:8] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: Whenever you cast a spell, summon a random 3-Cost Beast. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::CAST_SPELL)); cardDef.power.GetTrigger()->triggerSource = TriggerSource::FRIENDLY; cardDef.power.GetTrigger()->tasks = { std::make_shared<RandomMinionTask>( TagValues{ { GameTag::COST, 3, RelaSign::EQ }, { GameTag::CARDRACE, static_cast<int>(Race::BEAST), RelaSign::EQ } }), std::make_shared<SummonTask>() }; cards.emplace("DAL_774", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_775] Tunnel Blaster - COST:7 [ATK:3/HP:7] // - Set: Dalaran, Rarity: Rare // -------------------------------------------------------- // Text: <b>Taunt</b> <b>Deathrattle:</b> Deal 3 damage // to all minions. // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // - DEATHRATTLE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddDeathrattleTask( std::make_shared<DamageTask>(EntityType::ALL_MINIONS, 3)); cards.emplace("DAL_775", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_800] Zayle, Shadow Cloak - COST:2 [ATK:3/HP:2] // - Set: Dalaran, Rarity: Legendary // -------------------------------------------------------- // Text: You start the game with one of Zayle's EVIL Decks! // -------------------------------------------------------- // GameTag: // - ELITE = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_800", cardDef); } void DalaranCardsGen::AddNeutralNonCollect( std::map<std::string, CardDef>& cards) { CardDef cardDef; // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_011e] Lazul's Curse (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Reduced Attack. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant( std::make_unique<Enchant>(Atk::Effect(EffectOperator::SUB, 0))); cardDef.power.GetEnchant()->useScriptTag = true; cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::TURN_START)); cardDef.power.GetTrigger()->tasks = { std::make_shared<RemoveEnchantmentTask>() }; cards.emplace("DAL_011e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_052e] Muckmorphing (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: 4/4. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_052e")); cards.emplace("DAL_052e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_077e] Toxic Fin (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Poisonous</b> // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_077e")); cards.emplace("DAL_077e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_081e] Sparkly (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Can't be targeted by spells or Hero cards. // -------------------------------------------------------- // GameTag: // - CANT_BE_TARGETED_BY_SPELLS = 1 // - CANT_BE_TARGETED_BY_HERO_POWERS = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(std::make_shared<Enchant>( Effects::CantBeTargetedBySpellsAndHeroPowers())); cardDef.power.AddTrigger( std::make_shared<Trigger>(TriggerType::TURN_START)); cardDef.power.GetTrigger()->tasks = { std::make_shared<RemoveEnchantmentTask>() }; cards.emplace("DAL_081e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_086e] Stolen Secrets (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +1/+1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_086e")); cards.emplace("DAL_086e", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_087t] Amalgam (*) - COST:1 [ATK:1/HP:1] // - Race: All, Set: Dalaran // -------------------------------------------------------- // Text: <i>This is an Elemental, Mech, Demon, Murloc, Dragon, // Beast, Pirate and Totem.</i> // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_087t", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_088t2] Vault Safe (*) - COST:2 [ATK:0/HP:5] // - Race: Mechanical, Set: Dalaran // -------------------------------------------------------- // Text: <b>Taunt</b> // -------------------------------------------------------- // GameTag: // - TAUNT = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_088t2", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_095e] Pizzazz (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Increased Attack. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant( std::make_unique<Enchant>(Enchants::AddAttackScriptTag)); cards.emplace("DAL_095e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_147e] Dragon Shout (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +3/+3. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_147e")); cards.emplace("DAL_147e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_351e] Ancient Blessings (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +1/+1. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_351e")); cards.emplace("DAL_351e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_548e] Arcane Expansion (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Increased <b>Spell Damage</b>. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant( std::make_shared<OngoingEnchant>(EffectList{ std::make_shared<Effect>( GameTag::SPELLPOWER, EffectOperator::ADD, 2) })); cards.emplace("DAL_548e", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_554t] Greasefire Elemental (*) - COST:6 [ATK:6/HP:6] // - Race: Elemental, Faction: Neutral, Set: Dalaran // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_554t", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_566t] Vengeful Scroll (*) - COST:1 [ATK:1/HP:1] // - Set: Dalaran // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_566t", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_560e2] Protect the Brews! (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Increased stats. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant( std::make_unique<Enchant>(Enchants::AddAttackHealthScriptTag)); cards.emplace("DAL_560e2", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_561e] Imp-onomical (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Costs (1) less. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant( std::make_shared<OngoingEnchant>(EffectList{ Effects::ReduceCost(1) })); cards.emplace("DAL_561e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_563e] Power of EVIL (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +2/+2. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_563e")); cards.emplace("DAL_563e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_570e] Never Surrender! (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +2 Health. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_570e")); cards.emplace("DAL_570e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_576e] Kirin Tor's Curse (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Costs (1) more. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(std::make_shared<Enchant>(Effects::AddCost(1))); cards.emplace("DAL_576e", cardDef); // ---------------------------------------- SPELL - NEUTRAL // [DAL_582t] Felhound Portal (*) - COST:2 // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Casts When Drawn</b> // Summon a 2/2 Felhound with <b>Rush</b>. // -------------------------------------------------------- // GameTag: // - TOPDECK = 1 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // - CASTSWHENDRAWN = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddTopdeckTask(std::make_shared<SummonTask>("DAL_582t2")); cardDef.power.AddPowerTask(std::make_shared<SummonTask>("DAL_582t2")); cards.emplace("DAL_582t", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_582t2] Felhound (*) - COST:2 [ATK:2/HP:2] // - Race: Demon, Set: Dalaran // -------------------------------------------------------- // Text: <b>Rush</b> // -------------------------------------------------------- // GameTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_582t2", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_589e] Hunting Party (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +3/+3. // -------------------------------------------------------- // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_607e] Fleeting Fel (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Rush</b>. Dies at end of turn. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(std::make_shared<Enchant>(Effects::Rush)); cardDef.power.AddTrigger(std::make_shared<Trigger>(TriggerType::TURN_END)); cardDef.power.GetTrigger()->tasks = { std::make_shared<DestroyTask>(EntityType::TARGET), }; cards.emplace("DAL_607e", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_613] Faceless Lackey (*) - COST:1 [ATK:1/HP:1] // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Battlecry:</b> Summon a random 2-Cost minion. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // - MARK_OF_EVIL = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(std::make_shared<RandomMinionTask>( TagValues{ { GameTag::COST, 2, RelaSign::EQ } })); cardDef.power.AddPowerTask(std::make_shared<SummonTask>()); cards.emplace("DAL_613", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_614] Kobold Lackey (*) - COST:1 [ATK:1/HP:1] // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Battlecry:</b> Deal 2 damage. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // - MARK_OF_EVIL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_TARGET_TO_PLAY = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DamageTask>(EntityType::TARGET, 2)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_TARGET_TO_PLAY, 0 } }; cards.emplace("DAL_614", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_615] Witchy Lackey (*) - COST:1 [ATK:1/HP:1] // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Battlecry:</b> Transform a friendly minion into one // that costs (1) more. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // - MARK_OF_EVIL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_MINION_TARGET = 0 // - REQ_TARGET_IF_AVAILABLE = 0 // - REQ_FRIENDLY_TARGET = 0 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<TransformMinionTask>(EntityType::TARGET, 1)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_TARGET_IF_AVAILABLE, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 } }; cards.emplace("DAL_615", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_714e] Street Smarts (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +1/+1. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_714e")); cards.emplace("DAL_714e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_726e] Scargil's Blessing (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Costs (1). // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(std::make_shared<Enchant>(Effects::SetCost(1))); cards.emplace("DAL_726e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_727e] Heroic (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +2/+2. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_727e")); cards.emplace("DAL_727e", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_739] Goblin Lackey (*) - COST:1 [ATK:1/HP:1] // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Battlecry:</b> Give a friendly minion +1 Attack // and <b>Rush</b>. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // - MARK_OF_EVIL = 1 // -------------------------------------------------------- // PlayReq: // - REQ_MINION_TARGET = 0 // - REQ_TARGET_IF_AVAILABLE = 0 // - REQ_FRIENDLY_TARGET = 0 // -------------------------------------------------------- // RefTag: // - RUSH = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<AddEnchantmentTask>("DAL_739e", EntityType::TARGET)); cardDef.property.playReqs = PlayReqs{ { PlayReq::REQ_MINION_TARGET, 0 }, { PlayReq::REQ_TARGET_IF_AVAILABLE, 0 }, { PlayReq::REQ_FRIENDLY_TARGET, 0 } }; cards.emplace("DAL_739", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_739e] Short Fuse (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +1 Attack and <b>Rush</b>. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_739e")); cards.emplace("DAL_739e", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_741] Ethereal Lackey (*) - COST:1 [ATK:1/HP:1] // - Set: Dalaran // -------------------------------------------------------- // Text: <b>Battlecry:</b> <b>Discover</b> a spell. // -------------------------------------------------------- // GameTag: // - BATTLECRY = 1 // - MARK_OF_EVIL = 1 // -------------------------------------------------------- // RefTag: // - DISCOVER = 1 // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask( std::make_shared<DiscoverTask>(DiscoverType::SPELL)); cards.emplace("DAL_741", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_743t] Hench-Clan Squire (*) - COST:1 [ATK:1/HP:1] // - Race: Murloc, Set: Dalaran // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_743t", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_744e] Familiar Faces (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Copied health. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant( std::make_unique<Enchant>(Enchants::SetHealthScriptTag)); cards.emplace("DAL_744e", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_747t] Gryphon (*) - COST:2 [ATK:2/HP:2] // - Race: Beast, Faction: Alliance, Set: Dalaran // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_747t", cardDef); // --------------------------------------- MINION - NEUTRAL // [DAL_751t] Imp (*) - COST:1 [ATK:1/HP:1] // - Race: Demon, Faction: Neutral, Set: Dalaran // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddPowerTask(nullptr); cards.emplace("DAL_751t", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_752e] Toy-sized (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Jepetto Joybuzz made this 1/1. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_752e")); cards.emplace("DAL_752e", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_752e2] On Sale (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: Costs (1). // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(std::make_shared<Enchant>(Effects::SetCost(1))); cards.emplace("DAL_752e2", cardDef); // ---------------------------------- ENCHANTMENT - NEUTRAL // [DAL_773e] Flying High (*) - COST:0 // - Set: Dalaran // -------------------------------------------------------- // Text: +1 Attack and <b>Rush</b>. // -------------------------------------------------------- cardDef.ClearData(); cardDef.power.AddEnchant(Enchants::GetEnchantFromText("DAL_773e")); cards.emplace("DAL_773e", cardDef); } void DalaranCardsGen::AddAll(std::map<std::string, CardDef>& cards) { AddHeroes(cards); AddHeroPowers(cards); AddDruid(cards); AddDruidNonCollect(cards); AddHunter(cards); AddHunterNonCollect(cards); AddMage(cards); AddMageNonCollect(cards); AddPaladin(cards); AddPaladinNonCollect(cards); AddPriest(cards); AddPriestNonCollect(cards); AddRogue(cards); AddRogueNonCollect(cards); AddShaman(cards); AddShamanNonCollect(cards); AddWarlock(cards); AddWarlockNonCollect(cards); AddWarrior(cards); AddWarriorNonCollect(cards); AddNeutral(cards); AddNeutralNonCollect(cards); } } // namespace RosettaStone::PlayMode
44.329824
80
0.453202
Hearthstonepp
66eb4fdb23fcee252f2c081236d710f9cc8f901f
9,021
cxx
C++
test/integration/file/file_system_path_itest.cxx
ANSAKsoftware/ansak-lib
93eff12a50464f3071b27c8eb16336f93d0d04c6
[ "BSD-2-Clause" ]
null
null
null
test/integration/file/file_system_path_itest.cxx
ANSAKsoftware/ansak-lib
93eff12a50464f3071b27c8eb16336f93d0d04c6
[ "BSD-2-Clause" ]
null
null
null
test/integration/file/file_system_path_itest.cxx
ANSAKsoftware/ansak-lib
93eff12a50464f3071b27c8eb16336f93d0d04c6
[ "BSD-2-Clause" ]
null
null
null
/////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2015, Arthur N. Klassen // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // /////////////////////////////////////////////////////////////////////////// // // 2015.12.26 - First Version // // May you do good and not evil. // May you find forgiveness for yourself and forgive others. // May you share freely, never taking more than you give. // /////////////////////////////////////////////////////////////////////////// // // file_path_test.cxx -- Tests for FilePath in file_path.cxx // /////////////////////////////////////////////////////////////////////////// #include <gtest/gtest.h> #include <file_system_path.hxx> #include <ansak/string_splitjoin.hxx> #include <runtime_exception.hxx> #include <iostream> #include <vector> #include <sstream> using namespace ansak; using namespace std; using namespace testing; TEST(FileSystemPathITest, testConstructor) { // implicitly goes through FilePath FileSystemPath empty; EXPECT_FALSE(empty.asUtf8String().empty()); EXPECT_FALSE(empty.asUtf16String().empty()); EXPECT_TRUE(empty.isValid()); EXPECT_FALSE(empty.isRelative()); EXPECT_FALSE(empty.isRoot()); EXPECT_TRUE(empty.exists()); EXPECT_FALSE(empty.isFile()); EXPECT_TRUE(empty.isDir()); EXPECT_EQ(0u, empty.size()); FileSystemPath otherEmpty; EXPECT_TRUE(empty == otherEmpty); EXPECT_TRUE(empty <= otherEmpty); EXPECT_TRUE(empty >= otherEmpty); EXPECT_FALSE(empty != otherEmpty); EXPECT_FALSE(empty < otherEmpty); EXPECT_FALSE(empty > otherEmpty); // straight from a string #if defined(WIN32) FileSystemPath root("C:\\"); #else FileSystemPath root("/"); #endif EXPECT_FALSE(root.asUtf8String().empty()); EXPECT_FALSE(root.asUtf16String().empty()); EXPECT_TRUE(root.isValid()); EXPECT_FALSE(root.isRelative()); EXPECT_TRUE(root.isRoot()); EXPECT_TRUE(root.exists()); EXPECT_FALSE(root.isFile()); EXPECT_TRUE(root.isDir()); EXPECT_EQ(0u, root.size()); EXPECT_FALSE(root == empty); EXPECT_FALSE(root >= empty); EXPECT_TRUE(root <= empty); EXPECT_TRUE(root != empty); EXPECT_TRUE(root < empty); EXPECT_FALSE(root > empty); } TEST(FileSystemPathITest, testBadConstructor) { // implicitly goes through FilePath ostringstream os; os << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << ".." << FilePath::pathSep << "i-expect-some-file-here"; FileSystemPath bad0(os.str()); EXPECT_FALSE(bad0.isValid()); EXPECT_FALSE(bad0.isRelative()); EXPECT_FALSE(bad0.isRoot()); EXPECT_FALSE(bad0.isFile()); EXPECT_FALSE(bad0.exists()); EXPECT_FALSE(bad0.isDir()); EXPECT_EQ(0u, bad0.size()); // yes, I'm asking the systems to parse the wrong root... #if defined(WIN32) FilePath falseRoot("/"); #else FilePath falseRoot("C:\\"); #endif FileSystemPath bad1(falseRoot); EXPECT_FALSE(bad1.isValid()); EXPECT_FALSE(bad1.isRelative()); EXPECT_FALSE(bad1.isRoot()); #if defined(WIN32) EXPECT_TRUE(bad1.exists()); EXPECT_TRUE(bad1.isDir()); #else EXPECT_FALSE(bad1.exists()); EXPECT_FALSE(bad1.isDir()); #endif EXPECT_FALSE(bad1.isFile()); EXPECT_EQ(0u, bad1.size()); } TEST(FileSystemPathITest, testCreateDirectory) { FileSystemPath thisSrcFile(__FILE__); FileSystemPath thisParent(thisSrcFile.parent()); EXPECT_TRUE(thisParent.createDirectory()); EXPECT_FALSE(thisParent.createFile()); FilePath srcFileAsDir(thisSrcFile); FilePath subSrc(srcFileAsDir.child("noway")); FileSystemPath subSrcForSystem(subSrc); EXPECT_FALSE(subSrcForSystem.createDirectory()); FilePath parentPath(thisParent); FilePath subDeepPath(parentPath.child("some").child("deeper").child("path")); FileSystemPath subDeep(subDeepPath); EXPECT_FALSE(subDeep.createDirectory()); FileSystemPath subDeepParent(parentPath.child("some")); subDeepParent.remove(FileSystemPath::recursively); #if !defined(WIN32) FilePath usr("/usr"); FilePath dontTellMeYouCanDoThis(usr.child("bin").child("dont").child("tell").child("me").child("you").child("can")); FileSystemPath noneSuch(dontTellMeYouCanDoThis); EXPECT_FALSE(noneSuch.createDirectory(FileSystemPath::recursively)); #endif } TEST(FileSystemPathITest, testRemoveDirectory) { FileSystemPath thisSrcFile(__FILE__); FileSystemPath grandParent(thisSrcFile.parent().parent()); EXPECT_FALSE(grandParent.remove()); FileSystemPath thisParent(thisSrcFile.parent()); FilePath parentPath(thisParent); FileSystemPath sib(parentPath.child("sib")); sib.createDirectory(); EXPECT_TRUE(sib.exists()); EXPECT_TRUE(sib.isDir()); EXPECT_TRUE(sib.remove()); EXPECT_FALSE(sib.exists()); /* A tempting test but I don't dare leave it in in case someone suids the test #if !defined(WIN32) FileSystemPath usrbin("/usr/bin"); EXPECT_FALSE(usrbin.remove()); #endif */ } TEST(FileSystemPathITest, testCreateFile) { FileSystemPath thisSrcFile(__FILE__); EXPECT_FALSE(thisSrcFile.createDirectory()); EXPECT_TRUE(thisSrcFile.createFile()); EXPECT_FALSE(thisSrcFile.createFile(FileSystemPath::failIfThere)); EXPECT_TRUE(thisSrcFile.createFile()); FilePath srcFileAsDir(thisSrcFile); FilePath subSrc(srcFileAsDir.child("noway")); FileSystemPath subSrcForSystem(subSrc); EXPECT_FALSE(subSrcForSystem.createFile()); EXPECT_TRUE(subSrcForSystem.remove()); EXPECT_TRUE(subSrcForSystem.remove(FileSystemPath::recursively)); #if !defined(WIN32) FilePath usrbin("/usr/bin"); FileSystemPath youCantTouchThis(usrbin.child("youCantTouchThis")); EXPECT_FALSE(youCantTouchThis.createFile()); #endif } TEST(FileSystemPathITest, testThisSourceFile) { FileSystemPath thisFile(__FILE__); EXPECT_FALSE(thisFile.asUtf8String().empty()); EXPECT_FALSE(thisFile.asUtf16String().empty()); EXPECT_TRUE(thisFile.isValid()); EXPECT_FALSE(thisFile.isRelative()); EXPECT_FALSE(thisFile.isRoot()); EXPECT_TRUE(thisFile.exists()); EXPECT_TRUE(thisFile.isFile()); EXPECT_FALSE(thisFile.isDir()); EXPECT_GT(thisFile.size(), 3072u); EXPECT_GT(thisFile.lastModTime().year, 2015u); FileSystemPath notHere("./give-me-a-break.basic"); auto noTime(notHere.lastModTime()); EXPECT_EQ(0u, noTime.year); EXPECT_EQ(0u, noTime.month); EXPECT_EQ(0u, noTime.day); EXPECT_EQ(0u, noTime.hour); EXPECT_EQ(0u, noTime.minute); EXPECT_EQ(0u, noTime.second); FilePath thisFileAsPath(thisFile); EXPECT_EQ(thisFile.asUtf8String(), thisFileAsPath.asUtf8String()); EXPECT_EQ(thisFile.asUtf16String(), thisFileAsPath.asUtf16String()); EXPECT_EQ(thisFile.asUtf16String(), toUtf16(thisFileAsPath.asUtf8String())); } TEST(FileSystemPathITest, testScanThisDir) { { FileSystemPath p; auto retriever = p.children(); int entriesFound = 0; for (auto c = retriever(); c.isValid(); ++entriesFound, c = retriever()) ; EXPECT_LT(2, entriesFound); EXPECT_EQ(FilePath::invalidPath(), retriever()); } { FileSystemPath p; auto retriever = p.children(); auto c = retriever(); c = retriever(); } }
34.431298
152
0.677419
ANSAKsoftware
66eba512c0ab5e256302c89973cc39facd55f297
4,264
cpp
C++
src/ast/ast.cpp
strandfield/libscript
5d413762ad8ce88ff887642f6947032017dd284c
[ "MIT" ]
3
2020-12-28T01:40:45.000Z
2021-05-18T01:47:07.000Z
src/ast/ast.cpp
strandfield/libscript
5d413762ad8ce88ff887642f6947032017dd284c
[ "MIT" ]
4
2019-06-29T12:23:11.000Z
2020-07-25T15:38:46.000Z
src/ast/ast.cpp
strandfield/libscript
5d413762ad8ce88ff887642f6947032017dd284c
[ "MIT" ]
1
2021-11-17T01:49:42.000Z
2021-11-17T01:49:42.000Z
// Copyright (C) 2018-2020 Vincent Chambrin // This file is part of the libscript library // For conditions of distribution and use, see copyright notice in LICENSE #include "script/ast.h" #include "script/ast/ast_p.h" #include "script/script.h" #include "script/parser/parser.h" namespace script { namespace ast { AST::AST() { } AST::AST(const Script & s) : source(s.source()) , script(s.impl()) { } AST::AST(const SourceFile& src) : source(src) { } void AST::add(const std::shared_ptr<Statement> & statement) { auto *scriptnode = static_cast<ScriptRootNode*>(root.get()); scriptnode->statements.push_back(statement); if (statement->is<Declaration>()) scriptnode->declarations.push_back(std::static_pointer_cast<Declaration>(statement)); } size_t AST::offset(utils::StringView sv) const { return sv.data() - source.content().data(); } SourceFile::Position AST::position(const parser::Token& tok) const { SourceFile::Position pos; pos.pos = offset(tok.text()); pos = source.map(pos.pos); return pos; } } // namespace ast /*! * \class Ast * \brief Represents an abstract syntax tree. * */ /*! * \fn Ast() * \brief Null-constructs an ast */ /*! * \fn Ast(const Ast &) * \brief Constructs a new reference to another ast */ /*! * \fn ~Ast() * \brief Destructor */ /*! * \fn bool isNull() const * \brief Returns whether the Ast is null. */ /*! * \fn SourceFile source() const * \brief Returns the ast source file. */ SourceFile Ast::source() const { return d->source; } /*! * \fn const std::shared_ptr<ast::Node> & root() const * \brief Returns the ast root node. */ const std::shared_ptr<ast::Node> & Ast::root() const { return d->root; } /*! * \fn size_t offset(const ast::Node& n) const * \brief returns the offset of a node within the source code */ size_t Ast::offset(const ast::Node& n) const { return d->offset(n.source()); } /*! * \fn size_t offset(const parser::Token& tok) const * \brief returns the offset of a token within the source code */ size_t Ast::offset(const parser::Token& tok) const { return d->offset(tok.text()); } /*! * \fn bool isScript() const * \brief Returns whether this is the ast of a Script */ bool Ast::isScript() const { return d->root->is<ast::ScriptRootNode>(); } /*! * \fn Script script() const * \brief Returns the script associated with this ast. * * Note that you can call this function even if \m isScript returns false; * in such case, a null script is returned. */ Script Ast::script() const { return Script{ d->script.lock() }; } /*! * \fn const std::vector<std::shared_ptr<ast::Statement>> & statements() const * \brief Returns the top-level statements of the script * * Calling this function when \m isScript returns false is undefined behavior. */ const std::vector<std::shared_ptr<ast::Statement>> & Ast::statements() const { return d->root->as<ast::ScriptRootNode>().statements; } /*! * \fn const std::vector<std::shared_ptr<ast::Declaration>> & declarations() const * \brief Returns the top-level declarations of the script * * This returns the subset of \m statements for which \c{Statement::isDeclaration()} returns true. * * Calling this function when \m isScript returns false is undefined behavior. */ const std::vector<std::shared_ptr<ast::Declaration>> & Ast::declarations() const { return d->root->as<ast::ScriptRootNode>().declarations; } /*! * \fn bool isExpression() const * \brief Returns whether this is the ast of an expression * */ bool Ast::isExpression() const { return d->root->is<ast::Expression>(); } /*! * \fn std::shared_ptr<ast::Expression> expression() const * \brief Returns the expression associated with this ast * * It is safe to call this function even if \m isExpression returns false; * in such case a null pointer is returned. */ std::shared_ptr<ast::Expression> Ast::expression() const { return std::dynamic_pointer_cast<ast::Expression>(d->root); } /*! * \namespace ast */ namespace ast { /*! * \fn Ast parse(const SourceFile& source) * \brief produces an ast for a source file * \param the source file * */ Ast parse(const SourceFile& source) { return Ast{ script::parser::parse(source) }; } } // namespace ast } // namespace script
20.401914
98
0.680582
strandfield
66ecedb542778696ac08c948f03f710a17989572
1,303
hpp
C++
sprout/operation/fixed/pop_front.hpp
jwakely/Sprout
a64938fad0a64608f22d39485bc55a1e0dc07246
[ "BSL-1.0" ]
1
2018-09-21T23:50:44.000Z
2018-09-21T23:50:44.000Z
sprout/operation/fixed/pop_front.hpp
jwakely/Sprout
a64938fad0a64608f22d39485bc55a1e0dc07246
[ "BSL-1.0" ]
null
null
null
sprout/operation/fixed/pop_front.hpp
jwakely/Sprout
a64938fad0a64608f22d39485bc55a1e0dc07246
[ "BSL-1.0" ]
null
null
null
#ifndef SPROUT_OPERATION_FIXED_POP_FRONT_HPP #define SPROUT_OPERATION_FIXED_POP_FRONT_HPP #include <cstddef> #include <sprout/config.hpp> #include <sprout/index_tuple.hpp> #include <sprout/container/traits.hpp> #include <sprout/container/functions.hpp> #include <sprout/operation/fixed/erase.hpp> namespace sprout { namespace fixed { namespace result_of { // // pop_front // template<typename Container> struct pop_front : public sprout::fixed::result_of::erase<Container> {}; } // namespace result_of // // pop_front // template<typename Container> inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::pop_front<Container>::type pop_front( Container const& cont ) { return sprout::fixed::detail::erase_impl<typename sprout::fixed::result_of::pop_front<Container>::type>( cont, sprout::index_range<0, sprout::container_traits<typename sprout::fixed::result_of::pop_front<Container>::type>::static_size>::make(), sprout::internal_begin_offset(cont) ); } } // namespace fixed namespace result_of { using sprout::fixed::result_of::pop_front; } // namespace result_of using sprout::fixed::pop_front; } // namespace sprout #endif // #ifndef SPROUT_OPERATION_FIXED_POP_FRONT_HPP
27.723404
138
0.712203
jwakely
66f280f9b1e2b8eb1baa1f423e6ca7cad0f381c1
14,166
cpp
C++
src/sksl/SkSLConstantFolder.cpp
kita-ui/skia
c09761f57605f408e473a73fbfe25a2636676bfa
[ "BSD-3-Clause" ]
null
null
null
src/sksl/SkSLConstantFolder.cpp
kita-ui/skia
c09761f57605f408e473a73fbfe25a2636676bfa
[ "BSD-3-Clause" ]
null
null
null
src/sksl/SkSLConstantFolder.cpp
kita-ui/skia
c09761f57605f408e473a73fbfe25a2636676bfa
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright 2020 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "src/sksl/SkSLConstantFolder.h" #include <limits> #include "src/sksl/SkSLContext.h" #include "src/sksl/SkSLErrorReporter.h" #include "src/sksl/ir/SkSLBinaryExpression.h" #include "src/sksl/ir/SkSLBoolLiteral.h" #include "src/sksl/ir/SkSLConstructor.h" #include "src/sksl/ir/SkSLExpression.h" #include "src/sksl/ir/SkSLFloatLiteral.h" #include "src/sksl/ir/SkSLIntLiteral.h" #include "src/sksl/ir/SkSLType.h" #include "src/sksl/ir/SkSLVariable.h" #include "src/sksl/ir/SkSLVariableReference.h" namespace SkSL { static std::unique_ptr<Expression> eliminate_no_op_boolean(const Expression& left, Token::Kind op, const Expression& right) { SkASSERT(right.is<BoolLiteral>()); bool rightVal = right.as<BoolLiteral>().value(); // Detect no-op Boolean expressions and optimize them away. if ((op == Token::Kind::TK_LOGICALAND && rightVal) || // (expr && true) -> (expr) (op == Token::Kind::TK_LOGICALOR && !rightVal) || // (expr || false) -> (expr) (op == Token::Kind::TK_LOGICALXOR && !rightVal) || // (expr ^^ false) -> (expr) (op == Token::Kind::TK_EQEQ && rightVal) || // (expr == true) -> (expr) (op == Token::Kind::TK_NEQ && !rightVal)) { // (expr != false) -> (expr) return left.clone(); } return nullptr; } static std::unique_ptr<Expression> short_circuit_boolean(const Expression& left, Token::Kind op, const Expression& right) { SkASSERT(left.is<BoolLiteral>()); bool leftVal = left.as<BoolLiteral>().value(); // When the literal is on the left, we can sometimes eliminate the other expression entirely. if ((op == Token::Kind::TK_LOGICALAND && !leftVal) || // (false && expr) -> (false) (op == Token::Kind::TK_LOGICALOR && leftVal)) { // (true || expr) -> (true) return left.clone(); } // We can't eliminate the right-side expression via short-circuit, but we might still be able to // simplify away a no-op expression. return eliminate_no_op_boolean(right, op, left); } template <typename T> static std::unique_ptr<Expression> simplify_vector(const Context& context, const Expression& left, Token::Kind op, const Expression& right) { SkASSERT(left.type().isVector()); SkASSERT(left.type() == right.type()); const Type& type = left.type(); // Handle boolean operations: == != if (op == Token::Kind::TK_EQEQ || op == Token::Kind::TK_NEQ) { bool equality = (op == Token::Kind::TK_EQEQ); switch (left.compareConstant(right)) { case Expression::ComparisonResult::kNotEqual: equality = !equality; [[fallthrough]]; case Expression::ComparisonResult::kEqual: return std::make_unique<BoolLiteral>(context, left.fOffset, equality); case Expression::ComparisonResult::kUnknown: return nullptr; } } // Handle floating-point arithmetic: + - * / const auto vectorComponentwiseFold = [&](auto foldFn) -> std::unique_ptr<Constructor> { const Type& componentType = type.componentType(); ExpressionArray args; args.reserve_back(type.columns()); for (int i = 0; i < type.columns(); i++) { T value = foldFn(left.getVecComponent<T>(i), right.getVecComponent<T>(i)); args.push_back(std::make_unique<Literal<T>>(left.fOffset, value, &componentType)); } return std::make_unique<Constructor>(left.fOffset, &type, std::move(args)); }; const auto isVectorDivisionByZero = [&]() -> bool { for (int i = 0; i < type.columns(); i++) { if (right.getVecComponent<T>(i) == 0) { return true; } } return false; }; switch (op) { case Token::Kind::TK_PLUS: return vectorComponentwiseFold([](T a, T b) { return a + b; }); case Token::Kind::TK_MINUS: return vectorComponentwiseFold([](T a, T b) { return a - b; }); case Token::Kind::TK_STAR: return vectorComponentwiseFold([](T a, T b) { return a * b; }); case Token::Kind::TK_SLASH: { if (isVectorDivisionByZero()) { context.fErrors.error(right.fOffset, "division by zero"); return nullptr; } return vectorComponentwiseFold([](T a, T b) { return a / b; }); } default: return nullptr; } } static Constructor splat_scalar(const Expression& scalar, const Type& type) { SkASSERT(type.isVector()); SkASSERT(type.componentType() == scalar.type()); // Use a Constructor to splat the scalar expression across a vector. ExpressionArray arg; arg.push_back(scalar.clone()); return Constructor{scalar.fOffset, &type, std::move(arg)}; } std::unique_ptr<Expression> ConstantFolder::Simplify(const Context& context, const Expression& left, Token::Kind op, const Expression& right) { // Simplify the expression when both sides are constant Boolean literals. if (left.is<BoolLiteral>() && right.is<BoolLiteral>()) { bool leftVal = left.as<BoolLiteral>().value(); bool rightVal = right.as<BoolLiteral>().value(); bool result; switch (op) { case Token::Kind::TK_LOGICALAND: result = leftVal && rightVal; break; case Token::Kind::TK_LOGICALOR: result = leftVal || rightVal; break; case Token::Kind::TK_LOGICALXOR: result = leftVal ^ rightVal; break; case Token::Kind::TK_EQEQ: result = leftVal == rightVal; break; case Token::Kind::TK_NEQ: result = leftVal != rightVal; break; default: return nullptr; } return std::make_unique<BoolLiteral>(context, left.fOffset, result); } // If the left side is a Boolean literal, apply short-circuit optimizations. if (left.is<BoolLiteral>()) { return short_circuit_boolean(left, op, right); } // If the right side is a Boolean literal... if (right.is<BoolLiteral>()) { // ... and the left side has no side effects... if (!left.hasSideEffects()) { // We can reverse the expressions and short-circuit optimizations are still valid. return short_circuit_boolean(right, op, left); } // We can't use short-circuiting, but we can still optimize away no-op Boolean expressions. return eliminate_no_op_boolean(left, op, right); } // Other than the short-circuit cases above, constant folding requires both sides to be constant if (!left.isCompileTimeConstant() || !right.isCompileTimeConstant()) { return nullptr; } // Note that we expressly do not worry about precision and overflow here -- we use the maximum // precision to calculate the results and hope the result makes sense. // TODO: detect and handle integer overflow properly. #define RESULT(t, op) std::make_unique<t ## Literal>(context, left.fOffset, \ leftVal op rightVal) #define URESULT(t, op) std::make_unique<t ## Literal>(context, left.fOffset, \ (uint64_t) leftVal op \ (uint64_t) rightVal) if (left.is<IntLiteral>() && right.is<IntLiteral>()) { SKSL_INT leftVal = left.as<IntLiteral>().value(); SKSL_INT rightVal = right.as<IntLiteral>().value(); switch (op) { case Token::Kind::TK_PLUS: return URESULT(Int, +); case Token::Kind::TK_MINUS: return URESULT(Int, -); case Token::Kind::TK_STAR: return URESULT(Int, *); case Token::Kind::TK_SLASH: if (leftVal == std::numeric_limits<SKSL_INT>::min() && rightVal == -1) { context.fErrors.error(right.fOffset, "arithmetic overflow"); return nullptr; } if (!rightVal) { context.fErrors.error(right.fOffset, "division by zero"); return nullptr; } return RESULT(Int, /); case Token::Kind::TK_PERCENT: if (leftVal == std::numeric_limits<SKSL_INT>::min() && rightVal == -1) { context.fErrors.error(right.fOffset, "arithmetic overflow"); return nullptr; } if (!rightVal) { context.fErrors.error(right.fOffset, "division by zero"); return nullptr; } return RESULT(Int, %); case Token::Kind::TK_BITWISEAND: return RESULT(Int, &); case Token::Kind::TK_BITWISEOR: return RESULT(Int, |); case Token::Kind::TK_BITWISEXOR: return RESULT(Int, ^); case Token::Kind::TK_EQEQ: return RESULT(Bool, ==); case Token::Kind::TK_NEQ: return RESULT(Bool, !=); case Token::Kind::TK_GT: return RESULT(Bool, >); case Token::Kind::TK_GTEQ: return RESULT(Bool, >=); case Token::Kind::TK_LT: return RESULT(Bool, <); case Token::Kind::TK_LTEQ: return RESULT(Bool, <=); case Token::Kind::TK_SHL: if (rightVal >= 0 && rightVal <= 31) { return RESULT(Int, <<); } context.fErrors.error(right.fOffset, "shift value out of range"); return nullptr; case Token::Kind::TK_SHR: if (rightVal >= 0 && rightVal <= 31) { return RESULT(Int, >>); } context.fErrors.error(right.fOffset, "shift value out of range"); return nullptr; default: return nullptr; } } // Perform constant folding on pairs of floating-point literals. if (left.is<FloatLiteral>() && right.is<FloatLiteral>()) { SKSL_FLOAT leftVal = left.as<FloatLiteral>().value(); SKSL_FLOAT rightVal = right.as<FloatLiteral>().value(); switch (op) { case Token::Kind::TK_PLUS: return RESULT(Float, +); case Token::Kind::TK_MINUS: return RESULT(Float, -); case Token::Kind::TK_STAR: return RESULT(Float, *); case Token::Kind::TK_SLASH: if (rightVal) { return RESULT(Float, /); } context.fErrors.error(right.fOffset, "division by zero"); return nullptr; case Token::Kind::TK_EQEQ: return RESULT(Bool, ==); case Token::Kind::TK_NEQ: return RESULT(Bool, !=); case Token::Kind::TK_GT: return RESULT(Bool, >); case Token::Kind::TK_GTEQ: return RESULT(Bool, >=); case Token::Kind::TK_LT: return RESULT(Bool, <); case Token::Kind::TK_LTEQ: return RESULT(Bool, <=); default: return nullptr; } } // Perform constant folding on pairs of vectors. const Type& leftType = left.type(); const Type& rightType = right.type(); if (leftType.isVector() && leftType == rightType) { if (leftType.componentType().isFloat()) { return simplify_vector<SKSL_FLOAT>(context, left, op, right); } if (leftType.componentType().isInteger()) { return simplify_vector<SKSL_INT>(context, left, op, right); } return nullptr; } // Perform constant folding on vectors against scalars, e.g.: half4(2) + 2 if (leftType.isVector() && leftType.componentType() == rightType) { if (rightType.isFloat()) { return simplify_vector<SKSL_FLOAT>(context, left, op, splat_scalar(right, left.type())); } if (rightType.isInteger()) { return simplify_vector<SKSL_INT>(context, left, op, splat_scalar(right, left.type())); } return nullptr; } // Perform constant folding on scalars against vectors, e.g.: 2 + half4(2) if (rightType.isVector() && rightType.componentType() == leftType) { if (leftType.isFloat()) { return simplify_vector<SKSL_FLOAT>(context, splat_scalar(left, right.type()), op, right); } if (leftType.isInteger()) { return simplify_vector<SKSL_INT>(context, splat_scalar(left, right.type()), op, right); } return nullptr; } // Perform constant folding on pairs of matrices. if (leftType.isMatrix() && rightType.isMatrix()) { bool equality; switch (op) { case Token::Kind::TK_EQEQ: equality = true; break; case Token::Kind::TK_NEQ: equality = false; break; default: return nullptr; } switch (left.compareConstant(right)) { case Expression::ComparisonResult::kNotEqual: equality = !equality; [[fallthrough]]; case Expression::ComparisonResult::kEqual: return std::make_unique<BoolLiteral>(context, left.fOffset, equality); case Expression::ComparisonResult::kUnknown: return nullptr; } } // We aren't able to constant-fold. #undef RESULT #undef URESULT return nullptr; } } // namespace SkSL
42.413174
100
0.552802
kita-ui
66f87bd07f2a3f2ac283c3fa24534763080fc38a
8,252
cc
C++
icing/index/iterator/doc-hit-info-iterator-and.cc
PixelPlusUI-SnowCone/external_icing
206a7d6b4ab83c6acdb8b14565e2431751c9e4cf
[ "Apache-2.0" ]
null
null
null
icing/index/iterator/doc-hit-info-iterator-and.cc
PixelPlusUI-SnowCone/external_icing
206a7d6b4ab83c6acdb8b14565e2431751c9e4cf
[ "Apache-2.0" ]
null
null
null
icing/index/iterator/doc-hit-info-iterator-and.cc
PixelPlusUI-SnowCone/external_icing
206a7d6b4ab83c6acdb8b14565e2431751c9e4cf
[ "Apache-2.0" ]
null
null
null
// Copyright (C) 2019 Google LLC // // Licensed 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 "icing/index/iterator/doc-hit-info-iterator-and.h" #include <stddef.h> #include <cstdint> #include <memory> #include <string> #include <utility> #include <vector> #include "icing/text_classifier/lib3/utils/base/status.h" #include "icing/absl_ports/canonical_errors.h" #include "icing/absl_ports/str_cat.h" #include "icing/index/hit/doc-hit-info.h" #include "icing/index/iterator/doc-hit-info-iterator.h" #include "icing/schema/section.h" #include "icing/store/document-id.h" #include "icing/util/status-macros.h" namespace icing { namespace lib { namespace { // When combining ANDed iterators, n-ary operator has better performance when // number of operands > 3 according to benchmark cl/243720660 inline constexpr int kBinaryAndIteratorPerformanceThreshold = 3; // The minimum number of iterators needed to construct a And iterator. The And // constructor currently takes 2 iterators. inline constexpr int kMinBinaryIterators = 2; } // namespace std::unique_ptr<DocHitInfoIterator> CreateAndIterator( std::vector<std::unique_ptr<DocHitInfoIterator>> iterators) { if (iterators.size() == 1) { return std::move(iterators.at(0)); } std::unique_ptr<DocHitInfoIterator> iterator; if (iterators.size() <= kBinaryAndIteratorPerformanceThreshold && iterators.size() >= kMinBinaryIterators) { // Accumulate the iterators that need to be ANDed together. iterator = std::move(iterators.at(0)); for (size_t i = 1; i < iterators.size(); ++i) { std::unique_ptr<DocHitInfoIterator> temp_iterator = std::move(iterator); iterator = std::make_unique<DocHitInfoIteratorAnd>( std::move(temp_iterator), std::move(iterators[i])); } } else { // If the vector is too small, the AndNary iterator can handle it and return // an error on the Advance call iterator = std::make_unique<DocHitInfoIteratorAndNary>(std::move(iterators)); } return iterator; } DocHitInfoIteratorAnd::DocHitInfoIteratorAnd( std::unique_ptr<DocHitInfoIterator> short_it, std::unique_ptr<DocHitInfoIterator> long_it) : short_(std::move(short_it)), long_(std::move(long_it)) {} libtextclassifier3::Status DocHitInfoIteratorAnd::Advance() { // Advance on short first if (!short_->Advance().ok()) { // Didn't find anything for the first iterator, reset to invalid values and // return. doc_hit_info_ = DocHitInfo(kInvalidDocumentId); hit_intersect_section_ids_mask_ = kSectionIdMaskNone; return absl_ports::ResourceExhaustedError( "No more DocHitInfos in iterator"); } DocumentId short_doc_id = short_->doc_hit_info().document_id(); // Then AdvanceTo on long ICING_ASSIGN_OR_RETURN(DocumentId long_doc_id, AdvanceTo(long_.get(), short_doc_id)); // Now try to align DocHitInfos by moving one or the other. while (short_doc_id != long_doc_id) { if (short_doc_id > long_doc_id) { ICING_ASSIGN_OR_RETURN(short_doc_id, AdvanceTo(short_.get(), long_doc_id)); } else { ICING_ASSIGN_OR_RETURN(long_doc_id, AdvanceTo(long_.get(), short_doc_id)); } } // Guaranteed that short_doc_id and long_doc_id match now doc_hit_info_ = short_->doc_hit_info(); doc_hit_info_.MergeSectionsFrom(long_->doc_hit_info()); hit_intersect_section_ids_mask_ = short_->hit_intersect_section_ids_mask() & long_->hit_intersect_section_ids_mask(); return libtextclassifier3::Status::OK; } int32_t DocHitInfoIteratorAnd::GetNumBlocksInspected() const { return short_->GetNumBlocksInspected() + long_->GetNumBlocksInspected(); } int32_t DocHitInfoIteratorAnd::GetNumLeafAdvanceCalls() const { return short_->GetNumLeafAdvanceCalls() + long_->GetNumLeafAdvanceCalls(); } std::string DocHitInfoIteratorAnd::ToString() const { return absl_ports::StrCat("(", short_->ToString(), " AND ", long_->ToString(), ")"); } DocHitInfoIteratorAndNary::DocHitInfoIteratorAndNary( std::vector<std::unique_ptr<DocHitInfoIterator>> iterators) : iterators_(std::move(iterators)) {} libtextclassifier3::Status DocHitInfoIteratorAndNary::Advance() { if (iterators_.size() < 2) { return absl_ports::InvalidArgumentError( "Not enough iterators to AND together"); } // Advance on the first iterator to get a potential hit if (!iterators_.at(0)->Advance().ok()) { // Didn't find anything for the first iterator, reset to invalid values and // return doc_hit_info_ = DocHitInfo(kInvalidDocumentId); hit_intersect_section_ids_mask_ = kSectionIdMaskNone; return absl_ports::ResourceExhaustedError( "No more DocHitInfos in iterator"); } DocumentId potential_document_id = iterators_.at(0)->doc_hit_info().document_id(); // Our goal is to find the next document_id that exists on all the iterators // by advancing the iterators one by one. We start with some // "potential_document_id", check if it actually matches the above goal. If // yes, return. If not, find the next best "potential" and repeat till we hit // the end. // Has the current potential_document_id been found in all the iterators? bool found_document_id = false; while (!found_document_id) { for (auto& iterator : iterators_) { if (iterator->doc_hit_info().document_id() > potential_document_id) { // Advance the current iterator until it's equal to or smaller than the // potential hit doc id DocumentId unused; ICING_ASSIGN_OR_RETURN( unused, AdvanceTo(iterator.get(), potential_document_id)); } if (iterator->doc_hit_info().document_id() == potential_document_id) { // The potential hit got matched on the iterators so far found_document_id = true; continue; } else if (iterator->doc_hit_info().document_id() < potential_document_id) { // This iterator doesn't have potential_document_id as we've gone past // it already. Use the current document_id as the new // "potential_document_id" and start checking all iterators again. found_document_id = false; potential_document_id = iterator->doc_hit_info().document_id(); break; } } } // Found a DocumentId which exists in all the iterators doc_hit_info_ = iterators_.at(0)->doc_hit_info(); hit_intersect_section_ids_mask_ = iterators_.at(0)->hit_intersect_section_ids_mask(); for (size_t i = 1; i < iterators_.size(); i++) { doc_hit_info_.MergeSectionsFrom(iterators_.at(i)->doc_hit_info()); hit_intersect_section_ids_mask_ &= iterators_.at(i)->hit_intersect_section_ids_mask(); } return libtextclassifier3::Status::OK; } int32_t DocHitInfoIteratorAndNary::GetNumBlocksInspected() const { int32_t blockCount = 0; for (const std::unique_ptr<DocHitInfoIterator>& iter : iterators_) { blockCount += iter->GetNumBlocksInspected(); } return blockCount; } int32_t DocHitInfoIteratorAndNary::GetNumLeafAdvanceCalls() const { int32_t leafCount = 0; for (const std::unique_ptr<DocHitInfoIterator>& iter : iterators_) { leafCount += iter->GetNumLeafAdvanceCalls(); } return leafCount; } std::string DocHitInfoIteratorAndNary::ToString() const { std::string ret = "("; for (int i = 0; i < iterators_.size(); ++i) { if (i == iterators_.size() - 1) { // Last element in vector absl_ports::StrAppend(&ret, iterators_.at(i)->ToString(), ")"); } else { absl_ports::StrAppend(&ret, iterators_.at(i)->ToString(), " AND "); } } return ret; } } // namespace lib } // namespace icing
36.034934
80
0.706495
PixelPlusUI-SnowCone
0f007ab125e34219206e41bd0566f58baa5e1ede
12,890
hpp
C++
externals/stlsoft-1.9.118/include/winstl/performance/threadtimes_counter.hpp
betasheet/diffingo
285d21b16c118155e5c149b20fcb20a20276f3d7
[ "MIT" ]
17
2015-03-26T14:10:25.000Z
2022-02-09T20:55:04.000Z
externals/stlsoft-1.9.118/include/winstl/performance/threadtimes_counter.hpp
betasheet/diffingo
285d21b16c118155e5c149b20fcb20a20276f3d7
[ "MIT" ]
null
null
null
externals/stlsoft-1.9.118/include/winstl/performance/threadtimes_counter.hpp
betasheet/diffingo
285d21b16c118155e5c149b20fcb20a20276f3d7
[ "MIT" ]
3
2019-05-05T22:10:56.000Z
2019-08-22T22:24:23.000Z
/* ///////////////////////////////////////////////////////////////////////// * File: winstl/performance/threadtimes_counter.hpp * * Purpose: WinSTL thread-time performance counter class. * * Created: 22nd March 2002 * Updated: 6th May 2010 * * Home: http://stlsoft.org/ * * Copyright (c) 2002-2010, Matthew Wilson and Synesis Software * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of * any contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * ////////////////////////////////////////////////////////////////////// */ /** \file winstl/performance/threadtimes_counter.hpp * * \brief [C++ only] Definition of the * \link winstl::threadtimes_counter threadtimes_counter\endlink class * (\ref group__library__performance "Performance" Library). */ #ifndef WINSTL_INCL_WINSTL_PERFORMANCE_HPP_THREADTIMES_COUNTER #define WINSTL_INCL_WINSTL_PERFORMANCE_HPP_THREADTIMES_COUNTER #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define WINSTL_VER_WINSTL_PERFORMANCE_HPP_THREADTIMES_COUNTER_MAJOR 4 # define WINSTL_VER_WINSTL_PERFORMANCE_HPP_THREADTIMES_COUNTER_MINOR 0 # define WINSTL_VER_WINSTL_PERFORMANCE_HPP_THREADTIMES_COUNTER_REVISION 3 # define WINSTL_VER_WINSTL_PERFORMANCE_HPP_THREADTIMES_COUNTER_EDIT 48 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////// * Includes */ #ifndef WINSTL_INCL_WINSTL_H_WINSTL # include <winstl/winstl.h> #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */ /* ///////////////////////////////////////////////////////////////////////// * Namespace */ #ifndef _WINSTL_NO_NAMESPACE # if defined(_STLSOFT_NO_NAMESPACE) || \ defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) /* There is no stlsoft namespace, so must define ::winstl */ namespace winstl { # else /* Define stlsoft::winstl_project */ namespace stlsoft { namespace winstl_project { # endif /* _STLSOFT_NO_NAMESPACE */ #endif /* !_WINSTL_NO_NAMESPACE */ /* ///////////////////////////////////////////////////////////////////////// * Classes */ // class threadtimes_counter /** \brief A performance counter that provides thread-specific performance timings * * \ingroup group__library__performance * * This class uses the operating system's performance monitoring facilities to provide timing * information pertaining to the calling thread only, irrespective of the activities of other * threads on the system. This class does not provide meaningful timing information on operating * systems that do not provide thread-specific monitoring. */ class threadtimes_counter { public: /// This type typedef threadtimes_counter class_type; private: typedef ws_sint64_t epoch_type; public: /// \brief The interval type /// /// The type of the interval measurement, a 64-bit signed integer typedef ws_sint64_t interval_type; // Construction public: /// \brief Constructor /// /// Creates an instance of the class, and caches the thread token so that measurements will /// be taken with respect to the thread in which the class was created. threadtimes_counter(); // Operations public: /// \brief Starts measurement /// /// Begins the measurement period void start(); /// \brief Ends measurement /// /// Ends the measurement period void stop(); // Attributes public: // Kernel /// \brief The elapsed count in the measurement period for kernel mode activity /// /// This represents the extent, in machine-specific increments, of the measurement period for kernel mode activity interval_type get_kernel_period_count() const; /// \brief The number of whole seconds in the measurement period for kernel mode activity /// /// This represents the extent, in whole seconds, of the measurement period for kernel mode activity interval_type get_kernel_seconds() const; /// \brief The number of whole milliseconds in the measurement period for kernel mode activity /// /// This represents the extent, in whole milliseconds, of the measurement period for kernel mode activity interval_type get_kernel_milliseconds() const; /// \brief The number of whole microseconds in the measurement period for kernel mode activity /// /// This represents the extent, in whole microseconds, of the measurement period for kernel mode activity interval_type get_kernel_microseconds() const; // User /// \brief The elapsed count in the measurement period for user mode activity /// /// This represents the extent, in machine-specific increments, of the measurement period for user mode activity interval_type get_user_period_count() const; /// \brief The number of whole seconds in the measurement period for user mode activity /// /// This represents the extent, in whole seconds, of the measurement period for user mode activity interval_type get_user_seconds() const; /// \brief The number of whole milliseconds in the measurement period for user mode activity /// /// This represents the extent, in whole milliseconds, of the measurement period for user mode activity interval_type get_user_milliseconds() const; /// \brief The number of whole microseconds in the measurement period for user mode activity /// /// This represents the extent, in whole microseconds, of the measurement period for user mode activity interval_type get_user_microseconds() const; // Total /// \brief The elapsed count in the measurement period /// /// This represents the extent, in machine-specific increments, of the measurement period interval_type get_period_count() const; /// \brief The number of whole seconds in the measurement period /// /// This represents the extent, in whole seconds, of the measurement period interval_type get_seconds() const; /// \brief The number of whole milliseconds in the measurement period /// /// This represents the extent, in whole milliseconds, of the measurement period interval_type get_milliseconds() const; /// \brief The number of whole microseconds in the measurement period /// /// This represents the extent, in whole microseconds, of the measurement period interval_type get_microseconds() const; private: // Implementation static epoch_type convert_(FILETIME const& ft); // Members private: epoch_type m_kernelStart; epoch_type m_kernelEnd; epoch_type m_userStart; epoch_type m_userEnd; HANDLE m_thread; }; //////////////////////////////////////////////////////////////////////////// // Unit-testing #ifdef STLSOFT_UNITTEST # include "./unittest/threadtimes_counter_unittest_.h" #endif /* STLSOFT_UNITTEST */ //////////////////////////////////////////////////////////////////////////// // Implementation #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION inline /* static */ threadtimes_counter::epoch_type threadtimes_counter::convert_(FILETIME const& ft) { epoch_type r = ft.dwHighDateTime; r <<= 32; r += ft.dwLowDateTime; return r; } inline threadtimes_counter::threadtimes_counter() : m_thread(::GetCurrentThread()) { // Note that the constructor does nothing, for performance reasons. Calling // any of the Attribute methods before having gone through a start()-stop() // cycle will yield undefined results. } // Operations inline void threadtimes_counter::start() { FILETIME creationTime; FILETIME exitTime; FILETIME kernelTime; FILETIME userTime; if(!::GetThreadTimes(m_thread, &creationTime, &exitTime, &kernelTime, &userTime)) { m_kernelStart = 0; m_userStart = 0; #ifdef STLSOFT_CF_EXCEPTION_SUPPORT ; // TODO: throw #endif /* STLSOFT_CF_EXCEPTION_SUPPORT */ } else { m_kernelStart = convert_(kernelTime); m_userStart = convert_(userTime); } } inline void threadtimes_counter::stop() { FILETIME creationTime; FILETIME exitTime; FILETIME kernelTime; FILETIME userTime; if(!::GetThreadTimes(m_thread, &creationTime, &exitTime, &kernelTime, &userTime)) { m_kernelEnd = 0; m_userEnd = 0; #ifdef STLSOFT_CF_EXCEPTION_SUPPORT ; // TODO: throw #endif /* STLSOFT_CF_EXCEPTION_SUPPORT */ } else { m_kernelEnd = convert_(kernelTime); m_userEnd = convert_(userTime); } } // Attributes // Kernel inline threadtimes_counter::interval_type threadtimes_counter::get_kernel_period_count() const { return static_cast<interval_type>(m_kernelEnd - m_kernelStart); } inline threadtimes_counter::interval_type threadtimes_counter::get_kernel_seconds() const { return get_kernel_period_count() / interval_type(10000000); } inline threadtimes_counter::interval_type threadtimes_counter::get_kernel_milliseconds() const { return get_kernel_period_count() / interval_type(10000); } inline threadtimes_counter::interval_type threadtimes_counter::get_kernel_microseconds() const { return get_kernel_period_count() / interval_type(10); } // User inline threadtimes_counter::interval_type threadtimes_counter::get_user_period_count() const { return static_cast<interval_type>(m_userEnd - m_userStart); } inline threadtimes_counter::interval_type threadtimes_counter::get_user_seconds() const { return get_user_period_count() / interval_type(10000000); } inline threadtimes_counter::interval_type threadtimes_counter::get_user_milliseconds() const { return get_user_period_count() / interval_type(10000); } inline threadtimes_counter::interval_type threadtimes_counter::get_user_microseconds() const { return get_user_period_count() / interval_type(10); } // Total inline threadtimes_counter::interval_type threadtimes_counter::get_period_count() const { return get_kernel_period_count() + get_user_period_count(); } inline threadtimes_counter::interval_type threadtimes_counter::get_seconds() const { return get_period_count() / interval_type(10000000); } inline threadtimes_counter::interval_type threadtimes_counter::get_milliseconds() const { return get_period_count() / interval_type(10000); } inline threadtimes_counter::interval_type threadtimes_counter::get_microseconds() const { return get_period_count() / interval_type(10); } #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* ////////////////////////////////////////////////////////////////////// */ #ifndef _WINSTL_NO_NAMESPACE # if defined(_STLSOFT_NO_NAMESPACE) || \ defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) } // namespace winstl # else } // namespace winstl_project } // namespace stlsoft # endif /* _STLSOFT_NO_NAMESPACE */ #endif /* !_WINSTL_NO_NAMESPACE */ /* ////////////////////////////////////////////////////////////////////// */ #endif /* !WINSTL_INCL_WINSTL_PERFORMANCE_HPP_THREADTIMES_COUNTER */ /* ///////////////////////////// end of file //////////////////////////// */
35.027174
119
0.675795
betasheet
0f0163418e986baae0109e0fc5fe9b675895bd69
6,055
cpp
C++
level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp
kcencele/compute-runtime
bec8cdd6f1392bf0549e3b9340b4926b6e84f89a
[ "Intel", "MIT" ]
null
null
null
level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp
kcencele/compute-runtime
bec8cdd6f1392bf0549e3b9340b4926b6e84f89a
[ "Intel", "MIT" ]
null
null
null
level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp
kcencele/compute-runtime
bec8cdd6f1392bf0549e3b9340b4926b6e84f89a
[ "Intel", "MIT" ]
null
null
null
/* * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "level_zero/tools/source/sysman/pci/linux/os_pci_imp.h" #include "level_zero/tools/source/sysman/linux/fs_access.h" #include "level_zero/tools/source/sysman/sysman_const.h" #include "sysman/pci/pci_imp.h" namespace L0 { const std::string LinuxPciImp::deviceDir("device"); const std::string LinuxPciImp::resourceFile("device/resource"); const std::string LinuxPciImp::maxLinkSpeedFile("device/max_link_speed"); const std::string LinuxPciImp::maxLinkWidthFile("device/max_link_width"); ze_result_t LinuxPciImp::getProperties(zes_pci_properties_t *properties) { properties->haveBandwidthCounters = false; properties->havePacketCounters = false; properties->haveReplayCounters = false; return ZE_RESULT_SUCCESS; } ze_result_t LinuxPciImp::getPciBdf(std::string &bdf) { std::string bdfDir; ze_result_t result = pSysfsAccess->readSymLink(deviceDir, bdfDir); if (ZE_RESULT_SUCCESS != result) { return result; } const auto loc = bdfDir.find_last_of('/'); bdf = bdfDir.substr(loc + 1); return ZE_RESULT_SUCCESS; } ze_result_t LinuxPciImp::getMaxLinkSpeed(double &maxLinkSpeed) { ze_result_t result; if (isLmemSupported) { std::string rootPortPath; std::string realRootPath; result = pSysfsAccess->getRealPath(deviceDir, realRootPath); if (ZE_RESULT_SUCCESS != result) { maxLinkSpeed = 0; return result; } // we need to get actual values of speed and width at the Discrete card's root port. rootPortPath = pLinuxSysmanImp->getPciRootPortDirectoryPath(realRootPath); result = pfsAccess->read(rootPortPath + '/' + "max_link_speed", maxLinkSpeed); if (ZE_RESULT_SUCCESS != result) { maxLinkSpeed = 0; return result; } } else { result = pSysfsAccess->read(maxLinkSpeedFile, maxLinkSpeed); if (ZE_RESULT_SUCCESS != result) { maxLinkSpeed = 0; return result; } } return ZE_RESULT_SUCCESS; } ze_result_t LinuxPciImp::getMaxLinkWidth(int32_t &maxLinkwidth) { ze_result_t result; if (isLmemSupported) { std::string rootPortPath; std::string realRootPath; result = pSysfsAccess->getRealPath(deviceDir, realRootPath); if (ZE_RESULT_SUCCESS != result) { maxLinkwidth = -1; return result; } // we need to get actual values of speed and width at the Discrete card's root port. rootPortPath = pLinuxSysmanImp->getPciRootPortDirectoryPath(realRootPath); result = pfsAccess->read(rootPortPath + '/' + "max_link_width", maxLinkwidth); if (ZE_RESULT_SUCCESS != result) { maxLinkwidth = -1; return result; } if (maxLinkwidth == static_cast<int32_t>(unknownPcieLinkWidth)) { maxLinkwidth = -1; } } else { result = pSysfsAccess->read(maxLinkWidthFile, maxLinkwidth); if (ZE_RESULT_SUCCESS != result) { return result; } if (maxLinkwidth == static_cast<int32_t>(unknownPcieLinkWidth)) { maxLinkwidth = -1; } } return ZE_RESULT_SUCCESS; } void getBarBaseAndSize(std::string readBytes, uint64_t &baseAddr, uint64_t &barSize, uint64_t &barFlags) { unsigned long long start, end, flags; std::stringstream sStreamReadBytes; sStreamReadBytes << readBytes; sStreamReadBytes >> std::hex >> start; sStreamReadBytes >> end; sStreamReadBytes >> flags; flags &= 0xf; barFlags = flags; baseAddr = start; barSize = end - start + 1; } ze_result_t LinuxPciImp::initializeBarProperties(std::vector<zes_pci_bar_properties_t *> &pBarProperties) { std::vector<std::string> ReadBytes; ze_result_t result = pSysfsAccess->read(resourceFile, ReadBytes); if (result != ZE_RESULT_SUCCESS) { return result; } for (uint32_t i = 0; i <= maxPciBars; i++) { uint64_t baseAddr, barSize, barFlags; getBarBaseAndSize(ReadBytes[i], baseAddr, barSize, barFlags); if (baseAddr && !(barFlags & 0x1)) { // we do not update for I/O ports zes_pci_bar_properties_t *pBarProp = new zes_pci_bar_properties_t; memset(pBarProp, 0, sizeof(zes_pci_bar_properties_t)); pBarProp->index = i; pBarProp->base = baseAddr; pBarProp->size = barSize; // Bar Flags Desc. // Bit-0 - Value 0x0 -> MMIO type BAR // Bit-0 - Value 0x1 -> I/O type BAR if (i == 0) { // GRaphics MMIO is at BAR0, and is a 64-bit pBarProp->type = ZES_PCI_BAR_TYPE_MMIO; } if (i == 2) { pBarProp->type = ZES_PCI_BAR_TYPE_MEM; // device memory is always at BAR2 } if (i == 6) { // the 7th entry of resource file is expected to be ROM BAR pBarProp->type = ZES_PCI_BAR_TYPE_ROM; } pBarProperties.push_back(pBarProp); } } if (pBarProperties.size() == 0) { result = ZE_RESULT_ERROR_UNKNOWN; } return result; } bool LinuxPciImp::resizableBarSupported() { return false; } bool LinuxPciImp::resizableBarEnabled() { return false; } ze_result_t LinuxPciImp::getState(zes_pci_state_t *state) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } LinuxPciImp::LinuxPciImp(OsSysman *pOsSysman) { pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman); pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess(); pfsAccess = &pLinuxSysmanImp->getFsAccess(); Device *pDevice = pLinuxSysmanImp->getDeviceHandle(); isLmemSupported = pDevice->getDriverHandle()->getMemoryManager()->isLocalMemorySupported(pDevice->getRootDeviceIndex()); } OsPci *OsPci::create(OsSysman *pOsSysman) { LinuxPciImp *pLinuxPciImp = new LinuxPciImp(pOsSysman); return static_cast<OsPci *>(pLinuxPciImp); } } // namespace L0
34.016854
124
0.653014
kcencele
0f016646f07582e9224ef4ba3d786e57bd6392df
948
hpp
C++
server/homeserver/scripting/Scriptable.hpp
williamkoehler/home-server
ce99af73ea2e53fea3939fe0c4442433e65ac670
[ "MIT" ]
1
2021-07-05T21:11:59.000Z
2021-07-05T21:11:59.000Z
server/homeserver/scripting/Scriptable.hpp
williamkoehler/home-server
ce99af73ea2e53fea3939fe0c4442433e65ac670
[ "MIT" ]
null
null
null
server/homeserver/scripting/Scriptable.hpp
williamkoehler/home-server
ce99af73ea2e53fea3939fe0c4442433e65ac670
[ "MIT" ]
null
null
null
#pragma once #include "../common.hpp" #include <utils/Property.hpp> #include <utils/Timer.hpp> #include <utils/Event.hpp> namespace server { class Scriptable { public: virtual bool AddAttribute(const std::string& id, const char* json) = 0; virtual bool RemoveAttribute(const std::string& id) = 0; virtual void ClearAttributes() = 0; virtual Ref<home::Property> AddProperty(const std::string& id, home::PropertyType type) = 0; virtual bool RemoveProperty(const std::string& id) = 0; virtual void ClearProperties() = 0; virtual Ref<home::Event> AddEvent(const std::string& id, const std::string& callback) = 0; virtual bool RemoveEvent(const std::string& id) = 0; virtual void ClearEvents() = 0; virtual Ref<home::Timer> AddTimer(const std::string& id, const std::string& callback) = 0; virtual bool RemoveTimer(const std::string& id) = 0; virtual void ClearTimers() = 0; }; }
33.857143
94
0.67827
williamkoehler
0f02842b81f70087aee1e30f8076ec66927bf50b
945
cpp
C++
Engine/source/shaderGen/shaderDependency.cpp
fr1tz/alux3d
249a3b51751ce3184d52879b481f83eabe89e7e3
[ "MIT" ]
46
2015-01-05T17:34:43.000Z
2022-01-04T04:03:09.000Z
Engine/source/shaderGen/shaderDependency.cpp
fr1tz/alux3d
249a3b51751ce3184d52879b481f83eabe89e7e3
[ "MIT" ]
10
2015-01-20T23:14:46.000Z
2019-04-05T22:04:15.000Z
Engine/source/shaderGen/shaderDependency.cpp
fr1tz/terminal-overload
85f0689a40022e5eb7e54dcb6ddfb5ddd82a0a60
[ "CC-BY-4.0" ]
9
2015-08-08T18:46:06.000Z
2021-02-01T13:53:20.000Z
// Copyright information can be found in the file named COPYING // located in the root directory of this distribution. #include "platform/platform.h" #include "shaderGen/shaderDependency.h" #include "core/stream/fileStream.h" #include "core/frameAllocator.h" ShaderIncludeDependency::ShaderIncludeDependency( const Torque::Path &pathToInclude ) : mIncludePath( pathToInclude ) { } bool ShaderIncludeDependency::operator==( const ShaderDependency &cmpTo ) const { return this == &cmpTo || ( dynamic_cast<const ShaderIncludeDependency*>( &cmpTo ) && static_cast<const ShaderIncludeDependency*>( &cmpTo )->mIncludePath == mIncludePath ); } void ShaderIncludeDependency::print( Stream &s ) const { // Print the include... all shaders support #includes. String include = String::ToString( "#include \"%s\"\r\n", mIncludePath.getFullPath().c_str() ); s.write( include.length(), include.c_str() ); }
32.586207
101
0.71746
fr1tz
0f045eb3ae7e51c8eee5033f23351532814e124e
1,241
cpp
C++
src/test/json/big_list_of_naughty_strings.cpp
ClausKlein/json
eeabe4bdef13ccba985b4423ce558438fd2f5497
[ "BSD-3-Clause", "Apache-2.0", "MIT" ]
null
null
null
src/test/json/big_list_of_naughty_strings.cpp
ClausKlein/json
eeabe4bdef13ccba985b4423ce558438fd2f5497
[ "BSD-3-Clause", "Apache-2.0", "MIT" ]
null
null
null
src/test/json/big_list_of_naughty_strings.cpp
ClausKlein/json
eeabe4bdef13ccba985b4423ce558438fd2f5497
[ "BSD-3-Clause", "Apache-2.0", "MIT" ]
null
null
null
// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/json/ #include "test.hpp" #include <tao/json/from_file.hpp> #include <tao/json/from_string.hpp> #include <tao/json/to_string.hpp> #include <tao/json/value.hpp> #include <fstream> #include <string> [[nodiscard]] std::string get_file_contents( const char* filename ) { std::ifstream in( filename, std::ios::in | std::ios::binary ); if( !in.fail() ) { std::string contents; in.seekg( 0, std::ios::end ); contents.resize( static_cast< std::string::size_type >( in.tellg() ) ); in.seekg( 0, std::ios::beg ); in.read( &contents[ 0 ], contents.size() ); in.close(); return contents; } throw std::runtime_error( "unable to read input file" ); } namespace tao::json { void unit_test() { const auto v = from_file( "tests/blns.json" ); TEST_ASSERT( v.get_array().size() == 494 ); const auto s = to_string( v, 2 ) + '\n'; #if !defined( _WIN32 ) TEST_ASSERT( s == get_file_contents( "tests/blns.json" ) ); #endif const auto v2 = from_string( s ); TEST_ASSERT( v2 == v ); } } // namespace tao::json #include "main.hpp"
26.978261
77
0.625302
ClausKlein
0f0691bada8b570f7902e6bda627484f343b120b
749
cpp
C++
src/util/noise.cpp
ArneDJ/terranova
533e9e5687d464153418f73a1d811f57e7c572b9
[ "CC0-1.0" ]
null
null
null
src/util/noise.cpp
ArneDJ/terranova
533e9e5687d464153418f73a1d811f57e7c572b9
[ "CC0-1.0" ]
null
null
null
src/util/noise.cpp
ArneDJ/terranova
533e9e5687d464153418f73a1d811f57e7c572b9
[ "CC0-1.0" ]
null
null
null
#include "../extern/fastnoise/FastNoise.h" #include "image.h" #include "noise.h" namespace util { void noise_image(Image<float> &image, FastNoise *fastnoise, const glm::vec2 &sample_freq, uint8_t channel) { const int nsteps = 32; const int stepsize = image.width() / nsteps; #pragma omp parallel for for (int step_x = 0; step_x < image.width(); step_x += stepsize) { int w = step_x + stepsize; int h = image.height(); for (int i = 0; i < h; i++) { for (int j = step_x; j < w; j++) { float x = sample_freq.x * j; float y = sample_freq.y * i; fastnoise->GradientPerturbFractal(x, y); float value = 0.5f * (fastnoise->GetNoise(x, y) + 1.f); image.plot(j, i, channel, glm::clamp(value, 0.f, 1.f)); } } } } };
24.966667
106
0.623498
ArneDJ
0f07ec79e97c75b954de15d912455bf2c3850df7
586
cpp
C++
client/include/game/CTaskComplexLeaveCar.cpp
MayconFelipeA/sampvoiceatt
3fae8a2cf37dfad2e3925d56aebfbbcd4162b0ff
[ "MIT" ]
368
2015-01-01T21:42:00.000Z
2022-03-29T06:22:22.000Z
client/include/game/CTaskComplexLeaveCar.cpp
MayconFelipeA/sampvoiceatt
3fae8a2cf37dfad2e3925d56aebfbbcd4162b0ff
[ "MIT" ]
92
2019-01-23T23:02:31.000Z
2022-03-23T19:59:40.000Z
client/include/game/CTaskComplexLeaveCar.cpp
MayconFelipeA/sampvoiceatt
3fae8a2cf37dfad2e3925d56aebfbbcd4162b0ff
[ "MIT" ]
179
2015-02-03T23:41:17.000Z
2022-03-26T08:27:16.000Z
/* Plugin-SDK (Grand Theft Auto San Andreas) source file Authors: GTA Community. See more here https://github.com/DK22Pac/plugin-sdk Do not delete this comment block. Respect others' work! */ #include "CTaskComplexLeaveCar.h" CTaskComplexLeaveCar::CTaskComplexLeaveCar(CVehicle* pTargetVehicle, int nTargetDoor, int nDelayTime, bool bSensibleLeaveCar, bool bForceGetOut) : CTaskComplex(plugin::dummy) { plugin::CallMethod<0x63B8C0, CTaskComplexLeaveCar*, CVehicle*, int, int, bool, bool> (this, pTargetVehicle, nTargetDoor, nDelayTime, bSensibleLeaveCar, bForceGetOut); }
39.066667
174
0.78157
MayconFelipeA
0f08c5ae6fe4323ed96133a0fb109da4445346a3
8,701
cpp
C++
Source/OceanCS/CSFFT/fft_512x512_c2c.cpp
ytt747536970/ocean
1bd27aae62294229c8b8b07058a94b7d60723b1b
[ "MIT" ]
null
null
null
Source/OceanCS/CSFFT/fft_512x512_c2c.cpp
ytt747536970/ocean
1bd27aae62294229c8b8b07058a94b7d60723b1b
[ "MIT" ]
null
null
null
Source/OceanCS/CSFFT/fft_512x512_c2c.cpp
ytt747536970/ocean
1bd27aae62294229c8b8b07058a94b7d60723b1b
[ "MIT" ]
null
null
null
// Copyright (c) 2011 NVIDIA Corporation. All rights reserved. // // TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED // *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA // OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT, OR // CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS // OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY // OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, // EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. // // Please direct any bugs or questions to SDKFeedback@nvidia.com #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "fft_512x512.h" HRESULT CompileShaderFromFile( WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut ); void radix008A(CSFFT512x512_Plan* fft_plan, ID3D11UnorderedAccessView* pUAV_Dst, ID3D11ShaderResourceView* pSRV_Src, UINT thread_count, UINT istride) { // Setup execution configuration UINT grid = thread_count / COHERENCY_GRANULARITY; ID3D11DeviceContext* pd3dImmediateContext = fft_plan->pd3dImmediateContext; // Buffers ID3D11ShaderResourceView* cs_srvs[1] = {pSRV_Src}; pd3dImmediateContext->CSSetShaderResources(0, 1, cs_srvs); ID3D11UnorderedAccessView* cs_uavs[1] = {pUAV_Dst}; pd3dImmediateContext->CSSetUnorderedAccessViews(0, 1, cs_uavs, (UINT*)(&cs_uavs[0])); // Shader if (istride > 1) pd3dImmediateContext->CSSetShader(fft_plan->pRadix008A_CS, NULL, 0); else pd3dImmediateContext->CSSetShader(fft_plan->pRadix008A_CS2, NULL, 0); // Execute pd3dImmediateContext->Dispatch(grid, 1, 1); // Unbind resource cs_srvs[0] = NULL; pd3dImmediateContext->CSSetShaderResources(0, 1, cs_srvs); cs_uavs[0] = NULL; pd3dImmediateContext->CSSetUnorderedAccessViews(0, 1, cs_uavs, (UINT*)(&cs_uavs[0])); } void fft_512x512_c2c(CSFFT512x512_Plan* fft_plan, ID3D11UnorderedAccessView* pUAV_Dst, ID3D11ShaderResourceView* pSRV_Dst, ID3D11ShaderResourceView* pSRV_Src) { const UINT thread_count = fft_plan->slices * (512 * 512) / 8; ID3D11UnorderedAccessView* pUAV_Tmp = fft_plan->pUAV_Tmp; ID3D11ShaderResourceView* pSRV_Tmp = fft_plan->pSRV_Tmp; ID3D11DeviceContext* pd3dContext = fft_plan->pd3dImmediateContext; ID3D11Buffer* cs_cbs[1]; UINT istride = 512 * 512 / 8; cs_cbs[0] = fft_plan->pRadix008A_CB[0]; pd3dContext->CSSetConstantBuffers(0, 1, &cs_cbs[0]); radix008A(fft_plan, pUAV_Tmp, pSRV_Src, thread_count, istride); istride /= 8; cs_cbs[0] = fft_plan->pRadix008A_CB[1]; pd3dContext->CSSetConstantBuffers(0, 1, &cs_cbs[0]); radix008A(fft_plan, pUAV_Dst, pSRV_Tmp, thread_count, istride); istride /= 8; cs_cbs[0] = fft_plan->pRadix008A_CB[2]; pd3dContext->CSSetConstantBuffers(0, 1, &cs_cbs[0]); radix008A(fft_plan, pUAV_Tmp, pSRV_Dst, thread_count, istride); istride /= 8; cs_cbs[0] = fft_plan->pRadix008A_CB[3]; pd3dContext->CSSetConstantBuffers(0, 1, &cs_cbs[0]); radix008A(fft_plan, pUAV_Dst, pSRV_Tmp, thread_count, istride); istride /= 8; cs_cbs[0] = fft_plan->pRadix008A_CB[4]; pd3dContext->CSSetConstantBuffers(0, 1, &cs_cbs[0]); radix008A(fft_plan, pUAV_Tmp, pSRV_Dst, thread_count, istride); istride /= 8; cs_cbs[0] = fft_plan->pRadix008A_CB[5]; pd3dContext->CSSetConstantBuffers(0, 1, &cs_cbs[0]); radix008A(fft_plan, pUAV_Dst, pSRV_Tmp, thread_count, istride); } void create_cbuffers_512x512(CSFFT512x512_Plan* plan, ID3D11Device* pd3dDevice, UINT slices) { // Create 6 cbuffers for 512x512 transform. D3D11_BUFFER_DESC cb_desc; cb_desc.Usage = D3D11_USAGE_IMMUTABLE; cb_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; cb_desc.CPUAccessFlags = 0; cb_desc.MiscFlags = 0; cb_desc.ByteWidth = 32;//sizeof(float) * 5; cb_desc.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA cb_data; cb_data.SysMemPitch = 0; cb_data.SysMemSlicePitch = 0; struct CB_Structure { UINT thread_count; UINT ostride; UINT istride; UINT pstride; float phase_base; }; // Buffer 0 const UINT thread_count = slices * (512 * 512) / 8; UINT ostride = 512 * 512 / 8; UINT istride = ostride; double phase_base = -TWO_PI / (512.0 * 512.0); CB_Structure cb_data_buf0 = {thread_count, ostride, istride, 512, (float)phase_base}; cb_data.pSysMem = &cb_data_buf0; pd3dDevice->CreateBuffer(&cb_desc, &cb_data, &plan->pRadix008A_CB[0]); assert(plan->pRadix008A_CB[0]); // Buffer 1 istride /= 8; phase_base *= 8.0; CB_Structure cb_data_buf1 = {thread_count, ostride, istride, 512, (float)phase_base}; cb_data.pSysMem = &cb_data_buf1; pd3dDevice->CreateBuffer(&cb_desc, &cb_data, &plan->pRadix008A_CB[1]); assert(plan->pRadix008A_CB[1]); // Buffer 2 istride /= 8; phase_base *= 8.0; CB_Structure cb_data_buf2 = {thread_count, ostride, istride, 512, (float)phase_base}; cb_data.pSysMem = &cb_data_buf2; pd3dDevice->CreateBuffer(&cb_desc, &cb_data, &plan->pRadix008A_CB[2]); assert(plan->pRadix008A_CB[2]); // Buffer 3 istride /= 8; phase_base *= 8.0; ostride /= 512; CB_Structure cb_data_buf3 = {thread_count, ostride, istride, 1, (float)phase_base}; cb_data.pSysMem = &cb_data_buf3; pd3dDevice->CreateBuffer(&cb_desc, &cb_data, &plan->pRadix008A_CB[3]); assert(plan->pRadix008A_CB[3]); // Buffer 4 istride /= 8; phase_base *= 8.0; CB_Structure cb_data_buf4 = {thread_count, ostride, istride, 1, (float)phase_base}; cb_data.pSysMem = &cb_data_buf4; pd3dDevice->CreateBuffer(&cb_desc, &cb_data, &plan->pRadix008A_CB[4]); assert(plan->pRadix008A_CB[4]); // Buffer 5 istride /= 8; phase_base *= 8.0; CB_Structure cb_data_buf5 = {thread_count, ostride, istride, 1, (float)phase_base}; cb_data.pSysMem = &cb_data_buf5; pd3dDevice->CreateBuffer(&cb_desc, &cb_data, &plan->pRadix008A_CB[5]); assert(plan->pRadix008A_CB[5]); } void fft512x512_create_plan(CSFFT512x512_Plan* plan, ID3D11Device* pd3dDevice, UINT slices) { plan->slices = slices; // Context pd3dDevice->GetImmediateContext(&plan->pd3dImmediateContext); assert(plan->pd3dImmediateContext); // Compute shaders ID3DBlob* pBlobCS = NULL; ID3DBlob* pBlobCS2 = NULL; CompileShaderFromFile(L"CSFFT\\fft_512x512_c2c.hlsl", "Radix008A_CS", "cs_4_0", &pBlobCS); CompileShaderFromFile(L"CSFFT\\fft_512x512_c2c.hlsl", "Radix008A_CS2", "cs_4_0", &pBlobCS2); assert(pBlobCS); assert(pBlobCS2); pd3dDevice->CreateComputeShader(pBlobCS->GetBufferPointer(), pBlobCS->GetBufferSize(), NULL, &plan->pRadix008A_CS); pd3dDevice->CreateComputeShader(pBlobCS2->GetBufferPointer(), pBlobCS2->GetBufferSize(), NULL, &plan->pRadix008A_CS2); assert(plan->pRadix008A_CS); assert(plan->pRadix008A_CS2); SAFE_RELEASE(pBlobCS); SAFE_RELEASE(pBlobCS2); // Constants // Create 6 cbuffers for 512x512 transform create_cbuffers_512x512(plan, pd3dDevice, slices); // Temp buffer D3D11_BUFFER_DESC buf_desc; buf_desc.ByteWidth = sizeof(float) * 2 * (512 * slices) * 512; buf_desc.Usage = D3D11_USAGE_DEFAULT; buf_desc.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE; buf_desc.CPUAccessFlags = 0; buf_desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; buf_desc.StructureByteStride = sizeof(float) * 2; pd3dDevice->CreateBuffer(&buf_desc, NULL, &plan->pBuffer_Tmp); assert(plan->pBuffer_Tmp); // Temp undordered access view D3D11_UNORDERED_ACCESS_VIEW_DESC uav_desc; uav_desc.Format = DXGI_FORMAT_UNKNOWN; uav_desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; uav_desc.Buffer.FirstElement = 0; uav_desc.Buffer.NumElements = (512 * slices) * 512; uav_desc.Buffer.Flags = 0; pd3dDevice->CreateUnorderedAccessView(plan->pBuffer_Tmp, &uav_desc, &plan->pUAV_Tmp); assert(plan->pUAV_Tmp); // Temp shader resource view D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc; srv_desc.Format = DXGI_FORMAT_UNKNOWN; srv_desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; srv_desc.Buffer.FirstElement = 0; srv_desc.Buffer.NumElements = (512 * slices) * 512; pd3dDevice->CreateShaderResourceView(plan->pBuffer_Tmp, &srv_desc, &plan->pSRV_Tmp); assert(plan->pSRV_Tmp); } void fft512x512_destroy_plan(CSFFT512x512_Plan* plan) { SAFE_RELEASE(plan->pSRV_Tmp); SAFE_RELEASE(plan->pUAV_Tmp); SAFE_RELEASE(plan->pBuffer_Tmp); SAFE_RELEASE(plan->pRadix008A_CS); SAFE_RELEASE(plan->pRadix008A_CS2); SAFE_RELEASE(plan->pd3dImmediateContext); for (int i = 0; i < 6; i++) SAFE_RELEASE(plan->pRadix008A_CB[i]); }
32.958333
122
0.748765
ytt747536970
0f0cbbacc6522724d921f7ac2982bf39918e8c85
504
hpp
C++
Server/participant.hpp
Whiskarek/UDPChat
c7b5b34a1028a39c3b66a6154285688e05b2a3a9
[ "Apache-2.0" ]
1
2021-04-15T11:31:39.000Z
2021-04-15T11:31:39.000Z
Server/participant.hpp
AndrewShkrob/UDPChat
c7b5b34a1028a39c3b66a6154285688e05b2a3a9
[ "Apache-2.0" ]
null
null
null
Server/participant.hpp
AndrewShkrob/UDPChat
c7b5b34a1028a39c3b66a6154285688e05b2a3a9
[ "Apache-2.0" ]
null
null
null
#ifndef SERVER_PARTICIPANT_HPP #define SERVER_PARTICIPANT_HPP #include <memory> #include "chat_message.hpp" class Participant { public: Participant(std::string username) : _username(std::move(username)) {} virtual ~Participant() {} virtual void deliver(const ChatMessage &msg) = 0; std::string get_username() const { return _username; } private: const std::string _username; }; typedef std::shared_ptr<Participant> participant_ptr; #endif //SERVER_PARTICIPANT_HPP
19.384615
73
0.724206
Whiskarek
0f1114891df4246096544ed101e3dee4a012dc0f
1,862
cc
C++
src/connector/native/window.cc
andyshand/bitwig-enhancement-suite
914bf362444becac6a471faa431c3be735122e36
[ "MIT" ]
12
2020-10-20T13:37:33.000Z
2021-02-17T21:06:08.000Z
src/connector/native/window.cc
andyshand/modwig
914bf362444becac6a471faa431c3be735122e36
[ "MIT" ]
28
2020-10-06T19:04:03.000Z
2022-03-25T19:12:14.000Z
src/connector/native/window.cc
andyshand/bitwig-enhancement-suite
914bf362444becac6a471faa431c3be735122e36
[ "MIT" ]
null
null
null
#include "point.h" #include "window.h" #include "rect.h" #include <CoreGraphics/CoreGraphics.h> #include <napi.h> #include <iostream> #include <string> #include "string.h" Napi::Value GetMainScreen(const Napi::CallbackInfo &info) { Napi::Env env = info.Env(); auto mainDisplayId = CGMainDisplayID(); CGFloat screenWidth = CGDisplayPixelsWide(mainDisplayId); CGFloat screenHeight = CGDisplayPixelsHigh(mainDisplayId); auto obj = Napi::Object::New(env); obj.Set(Napi::String::New(env, "w"), Napi::Number::New(env, screenWidth)); obj.Set(Napi::String::New(env, "h"), Napi::Number::New(env, screenHeight)); return obj; } Napi::Value ClosePluginWindows(const Napi::CallbackInfo &info) { Napi::Env env = info.Env(); // Go through all on screen windows, find BW, get its frame CFArrayRef array = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID); CFIndex count = CFArrayGetCount(array); for (CFIndex i = 0; i < count; i++) { CFDictionaryRef dict = (CFDictionaryRef)CFArrayGetValueAtIndex(array, i); auto str = CFStringToString((CFStringRef)CFDictionaryGetValue(dict, kCGWindowOwnerName)); auto windowName = CFStringToString((CFStringRef)CFDictionaryGetValue(dict, kCGWindowName)); if (str == "Bitwig Studio") { std::cout << "window name: " << windowName << std::endl; } } CFRelease(array); return env.Null(); } Napi::Value InitWindow(Napi::Env env, Napi::Object exports) { Napi::Object obj = Napi::Object::New(env); obj.Set(Napi::String::New(env, "getMainScreen"), Napi::Function::New(env, GetMainScreen)); obj.Set(Napi::String::New(env, "closePluginWindows"), Napi::Function::New(env, ClosePluginWindows)); exports.Set("MainWindow", obj); return exports; }
38
138
0.691729
andyshand
0f12aeeb61c100b731a89caba2295b7d73be1daa
3,280
cpp
C++
src/libtsduck/dtv/codec/tsHEVCAccessUnitDelimiter.cpp
ethouris/tsduck
a1963c55c22086a9227a7530718fc5b3e8a69873
[ "BSD-2-Clause" ]
1
2019-04-23T21:16:00.000Z
2019-04-23T21:16:00.000Z
src/libtsduck/dtv/codec/tsHEVCAccessUnitDelimiter.cpp
ethouris/tsduck
a1963c55c22086a9227a7530718fc5b3e8a69873
[ "BSD-2-Clause" ]
null
null
null
src/libtsduck/dtv/codec/tsHEVCAccessUnitDelimiter.cpp
ethouris/tsduck
a1963c55c22086a9227a7530718fc5b3e8a69873
[ "BSD-2-Clause" ]
null
null
null
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2021, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- #include "tsHEVCAccessUnitDelimiter.h" #include "tsHEVC.h" TSDUCK_SOURCE; //---------------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------------- ts::HEVCAccessUnitDelimiter::HEVCAccessUnitDelimiter(const uint8_t* data, size_t size) : SuperClass(), pic_type(0) { parse(data, size); } //---------------------------------------------------------------------------- // Clear all values //---------------------------------------------------------------------------- void ts::HEVCAccessUnitDelimiter::clear() { SuperClass::clear(); pic_type = 0; } //---------------------------------------------------------------------------- // Parse the body of the binary access unit. Return the "valid" flag. //---------------------------------------------------------------------------- bool ts::HEVCAccessUnitDelimiter::parseBody(AVCParser& parser, std::initializer_list<uint32_t>) { return nal_unit_type == HEVC_AUT_AUD_NUT && parser.u(pic_type, 3); } //---------------------------------------------------------------------------- // Display structure content //---------------------------------------------------------------------------- std::ostream& ts::HEVCAccessUnitDelimiter::display(std::ostream& out, const UString& margin) const { #define DISP(n) disp(out, margin, u ## #n, n) if (valid) { DISP(forbidden_zero_bit); DISP(nal_unit_type); DISP(nuh_layer_id); DISP(nuh_temporal_id_plus1); DISP(pic_type); DISP(rbsp_trailing_bits_valid); DISP(rbsp_trailing_bits_count); } return out; #undef DISP }
36.853933
98
0.557317
ethouris
0f137a3dd45a8d4196586c4b2039b8a74d55408d
2,402
hpp
C++
nexxT/src/Services.hpp
pfrydlewicz/nexxT
33616dbeee448c59201aa3009d637fe6b8d2b39c
[ "Apache-2.0" ]
5
2020-05-03T10:52:14.000Z
2022-03-02T10:32:33.000Z
nexxT/src/Services.hpp
pfrydlewicz/nexxT
33616dbeee448c59201aa3009d637fe6b8d2b39c
[ "Apache-2.0" ]
32
2020-05-18T15:49:00.000Z
2022-02-22T20:10:56.000Z
nexxT/src/Services.hpp
pfrydlewicz/nexxT
33616dbeee448c59201aa3009d637fe6b8d2b39c
[ "Apache-2.0" ]
2
2020-03-21T15:04:46.000Z
2021-03-01T15:42:49.000Z
/* * SPDX-License-Identifier: Apache-2.0 * Copyright (C) 2020 ifm electronic gmbh * * THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. */ /** \file Services.hpp The interface corresponding to \verbatim embed:rst :py:mod:`nexxT.interface.Services \endverbatim */ #ifndef NEXXT_SERVICES_HPP #define NEXXT_SERVICES_HPP #include <QtCore/QObject> #include <QtCore/QSharedPointer> #include "NexxTLinkage.hpp" namespace nexxT { struct ServicesD; /*! A typedef for a QObject handled by a shared pointer. In principle it is not really necessary to use a shared pointer to handle QObjects, because of the parent/child ownership principle. However for consistency, the design decision has been made to also wrap the services in a smart pointer just like datasamples, filters and ports. */ typedef QSharedPointer<QObject> SharedQObjectPtr; /*! This class is the C++ variant of \verbatim embed:rst:inline :py:class:`nexxT.interface.Services.Services` \endverbatim */ class DLLEXPORT Services { ServicesD *d; static Services *_singleton; SharedQObjectPtr _getService(const QString &name); void _addService(const QString &name, const SharedQObjectPtr &service); void _removeService(const QString &name); void _removeAll(); static Services *singleton(); public: /*! Constructor (intended to be used by the nexxT framework only) */ Services(); /*! Destructor */ virtual ~Services(); /*! See \verbatim embed:rst:inline :py:meth:`nexxT.interface.Services.Services.getService` \endverbatim */ static SharedQObjectPtr getService(const QString &name); /*! See \verbatim embed:rst:inline :py:meth:`nexxT.interface.Services.Services.addService` \endverbatim */ static void addService(const QString &name, QObject *service); /*! See \verbatim embed:rst:inline :py:meth:`nexxT.interface.Services.Services.removeService` \endverbatim */ static void removeService(const QString &name); /*! See \verbatim embed:rst:inline :py:meth:`nexxT.interface.Services.Services.removeAll` \endverbatim */ static void removeAll(); }; }; #endif
30.025
119
0.652373
pfrydlewicz
0f159463ad01cfd4420b9df75be7f521f7be5b73
4,008
hpp
C++
src/split_strand_graph.hpp
lnceballosz/vg
82d8ba2f38299525c0b0a6b19dcb785d2c439cfa
[ "MIT" ]
null
null
null
src/split_strand_graph.hpp
lnceballosz/vg
82d8ba2f38299525c0b0a6b19dcb785d2c439cfa
[ "MIT" ]
null
null
null
src/split_strand_graph.hpp
lnceballosz/vg
82d8ba2f38299525c0b0a6b19dcb785d2c439cfa
[ "MIT" ]
null
null
null
// SPDX-FileCopyrightText: 2014 Erik Garrison // // SPDX-License-Identifier: MIT #ifndef VG_SPLIT_STRAND_GRAPH_HPP_INCLUDED #define VG_SPLIT_STRAND_GRAPH_HPP_INCLUDED /** \file * split_strand_graph.hpp: defines a handle graph overlay that duplicates nodes * and edges so that both the forward and reverse strand of the underlying graph * are now on the forward strand */ #include "handle.hpp" #include "utility.hpp" namespace vg { using namespace std; /** * A HandleGraph implementation that overlays some other handle graph and splits * the two strands of its nodes into separate nodes */ class StrandSplitGraph : public ExpandingOverlayGraph { public: /// Initialize as the reverse version of another graph, optionally also /// complementing StrandSplitGraph(const HandleGraph* graph); /// Default constructor -- not actually functional StrandSplitGraph() = default; /// Default destructor ~StrandSplitGraph() = default; ////////////////////////// /// HandleGraph interface ////////////////////////// // Method to check if a node exists by ID bool has_node(id_t node_id) const; /// Look up the handle for the node with the given ID in the given orientation handle_t get_handle(const id_t& node_id, bool is_reverse = false) const; /// Get the ID from a handle id_t get_id(const handle_t& handle) const; /// Get the orientation of a handle bool get_is_reverse(const handle_t& handle) const; /// Invert the orientation of a handle (potentially without getting its ID) handle_t flip(const handle_t& handle) const; /// Get the length of a node size_t get_length(const handle_t& handle) const; /// Get the sequence of a node, presented in the handle's local forward /// orientation. string get_sequence(const handle_t& handle) const; /// Loop over all the handles to next/previous (right/left) nodes. Passes /// them to a callback which returns false to stop iterating and true to /// continue. Returns true if we finished and false if we stopped early. bool follow_edges_impl(const handle_t& handle, bool go_left, const function<bool(const handle_t&)>& iteratee) const; /// Loop over all the nodes in the graph in their local forward /// orientations, in their internal stored order. Stop if the iteratee /// returns false. Can be told to run in parallel, in which case stopping /// after a false return value is on a best-effort basis and iteration /// order is not defined. bool for_each_handle_impl(const function<bool(const handle_t&)>& iteratee, bool parallel = false) const; /// Return the number of nodes in the graph size_t get_node_count() const; /// Return the smallest ID in the graph, or some smaller number if the /// smallest ID is unavailable. Return value is unspecified if the graph is empty. id_t min_node_id() const; /// Return the largest ID in the graph, or some larger number if the /// largest ID is unavailable. Return value is unspecified if the graph is empty. id_t max_node_id() const; /////////////////////////////////// /// ExpandingOverlayGraph interface /////////////////////////////////// /** * Returns the handle in the underlying graph that corresponds to a handle in the * overlay */ handle_t get_underlying_handle(const handle_t& handle) const; private: /// The underlying graph we're making splitting const HandleGraph* graph = nullptr; }; } #endif
37.811321
94
0.609032
lnceballosz
0f15d2decb8d3148129fcd200d0dbe58c916ada8
5,625
cpp
C++
tutorial/test_async_memory_layout.cpp
tearshark/librf
4299e2ff264aac9bcd9e4788e528de80044252c8
[ "Apache-2.0" ]
434
2017-09-24T06:41:06.000Z
2022-03-29T10:24:14.000Z
tutorial/test_async_memory_layout.cpp
tearshark/librf
4299e2ff264aac9bcd9e4788e528de80044252c8
[ "Apache-2.0" ]
7
2017-12-06T13:08:33.000Z
2021-12-01T07:46:12.000Z
tutorial/test_async_memory_layout.cpp
tearshark/librf
4299e2ff264aac9bcd9e4788e528de80044252c8
[ "Apache-2.0" ]
95
2017-09-24T06:14:04.000Z
2022-03-22T06:23:14.000Z
#include <chrono> #include <iostream> #include <string> #include <thread> #include "librf.h" using namespace resumef; #ifndef __GNUC__ //GCC: 没有提供__builtin_coro_frame这样的内置函数 template<class _Ctype> static void callback_get_long(int64_t a, int64_t b, _Ctype&& cb) { std::cout << std::endl << __FUNCTION__ << " - begin" << std::endl; //编译失败。因为这个函数不是"可恢复函数(resumeable function)",甚至都不是"可等待函数(awaitable function)" //void* frame_ptr = _coro_frame_ptr(); using namespace std::chrono; std::thread([=, cb = std::forward<_Ctype>(cb)] { std::this_thread::sleep_for(500ms); cb(a + b); }).detach(); std::cout << __FUNCTION__ << " - end" << std::endl; } //这种情况下,没有生成 frame-context,因此,并没有promise_type被内嵌在frame-context里 future_t<int64_t> awaitable_get_long(int64_t a, int64_t b) { std::cout << std::endl << __FUNCTION__ << " - begin" << std::endl; //编译失败。因为这个函数不是"可恢复函数(resumeable function)",仅仅是"可等待函数(awaitable function)" //void* frame_ptr = _coro_frame_ptr(); resumef::awaitable_t<int64_t> awaitable; callback_get_long(a, b, [awaitable](int64_t val) { awaitable.set_value(val); }); std::cout << __FUNCTION__ << " - end" << std::endl; return awaitable.get_future(); } future_t<int64_t> resumeable_get_long(int64_t x, int64_t y) { std::cout << std::endl << __FUNCTION__ << " - begin" << std::endl; using future_type = future_t<int64_t>; using promise_type = typename future_type::promise_type; using state_type = typename future_type::state_type; void* frame_ptr = _coro_frame_ptr(); auto handler = coroutine_handle<promise_type>::from_address(frame_ptr); promise_type* promise = &handler.promise(); state_type* state = handler.promise().get_state(); std::cout << " future size=" << sizeof(future_type) << " / " << _Align_size<future_type>() << std::endl; std::cout << " promise size=" << sizeof(promise_type) << " / " << _Align_size<promise_type>() << std::endl; std::cout << " state size=" << sizeof(state_type) << " / "<< _Align_size<state_type>() << std::endl; std::cout << " frame size=" << _coro_frame_size() << ", alloc size=" << state->get_alloc_size() << std::endl; std::cout << " frame ptr=" << frame_ptr << "," << (void*)&frame_ptr << std::endl; std::cout << " frame end=" << (void*)((char*)(frame_ptr)+_coro_frame_size()) << std::endl; std::cout << " promise ptr=" << promise << "," << (void*)&promise << std::endl; std::cout << " handle ptr=" << handler.address() << "," << (void*)&handler << std::endl; std::cout << " state ptr=" << state << "," << (void*)&state << std::endl; std::cout << " parent ptr=" << state->get_parent() << std::endl; std::cout << " x=" << x << ", &x=" << std::addressof(x) << std::endl; std::cout << " y=" << y << ", &y=" << std::addressof(y) << std::endl; int64_t val = co_await awaitable_get_long(x, y); std::cout << " val=" << val << ", &val=" << std::addressof(val) << std::endl; std::cout << __FUNCTION__ << " - end" << std::endl; co_return val; } //这种情况下,会生成对应的 frame-context,一个promise_type被内嵌在frame-context里 future_t<> resumable_get_long_2(int64_t a, int64_t b, int64_t c) { int64_t v1, v2, v3; std::cout << std::endl << __FUNCTION__ << " - begin" << std::endl; using future_type = future_t<>; using promise_type = typename future_type::promise_type; using state_type = typename future_type::state_type; void* frame_ptr = _coro_frame_ptr(); auto handler = coroutine_handle<promise_type>::from_address(frame_ptr); promise_type * promise = &handler.promise(); state_type * state = handler.promise().get_state(); std::cout << " future size=" << sizeof(future_type) << " / " << _Align_size<future_type>() << std::endl; std::cout << " promise size=" << sizeof(promise_type) << " / " << _Align_size<promise_type>() << std::endl; std::cout << " state size=" << sizeof(state_type) << " / "<< _Align_size<state_type>() << std::endl; std::cout << " frame size=" << _coro_frame_size() << ", alloc size=" << state->get_alloc_size() << std::endl; std::cout << " frame ptr=" << frame_ptr << ","<< (void*)&frame_ptr << std::endl; std::cout << " frame end=" << (void *)((char*)(frame_ptr) + _coro_frame_size()) << std::endl; std::cout << " promise ptr=" << promise << "," << (void *)&promise << std::endl; std::cout << " handle ptr=" << handler.address() << "," << (void*)&handler << std::endl; std::cout << " state ptr=" << state << "," << (void*)&state << std::endl; std::cout << " parent ptr=" << state->get_parent() << std::endl; std::cout << " a=" << a << ", &a=" << std::addressof(a) << std::endl; std::cout << " b=" << b << ", &b=" << std::addressof(b) << std::endl; std::cout << " c=" << c << ", &c=" << std::addressof(c) << std::endl; v1 = co_await resumeable_get_long(a, b); std::cout << " v1=" << v1 << ", &v1=" << std::addressof(v1) << std::endl; v2 = co_await resumeable_get_long(b, c); std::cout << " v2=" << v2 << ", &v2=" << std::addressof(v2) << std::endl; v3 = co_await resumeable_get_long(v1, v2); std::cout << " v3=" << v3 << ", &v3=" << std::addressof(v3) << std::endl; int64_t v4 = v1 * v2 * v3; std::cout << " v4=" << v4 << ", &v4=" << std::addressof(v4) << std::endl; std::cout << __FUNCTION__ << " - end" << std::endl; } #endif //#ifndef __GNUC__ void resumable_main_layout() { std::cout << std::endl << __FUNCTION__ << " - begin" << std::endl; #ifndef __GNUC__ //GCC: 没有提供__builtin_coro_frame这样的内置函数 go resumable_get_long_2(1, 2, 5); #endif //#ifndef __GNUC__ resumef::this_scheduler()->run_until_notask(); std::cout << __FUNCTION__ << " - end" << std::endl; } int main() { resumable_main_layout(); return 0; }
37.751678
111
0.619911
tearshark
0f17d10a59bb17880ee6879713a1ef0cefe9f7fd
2,132
cpp
C++
src/shared/data/settings.cpp
snowmeltarcade/projectbirdracing
55cd479c81979de535b0cf496e91dd8d48b99fa8
[ "MIT" ]
null
null
null
src/shared/data/settings.cpp
snowmeltarcade/projectbirdracing
55cd479c81979de535b0cf496e91dd8d48b99fa8
[ "MIT" ]
3
2021-11-13T02:18:59.000Z
2021-12-04T18:16:01.000Z
src/shared/data/settings.cpp
snowmeltarcade/projectbirdracing
55cd479c81979de535b0cf496e91dd8d48b99fa8
[ "MIT" ]
null
null
null
#include "settings.h" #include "shared/utils/strings.h" namespace pbr::shared::data { std::optional<std::string> settings::get(const std::string& key) noexcept { auto it = this->_map.find(key); if (it == this->_map.end()) { return {}; } return this->_map[key]; } std::optional<int> settings::get_as_int(const std::string& key) noexcept { auto it = this->_map.find(key); if (it == this->_map.end()) { return {}; } if (auto i = utils::to_int(this->_map[key]); i) { return i; } return {}; } std::optional<uint32_t> settings::get_as_uint32_t(const std::string& key) noexcept { if (auto i = this->get_as_int(key); i) { return static_cast<uint32_t>(*i); } return {}; } std::optional<float> settings::get_as_float(const std::string& key) noexcept { auto it = this->_map.find(key); if (it == this->_map.end()) { return {}; } if (auto i = utils::to_float(this->_map[key]); i) { return i; } return {}; } std::optional<bool> settings::get_as_bool(const std::string& key) noexcept { auto it = this->_map.find(key); if (it == this->_map.end()) { return {}; } auto value = this->_map[key]; // we're being strict with these values if (value == "true") { return true; } else if (value == "false") { return false; } return {}; } std::optional<settings> settings::get_as_settings(const std::string& key) noexcept { auto it = this->_settings_map.find(key); if (it == this->_settings_map.end()) { return {}; } return this->_settings_map[key]; } std::optional<std::vector<settings>> settings::get_as_settings_array(const std::string& key) noexcept { auto it = this->_array.find(key); if (it == this->_array.end()) { return {}; } return this->_array[key]; } }
25.380952
107
0.515009
snowmeltarcade
0f1e07e1f1601881011c03e5da4c7c024b97f363
4,351
cpp
C++
src/qt/src/corelib/animation/qpauseanimation.cpp
martende/phantomjs
5cecd7dde7b8fd04ad2c036d16f09a8d2a139854
[ "BSD-3-Clause" ]
1
2015-03-16T20:49:09.000Z
2015-03-16T20:49:09.000Z
src/qt/src/corelib/animation/qpauseanimation.cpp
firedfox/phantomjs
afb0707c9db7b5e693ad1b216a50081565c08ebb
[ "BSD-3-Clause" ]
null
null
null
src/qt/src/corelib/animation/qpauseanimation.cpp
firedfox/phantomjs
afb0707c9db7b5e693ad1b216a50081565c08ebb
[ "BSD-3-Clause" ]
null
null
null
/**************************************************************************** ** ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage ** This file may be used under the terms of the GNU Lesser General Public ** License version 2.1 as published by the Free Software Foundation and ** appearing in the file LICENSE.LGPL included in the packaging of this ** file. Please review the following information to ensure the GNU Lesser ** General Public License version 2.1 requirements will be met: ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU General ** Public License version 3.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of this ** file. Please review the following information to ensure the GNU General ** Public License version 3.0 requirements will be met: ** http://www.gnu.org/copyleft/gpl.html. ** ** Other Usage ** Alternatively, this file may be used in accordance with the terms and ** conditions contained in a signed written agreement between you and Nokia. ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ /*! \class QPauseAnimation \brief The QPauseAnimation class provides a pause for QSequentialAnimationGroup. \since 4.6 \ingroup animation If you wish to introduce a delay between animations in a QSequentialAnimationGroup, you can insert a QPauseAnimation. This class does not animate anything, but does not \l{QAbstractAnimation::finished()}{finish} before a specified number of milliseconds have elapsed from when it was started. You specify the duration of the pause in the constructor. It can also be set directly with setDuration(). It is not necessary to construct a QPauseAnimation yourself. QSequentialAnimationGroup provides the convenience functions \l{QSequentialAnimationGroup::}{addPause()} and \l{QSequentialAnimationGroup::}{insertPause()}. These functions simply take the number of milliseconds the pause should last. \sa QSequentialAnimationGroup */ #include "qpauseanimation.h" #include "qabstractanimation_p.h" #ifndef QT_NO_ANIMATION QT_BEGIN_NAMESPACE class QPauseAnimationPrivate : public QAbstractAnimationPrivate { public: QPauseAnimationPrivate() : QAbstractAnimationPrivate(), duration(250) { isPause = true; } int duration; }; /*! Constructs a QPauseAnimation. \a parent is passed to QObject's constructor. The default duration is 0. */ QPauseAnimation::QPauseAnimation(QObject *parent) : QAbstractAnimation(*new QPauseAnimationPrivate, parent) { } /*! Constructs a QPauseAnimation. \a msecs is the duration of the pause. \a parent is passed to QObject's constructor. */ QPauseAnimation::QPauseAnimation(int msecs, QObject *parent) : QAbstractAnimation(*new QPauseAnimationPrivate, parent) { setDuration(msecs); } /*! Destroys the pause animation. */ QPauseAnimation::~QPauseAnimation() { } /*! \property QPauseAnimation::duration \brief the duration of the pause. The duration of the pause. The duration should not be negative. The default duration is 250 milliseconds. */ int QPauseAnimation::duration() const { Q_D(const QPauseAnimation); return d->duration; } void QPauseAnimation::setDuration(int msecs) { if (msecs < 0) { qWarning("QPauseAnimation::setDuration: cannot set a negative duration"); return; } Q_D(QPauseAnimation); d->duration = msecs; } /*! \reimp */ bool QPauseAnimation::event(QEvent *e) { return QAbstractAnimation::event(e); } /*! \reimp */ void QPauseAnimation::updateCurrentTime(int) { } QT_END_NAMESPACE #include "moc_qpauseanimation.cpp" #endif //QT_NO_ANIMATION
27.891026
118
0.709262
martende
0f1f0460beb53978edc7a32feda7567bfbbf1e9f
1,955
cpp
C++
aws-cpp-sdk-wellarchitected/source/model/ListLensReviewImprovementsResult.cpp
perfectrecall/aws-sdk-cpp
fb8cbebf2fd62720b65aeff841ad2950e73d8ebd
[ "Apache-2.0" ]
1
2022-02-10T08:06:54.000Z
2022-02-10T08:06:54.000Z
aws-cpp-sdk-wellarchitected/source/model/ListLensReviewImprovementsResult.cpp
perfectrecall/aws-sdk-cpp
fb8cbebf2fd62720b65aeff841ad2950e73d8ebd
[ "Apache-2.0" ]
1
2021-10-14T16:57:00.000Z
2021-10-18T10:47:24.000Z
aws-cpp-sdk-wellarchitected/source/model/ListLensReviewImprovementsResult.cpp
ravindra-wagh/aws-sdk-cpp
7d5ff01b3c3b872f31ca98fb4ce868cd01e97696
[ "Apache-2.0" ]
1
2021-11-09T11:58:03.000Z
2021-11-09T11:58:03.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/wellarchitected/model/ListLensReviewImprovementsResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::WellArchitected::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; ListLensReviewImprovementsResult::ListLensReviewImprovementsResult() : m_milestoneNumber(0) { } ListLensReviewImprovementsResult::ListLensReviewImprovementsResult(const Aws::AmazonWebServiceResult<JsonValue>& result) : m_milestoneNumber(0) { *this = result; } ListLensReviewImprovementsResult& ListLensReviewImprovementsResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("WorkloadId")) { m_workloadId = jsonValue.GetString("WorkloadId"); } if(jsonValue.ValueExists("MilestoneNumber")) { m_milestoneNumber = jsonValue.GetInteger("MilestoneNumber"); } if(jsonValue.ValueExists("LensAlias")) { m_lensAlias = jsonValue.GetString("LensAlias"); } if(jsonValue.ValueExists("LensArn")) { m_lensArn = jsonValue.GetString("LensArn"); } if(jsonValue.ValueExists("ImprovementSummaries")) { Array<JsonView> improvementSummariesJsonList = jsonValue.GetArray("ImprovementSummaries"); for(unsigned improvementSummariesIndex = 0; improvementSummariesIndex < improvementSummariesJsonList.GetLength(); ++improvementSummariesIndex) { m_improvementSummaries.push_back(improvementSummariesJsonList[improvementSummariesIndex].AsObject()); } } if(jsonValue.ValueExists("NextToken")) { m_nextToken = jsonValue.GetString("NextToken"); } return *this; }
25.723684
146
0.759079
perfectrecall
0f1f3f75ea02c1daa2f765b06c2e26545b533f58
5,604
cpp
C++
src/tests/DispatcherTest/DispatcherTest.cpp
ADDubovik/StateReportable
07132939e5ce5b38037e611c6dc5231566294b79
[ "MIT" ]
1
2022-02-13T11:42:50.000Z
2022-02-13T11:42:50.000Z
src/tests/DispatcherTest/DispatcherTest.cpp
ADDubovik/StateReportable
07132939e5ce5b38037e611c6dc5231566294b79
[ "MIT" ]
null
null
null
src/tests/DispatcherTest/DispatcherTest.cpp
ADDubovik/StateReportable
07132939e5ce5b38037e611c6dc5231566294b79
[ "MIT" ]
null
null
null
#include <gtest/gtest.h> #include "core/Dispatcher.h" #include "core/ReportLine.h" #include "core/DispatcherImplementation.h" #include "core/VectorHelpers.h" #include <vector> #include <algorithm> #include <array> using namespace StateReportable; struct TestDestination { using Data = core::ReportLine; using Storage = std::vector<Data>; using StorageWithMutex = std::pair<std::mutex, Storage>; StorageWithMutex storageWithMutex; void send(Data &&line) { std::lock_guard<std::mutex> guard(storageWithMutex.first); VectorHelpers::doubleCapacityIfNeeded(storageWithMutex.second); storageWithMutex.second.emplace_back(std::move(line)); } }; namespace { void instantiateTemplateFunctions() { core::Dispatcher<TestDestination>::instanceWeak(); } } // namespace namespace StateReportable::core { template<typename Destination_t> class DispatcherTestClass { public: using Dispatcher = core::Dispatcher<TestDestination>; static TestDestination& getTestDestination() { return Dispatcher::instanceWeak().lock()->m_destination; }; }; } // namespace StateReportable::core std::string getStringRandom() { static std::array<unsigned char, 16> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'}; auto chars = 1 + (rand() & 0xf); std::string result; for ( auto i = 0; i < chars; ++i ) result += alphabet[rand() & 0xf]; return result; } core::ReportLine getReportLineRandom() { return {getStringRandom(), getStringRandom(), getStringRandom(), rand() & 0xff}; } TEST(DispatcherTest, Test_01) { TestDestination::Storage expected = {getReportLineRandom()}; auto &globalStorage = core::DispatcherTestClass<TestDestination>::getTestDestination().storageWithMutex; if ( auto strong = core::Dispatcher<TestDestination>::instanceWeak().lock() ) strong->send(core::ReportLine(*expected.cbegin())); else EXPECT_TRUE(false); while (true) { { std::lock_guard<std::mutex> guard(globalStorage.first); if ( globalStorage.second.size() == expected.size() ) break; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); } std::lock_guard<std::mutex> guard(globalStorage.first); EXPECT_EQ(expected, globalStorage.second); globalStorage.second.clear(); } TEST(DispatcherTest, Test_02) { const auto lines = 10'000; TestDestination::Storage expected; auto &globalStorage = core::DispatcherTestClass<TestDestination>::getTestDestination().storageWithMutex; for ( auto i = 0; i < lines; ++i ) { VectorHelpers::doubleCapacityIfNeeded(expected); expected.emplace_back(getReportLineRandom()); } if ( auto strong = core::Dispatcher<TestDestination>::instanceWeak().lock() ) for ( auto const &elem : expected ) strong->send(core::ReportLine(elem)); else EXPECT_TRUE(false); while (true) { { std::lock_guard<std::mutex> guard(globalStorage.first); if ( globalStorage.second.size() == expected.size() ) break; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); } std::lock_guard<std::mutex> guard(globalStorage.first); EXPECT_EQ(expected.size(), globalStorage.second.size()); std::sort(expected.begin(), expected.end()); std::sort(globalStorage.second.begin(), globalStorage.second.end()); EXPECT_EQ(expected, globalStorage.second); globalStorage.second.clear(); } void sendSome(TestDestination::Storage::const_iterator begin, TestDestination::Storage::const_iterator end) { if ( auto strong = core::Dispatcher<TestDestination>::instanceWeak().lock() ) for ( auto iter = begin; iter != end; ++iter ) { strong->send(core::ReportLine(*iter)); std::this_thread::yield(); } else EXPECT_TRUE(false); } void test(size_t reportBySingleThread, size_t reporterThreads) { TestDestination::Storage expected; auto &globalStorage = core::DispatcherTestClass<TestDestination>::getTestDestination().storageWithMutex; for ( size_t i = 0u; i < reportBySingleThread * reporterThreads; ++i ) { VectorHelpers::doubleCapacityIfNeeded(expected); expected.emplace_back(getReportLineRandom()); } { std::vector<std::future<void>> reporters; reporters.reserve(reporterThreads); for ( size_t i = 0; i < reporterThreads; ++i ) reporters.emplace_back(std::async( std::launch::async, sendSome, expected.cbegin() + i * reportBySingleThread, expected.cbegin() + (i + 1) * reportBySingleThread )); } // <--- waiting for all reporters to finish while (true) { { std::lock_guard<std::mutex> guard(globalStorage.first); if ( globalStorage.second.size() == expected.size() ) break; } std::this_thread::sleep_for(std::chrono::milliseconds(1)); } std::lock_guard<std::mutex> guard(globalStorage.first); EXPECT_EQ(expected.size(), globalStorage.second.size()); std::sort(expected.begin(), expected.end()); std::sort(globalStorage.second.begin(), globalStorage.second.end()); EXPECT_EQ(expected, globalStorage.second); globalStorage.second.clear(); } TEST(DispatcherTest, Test_03) { test(2'500, 4); } TEST(DispatcherTest, HeavyLoadTest) { srand(static_cast<unsigned int>(time(nullptr))); const auto repetitions = 100; for ( auto rep = 0; rep < repetitions; ++rep ) { const size_t reportBySingleThread = 100 + 100 * (rand() & 0xf); const size_t reporterThreads = 1 + rand() & 0xf; test(reportBySingleThread, reporterThreads); } } #include "main.h"
25.017857
107
0.680585
ADDubovik
0f1f86bc14907e305c772afcc328455974073934
8,325
cpp
C++
Game/Client/CEGUI/CEGUI/WidgetSets/Falagard/src/FalEditbox.cpp
hackerlank/SourceCode
b702c9e0a9ca5d86933f3c827abb02a18ffc9a59
[ "MIT" ]
4
2021-07-31T13:56:01.000Z
2021-11-13T02:55:10.000Z
Game/Client/CEGUI/CEGUI/WidgetSets/Falagard/src/FalEditbox.cpp
shacojx/SourceCodeGameTLBB
e3cea615b06761c2098a05427a5f41c236b71bf7
[ "MIT" ]
null
null
null
Game/Client/CEGUI/CEGUI/WidgetSets/Falagard/src/FalEditbox.cpp
shacojx/SourceCodeGameTLBB
e3cea615b06761c2098a05427a5f41c236b71bf7
[ "MIT" ]
7
2021-08-31T14:34:23.000Z
2022-01-19T08:25:58.000Z
/************************************************************************ filename: FalEditbox.cpp created: Sat Jun 25 2005 author: Paul D Turner <paul@cegui.org.uk> *************************************************************************/ /************************************************************************* Crazy Eddie's GUI System (http://www.cegui.org.uk) Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *************************************************************************/ #include "FalEditbox.h" #include "falagard/CEGUIFalWidgetLookManager.h" #include "falagard/CEGUIFalWidgetLookFeel.h" // Start of CEGUI namespace section namespace CEGUI { const utf8 FalagardEditbox::WidgetTypeName[] = "Falagard/Editbox"; FalagardEditbox::FalagardEditbox(const String& type, const String& name) : Editbox(type, name), d_lastTextOffset(0) { } FalagardEditbox::~FalagardEditbox() { } void FalagardEditbox::populateRenderCache() { const StateImagery* imagery; // draw container etc // get WidgetLookFeel for the assigned look. const WidgetLookFeel& wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName); // try and get imagery for the approprite state. imagery = &wlf.getStateImagery(isDisabled() ? "Disabled" : (isReadOnly() ? "ReadOnly" : "Enabled")); // peform the rendering operation for the container. imagery->render(*this); // get destination area for text const Rect textArea(wlf.getNamedArea("TextArea").getArea().getPixelRect(*this)); // // Required preliminary work for text rendering operations // const FontBase* font = getFont(); // no font == no more rendering if (!font) return; // This will point to the final string to be used for rendering. Useful because it means we // do not have to have duplicate code or be copying d_text for handling masked/unmasked text. String* editText; // Create a 'masked' version of the string if needed. String maskedText; if (isTextMasked()) { maskedText.insert(0, d_text.length(), getMaskCodePoint()); editText = &maskedText; } // text not masked to editText will be the windows d_text String. else { editText = &d_text; } // calculate best position to render text to ensure carat is always visible float textOffset; float extentToCarat = font->getTextExtent(editText->substr(0, getCaratIndex())); // get carat imagery const ImagerySection& caratImagery = wlf.getImagerySection("Carat"); // store carat width float caratWidth = caratImagery.getBoundingRect(*this, textArea).getWidth(); // if box is inactive if (!hasInputFocus()) { textOffset = d_lastTextOffset; } // if carat is to the left of the box else if ((d_lastTextOffset + extentToCarat) < 0) { textOffset = -extentToCarat; } // if carat is off to the right. else if ((d_lastTextOffset + extentToCarat) >= (textArea.getWidth() - caratWidth)) { textOffset = textArea.getWidth() - extentToCarat - caratWidth; } // else carat is already within the box else { textOffset = d_lastTextOffset; } ColourRect colours; float alpha_comp = getEffectiveAlpha(); // // Draw label text // // setup initial rect for text formatting Rect text_part_rect(textArea); // allow for scroll position text_part_rect.d_left += textOffset; // centre text vertically within the defined text area text_part_rect.d_top += (textArea.getHeight() - font->getLineSpacing()) * 0.5f; // draw pre-highlight text String sect = editText->substr(0, getSelectionStartIndex()); colours.setColours(d_normalTextColour); colours.modulateAlpha(alpha_comp); d_renderCache.cacheText(this, sect, font, LeftAligned, text_part_rect, 0, colours, &textArea); // adjust rect for next section text_part_rect.d_left += font->getTextExtent(sect); // draw highlight text sect = editText->substr(getSelectionStartIndex(), getSelectionLength()); colours.setColours(d_selectTextColour); colours.modulateAlpha(alpha_comp); d_renderCache.cacheText(this, sect, font, LeftAligned, text_part_rect, 0, colours, &textArea); // adjust rect for next section text_part_rect.d_left += font->getTextExtent(sect); // draw post-highlight text sect = editText->substr(getSelectionEndIndex()); colours.setColours(d_normalTextColour); colours.modulateAlpha(alpha_comp); d_renderCache.cacheText(this, sect, font, LeftAligned, text_part_rect, 0, colours, &textArea); // remember this for next time. d_lastTextOffset = textOffset; // see if the editbox is active or inactive. bool active = (!isReadOnly()) && hasInputFocus(); // // Render selection imagery. // if (getSelectionLength() != 0) { // calculate required start and end offsets of selection imagery. float selStartOffset = font->getTextExtent(editText->substr(0, getSelectionStartIndex())); float selEndOffset = font->getTextExtent(editText->substr(0, getSelectionEndIndex())); // calculate area for selection imagery. Rect hlarea(textArea); hlarea.d_left += textOffset + selStartOffset; hlarea.d_right = hlarea.d_left + (selEndOffset - selStartOffset); // render the selection imagery. wlf.getStateImagery(active ? "ActiveSelection" : "InactiveSelection").render(*this, hlarea, 0, &textArea); } // // Render carat // if (active) { Rect caratRect(textArea); caratRect.d_left += extentToCarat + textOffset; caratImagery.render(*this, caratRect, 0, 0, &textArea); } } size_t FalagardEditbox::getTextIndexFromPosition(const Point& pt) const { // // calculate final window position to be checked // float wndx = screenToWindowX(pt.d_x); if (getMetricsMode() == Relative) { wndx = relativeToAbsoluteX(wndx); } wndx -= d_lastTextOffset; // // Return the proper index // if (isTextMasked()) { return getFont()->getCharAtPixel(String(d_text.length(), getMaskCodePoint()), wndx); } else { return getFont()->getCharAtPixel(d_text, wndx); } } ////////////////////////////////////////////////////////////////////////// /************************************************************************* Factory Methods *************************************************************************/ ////////////////////////////////////////////////////////////////////////// Window* FalagardEditboxFactory::createWindow(const String& name) { return new FalagardEditbox(d_type, name); } void FalagardEditboxFactory::destroyWindow(Window* window) { delete window; } } // End of CEGUI namespace section
35.729614
118
0.578979
hackerlank
0f2129d3c5cf137aa56d9fda33d3e43d490ab804
7,603
cpp
C++
part2/main.cpp
enjalot/adventures_in_opencl
c222d15c076ee3f5f81b529eb47e87c8d8057096
[ "MIT" ]
152
2015-01-04T00:58:08.000Z
2022-02-02T00:11:58.000Z
part2/main.cpp
ahmadm-atallah/adventures_in_opencl
c222d15c076ee3f5f81b529eb47e87c8d8057096
[ "MIT" ]
1
2017-09-21T13:36:15.000Z
2017-09-21T13:36:15.000Z
part2/main.cpp
ahmadm-atallah/adventures_in_opencl
c222d15c076ee3f5f81b529eb47e87c8d8057096
[ "MIT" ]
71
2015-02-11T17:12:09.000Z
2021-12-06T14:05:28.000Z
/* * Adventures in OpenCL tutorial series * Part 2 * * author: Ian Johnson * htt://enja.org * code based on advisor Gordon Erlebacher's work * NVIDIA's examples * as well as various blogs and resources on the internet */ #include <stdio.h> #include <stdlib.h> #include <sstream> #include <iomanip> #include <math.h> //OpenGL stuff #include <GL/glew.h> #if defined __APPLE__ || defined(MACOSX) #include <GLUT/glut.h> #else #include <GL/glut.h> #endif //Our OpenCL Particle Systemclass #include "cll.h" #define NUM_PARTICLES 20000 CL* example; //GL related variables int window_width = 800; int window_height = 600; int glutWindowHandle = 0; float translate_z = -1.f; // mouse controls int mouse_old_x, mouse_old_y; int mouse_buttons = 0; float rotate_x = 0.0, rotate_y = 0.0; //main app helper functions void init_gl(int argc, char** argv); void appRender(); void appDestroy(); void timerCB(int ms); void appKeyboard(unsigned char key, int x, int y); void appMouse(int button, int state, int x, int y); void appMotion(int x, int y); //---------------------------------------------------------------------- //quick random function to distribute our initial points float rand_float(float mn, float mx) { float r = random() / (float) RAND_MAX; return mn + (mx-mn)*r; } //---------------------------------------------------------------------- int main(int argc, char** argv) { printf("Hello, OpenCL\n"); //Setup our GLUT window and OpenGL related things //glut callback functions are setup here too init_gl(argc, argv); //initialize our CL object, this sets up the context example = new CL(); //load and build our CL program from the file #include "part2.cl" //std::string kernel_source is defined in this file example->loadProgram(kernel_source); //initialize our particle system with positions, velocities and color int num = NUM_PARTICLES; std::vector<Vec4> pos(num); std::vector<Vec4> vel(num); std::vector<Vec4> color(num); //fill our vectors with initial data for(int i = 0; i < num; i++) { //distribute the particles in a random circle around z axis float rad = rand_float(.2, .5); float x = rad*sin(2*3.14 * i/num); float z = 0.0f;// -.1 + .2f * i/num; float y = rad*cos(2*3.14 * i/num); pos[i] = Vec4(x, y, z, 1.0f); //give some initial velocity //float xr = rand_float(-.1, .1); //float yr = rand_float(1.f, 3.f); //the life is the lifetime of the particle: 1 = alive 0 = dead //as you will see in part2.cl we reset the particle when it dies float life_r = rand_float(0.f, 1.f); vel[i] = Vec4(0.0, 0.0, 3.0f, life_r); //just make them red and full alpha color[i] = Vec4(1.0f, 0.0f,0.0f, 1.0f); } //our load data function sends our initial values to the GPU example->loadData(pos, vel, color); //initialize the kernel example->popCorn(); //this starts the GLUT program, from here on out everything we want //to do needs to be done in glut callback functions glutMainLoop(); } //---------------------------------------------------------------------- void appRender() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //this updates the particle system by calling the kernel example->runKernel(); //render the particles from VBOs glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_POINT_SMOOTH); glPointSize(5.); //printf("color buffer\n"); glBindBuffer(GL_ARRAY_BUFFER, example->c_vbo); glColorPointer(4, GL_FLOAT, 0, 0); //printf("vertex buffer\n"); glBindBuffer(GL_ARRAY_BUFFER, example->p_vbo); glVertexPointer(4, GL_FLOAT, 0, 0); //printf("enable client state\n"); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); //Need to disable these for blender glDisableClientState(GL_NORMAL_ARRAY); //printf("draw arrays\n"); glDrawArrays(GL_POINTS, 0, example->num); //printf("disable stuff\n"); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glutSwapBuffers(); } //---------------------------------------------------------------------- void init_gl(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(window_width, window_height); glutInitWindowPosition (glutGet(GLUT_SCREEN_WIDTH)/2 - window_width/2, glutGet(GLUT_SCREEN_HEIGHT)/2 - window_height/2); std::stringstream ss; ss << "Adventures in OpenCL: Part 2, " << NUM_PARTICLES << " particles" << std::ends; glutWindowHandle = glutCreateWindow(ss.str().c_str()); glutDisplayFunc(appRender); //main rendering function glutTimerFunc(30, timerCB, 30); //determin a minimum time between frames glutKeyboardFunc(appKeyboard); glutMouseFunc(appMouse); glutMotionFunc(appMotion); glewInit(); glClearColor(0.0, 0.0, 0.0, 1.0); glDisable(GL_DEPTH_TEST); // viewport glViewport(0, 0, window_width, window_height); // projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90.0, (GLfloat)window_width / (GLfloat) window_height, 0.1, 1000.0); // set view matrix glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0, 0.0, translate_z); } //---------------------------------------------------------------------- void appDestroy() { //this makes sure we properly cleanup our OpenCL context delete example; if(glutWindowHandle)glutDestroyWindow(glutWindowHandle); printf("about to exit!\n"); exit(0); } //---------------------------------------------------------------------- void timerCB(int ms) { //this makes sure the appRender function is called every ms miliseconds glutTimerFunc(ms, timerCB, ms); glutPostRedisplay(); } //---------------------------------------------------------------------- void appKeyboard(unsigned char key, int x, int y) { //this way we can exit the program cleanly switch(key) { case '\033': // escape quits case '\015': // Enter quits case 'Q': // Q quits case 'q': // q (or escape) quits // Cleanup up and quit appDestroy(); break; } } //---------------------------------------------------------------------- void appMouse(int button, int state, int x, int y) { //handle mouse interaction for rotating/zooming the view if (state == GLUT_DOWN) { mouse_buttons |= 1<<button; } else if (state == GLUT_UP) { mouse_buttons = 0; } mouse_old_x = x; mouse_old_y = y; } //---------------------------------------------------------------------- void appMotion(int x, int y) { //hanlde the mouse motion for zooming and rotating the view float dx, dy; dx = x - mouse_old_x; dy = y - mouse_old_y; if (mouse_buttons & 1) { rotate_x += dy * 0.2; rotate_y += dx * 0.2; } else if (mouse_buttons & 4) { translate_z += dy * 0.1; } mouse_old_x = x; mouse_old_y = y; // set view matrix glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0, 0.0, translate_z); glRotatef(rotate_x, 1.0, 0.0, 0.0); glRotatef(rotate_y, 0.0, 1.0, 0.0); }
27.250896
89
0.592661
enjalot
0f225de35f273e6db5774e0e24ece82455e242cd
926
cpp
C++
Game/Scorpio/src/PhysicsSimulation/PS_MovableCollider.cpp
hackerlank/SourceCode
b702c9e0a9ca5d86933f3c827abb02a18ffc9a59
[ "MIT" ]
4
2021-07-31T13:56:01.000Z
2021-11-13T02:55:10.000Z
Game/Scorpio/src/PhysicsSimulation/PS_MovableCollider.cpp
shacojx/SourceCodeGameTLBB
e3cea615b06761c2098a05427a5f41c236b71bf7
[ "MIT" ]
null
null
null
Game/Scorpio/src/PhysicsSimulation/PS_MovableCollider.cpp
shacojx/SourceCodeGameTLBB
e3cea615b06761c2098a05427a5f41c236b71bf7
[ "MIT" ]
7
2021-08-31T14:34:23.000Z
2022-01-19T08:25:58.000Z
#include "PS_MovableCollider.h" //------------------------------------------------------------------------------ void PS_MovableCollider::setPosition(PS_Scalar x, PS_Scalar y, PS_Scalar z) { setPosition(PS_Vector3(x, y, z)); } //------------------------------------------------------------------------------ void PS_MovableCollider::setPosition(const PS_Vector3& position) { mPosition = position; } //------------------------------------------------------------------------------ const PS_Vector3& PS_MovableCollider::getPosition(void) const { return mPosition; } //------------------------------------------------------------------------------ void PS_MovableCollider::setRotation(const PS_Matrix3x3& rotation) { mRotation = rotation; } //------------------------------------------------------------------------------ const PS_Matrix3x3& PS_MovableCollider::getRotation(void) const { return mRotation; }
33.071429
80
0.430886
hackerlank
0f22d1d4a84242d0f1652994198fd0fe6981c9ec
1,252
hpp
C++
silkrpc/types/log.hpp
enriavil1/silkrpc
1fa2109658d4c89b6cfdd5190d919bd1324f367e
[ "Apache-2.0" ]
9
2021-03-08T13:26:46.000Z
2022-02-25T23:23:16.000Z
silkrpc/types/log.hpp
enriavil1/silkrpc
1fa2109658d4c89b6cfdd5190d919bd1324f367e
[ "Apache-2.0" ]
151
2020-11-22T15:42:58.000Z
2022-03-31T20:12:18.000Z
silkrpc/types/log.hpp
enriavil1/silkrpc
1fa2109658d4c89b6cfdd5190d919bd1324f367e
[ "Apache-2.0" ]
5
2021-03-15T11:01:34.000Z
2022-03-12T15:45:00.000Z
/* Copyright 2020 The Silkrpc Authors Licensed 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. */ #ifndef SILKRPC_TYPES_LOG_HPP_ #define SILKRPC_TYPES_LOG_HPP_ #include <iostream> #include <vector> #include <evmc/evmc.hpp> #include <silkworm/common/base.hpp> namespace silkrpc { struct Log { /* raw fields */ evmc::address address; std::vector<evmc::bytes32> topics; silkworm::Bytes data; /* derived fields */ uint64_t block_number{0}; evmc::bytes32 tx_hash; uint32_t tx_index{0}; evmc::bytes32 block_hash; uint32_t index{0}; bool removed{false}; }; typedef std::vector<Log> Logs; std::ostream& operator<<(std::ostream& out, const Log& log); } // namespace silkrpc #endif // SILKRPC_TYPES_LOG_HPP_
24.54902
75
0.718051
enriavil1
0f24cfb6e46e468609fabc0ebc9f89efadaf80fd
611
hpp
C++
source/clock.hpp
blauerpullover/programmiersprachen-aufgabenblatt-3
6a9fdcbc88b348cbd52a99f45ec01d17f9b56872
[ "MIT" ]
null
null
null
source/clock.hpp
blauerpullover/programmiersprachen-aufgabenblatt-3
6a9fdcbc88b348cbd52a99f45ec01d17f9b56872
[ "MIT" ]
null
null
null
source/clock.hpp
blauerpullover/programmiersprachen-aufgabenblatt-3
6a9fdcbc88b348cbd52a99f45ec01d17f9b56872
[ "MIT" ]
null
null
null
#ifndef CLOCK_HPP #define CLOCK_HPP #include "window.hpp" #include "circle.hpp" #include "color.hpp" class Clock{ public: Clock(Vec2 const& ctr, float r, Color const& clr); void center (Vec2 const& ctr); Vec2 center() const; void radius (float r); //setter float radius() const; //getter void color(Color const& clr); Color color() const; void draw(Window const& w) const; void draw(Window const& w, Color const& clr) const; private: Vec2 center_; float radius_; Color color_; }; #endif
21.068966
60
0.582651
blauerpullover
0f274c4904dea2542446d2abdfe933619aa2da34
5,570
cpp
C++
source/d3d9/d3d9_impl_swapchain.cpp
resistancelion/reshade
5d2436eb8af1b7a17cae58e48a7dc4b7bce8243f
[ "BSD-3-Clause" ]
null
null
null
source/d3d9/d3d9_impl_swapchain.cpp
resistancelion/reshade
5d2436eb8af1b7a17cae58e48a7dc4b7bce8243f
[ "BSD-3-Clause" ]
11
2021-09-25T12:31:44.000Z
2022-02-04T22:56:35.000Z
source/d3d9/d3d9_impl_swapchain.cpp
resistancelion/reshade
5d2436eb8af1b7a17cae58e48a7dc4b7bce8243f
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (C) 2014 Patrick Mours. All rights reserved. * License: https://github.com/crosire/reshade#license */ #include "d3d9_impl_device.hpp" #include "d3d9_impl_swapchain.hpp" #include "d3d9_impl_type_convert.hpp" #include "dll_log.hpp" // Include late to get HRESULT log overloads reshade::d3d9::swapchain_impl::swapchain_impl(device_impl *device, IDirect3DSwapChain9 *swapchain) : api_object_impl(swapchain, device, device), _app_state(device->_orig) { _renderer_id = 0x9000; if (D3DADAPTER_IDENTIFIER9 adapter_desc; SUCCEEDED(device->_d3d->GetAdapterIdentifier(device->_cp.AdapterOrdinal, 0, &adapter_desc))) { _vendor_id = adapter_desc.VendorId; _device_id = adapter_desc.DeviceId; // Only the last 5 digits represents the version specific to a driver // See https://docs.microsoft.com/windows-hardware/drivers/display/version-numbers-for-display-drivers const DWORD driver_version = LOWORD(adapter_desc.DriverVersion.LowPart) + (HIWORD(adapter_desc.DriverVersion.LowPart) % 10) * 10000; LOG(INFO) << "Running on " << adapter_desc.Description << " Driver " << (driver_version / 100) << '.' << (driver_version % 100); } D3DPRESENT_PARAMETERS pp = {}; _orig->GetPresentParameters(&pp); on_init(pp); } reshade::d3d9::swapchain_impl::~swapchain_impl() { on_reset(); } reshade::api::resource reshade::d3d9::swapchain_impl::get_back_buffer(uint32_t index) { assert(index == 0); return { reinterpret_cast<uintptr_t>(_backbuffer.get()) }; } reshade::api::resource reshade::d3d9::swapchain_impl::get_back_buffer_resolved(uint32_t index) { assert(index == 0); return { reinterpret_cast<uintptr_t>(_backbuffer_resolved.get()) }; } bool reshade::d3d9::swapchain_impl::on_init(const D3DPRESENT_PARAMETERS &pp) { // Get back buffer surface if (FAILED(_orig->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &_backbuffer))) return false; assert(_backbuffer != nullptr); #if RESHADE_ADDON invoke_addon_event<addon_event::init_swapchain>(this); #endif _width = pp.BackBufferWidth; _height = pp.BackBufferHeight; _backbuffer_format = convert_format(pp.BackBufferFormat); if (pp.MultiSampleType != D3DMULTISAMPLE_NONE || (pp.BackBufferFormat == D3DFMT_X8R8G8B8 || pp.BackBufferFormat == D3DFMT_X8B8G8R8)) { // Some effects rely on there being an alpha channel available, so create custom back buffer in case that is not the case switch (_backbuffer_format) { case api::format::r8g8b8x8_unorm: _backbuffer_format = api::format::r8g8b8a8_unorm; break; case api::format::b8g8r8x8_unorm: _backbuffer_format = api::format::b8g8r8a8_unorm; break; } if (FAILED(static_cast<device_impl *>(_device)->_orig->CreateRenderTarget(_width, _height, convert_format(_backbuffer_format), D3DMULTISAMPLE_NONE, 0, FALSE, &_backbuffer_resolved, nullptr))) { LOG(ERROR) << "Failed to create back buffer resolve render target!"; return false; } } else { _backbuffer_resolved = _backbuffer; } // Create state block object if (!_app_state.init_state_block()) { LOG(ERROR) << "Failed to create application state block!"; return false; } return runtime::on_init(pp.hDeviceWindow); } void reshade::d3d9::swapchain_impl::on_reset() { if (_backbuffer == nullptr) return; runtime::on_reset(); #if RESHADE_ADDON invoke_addon_event<addon_event::destroy_swapchain>(this); #endif _app_state.release_state_block(); _backbuffer.reset(); _backbuffer_resolved.reset(); } void reshade::d3d9::swapchain_impl::on_present() { const auto device_impl = static_cast<class device_impl *>(_device); if (!is_initialized() || FAILED(device_impl->_orig->BeginScene())) return; _app_state.capture(); BOOL software_rendering_enabled = FALSE; if ((device_impl->_cp.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING) != 0) software_rendering_enabled = device_impl->_orig->GetSoftwareVertexProcessing(), device_impl->_orig->SetSoftwareVertexProcessing(FALSE); // Disable software vertex processing since it is incompatible with programmable shaders // Resolve MSAA back buffer if MSAA is active if (_backbuffer_resolved != _backbuffer) device_impl->_orig->StretchRect(_backbuffer.get(), nullptr, _backbuffer_resolved.get(), nullptr, D3DTEXF_NONE); runtime::on_present(); // Stretch main render target back into MSAA back buffer if MSAA is active if (_backbuffer_resolved != _backbuffer) device_impl->_orig->StretchRect(_backbuffer_resolved.get(), nullptr, _backbuffer.get(), nullptr, D3DTEXF_NONE); // Apply previous state from application _app_state.apply_and_release(); if ((device_impl->_cp.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING) != 0) device_impl->_orig->SetSoftwareVertexProcessing(software_rendering_enabled); device_impl->_orig->EndScene(); } void reshade::d3d9::swapchain_impl::render_effects(api::command_list *cmd_list, api::resource_view rtv, api::resource_view rtv_srgb) { const auto device_impl = static_cast<class device_impl *>(_device); _app_state.capture(); BOOL software_rendering_enabled = FALSE; if ((device_impl->_cp.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING) != 0) software_rendering_enabled = device_impl->_orig->GetSoftwareVertexProcessing(), device_impl->_orig->SetSoftwareVertexProcessing(FALSE); // Disable software vertex processing since it is incompatible with programmable shaders runtime::render_effects(cmd_list, rtv, rtv_srgb); _app_state.apply_and_release(); if ((device_impl->_cp.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING) != 0) device_impl->_orig->SetSoftwareVertexProcessing(software_rendering_enabled); }
33.963415
193
0.767864
resistancelion
0f282de197bb6cc18fee106ad360723323cc87cb
808
hpp
C++
ui/src/core/model/graph/SequenceModel.hpp
thebigG/trackerboy
c6a818954b2a57bb1d883ad1d52764c6bd29de6d
[ "MIT" ]
null
null
null
ui/src/core/model/graph/SequenceModel.hpp
thebigG/trackerboy
c6a818954b2a57bb1d883ad1d52764c6bd29de6d
[ "MIT" ]
null
null
null
ui/src/core/model/graph/SequenceModel.hpp
thebigG/trackerboy
c6a818954b2a57bb1d883ad1d52764c6bd29de6d
[ "MIT" ]
null
null
null
#pragma once #include "core/model/graph/GraphModel.hpp" #include "trackerboy/data/Sequence.hpp" class SequenceModel : public GraphModel { Q_OBJECT public: explicit SequenceModel(Module &mod, QObject *parent = nullptr); virtual int count() override; virtual DataType dataAt(int index) override; virtual void setData(int index, DataType data) override; // // Sets the sequence data source for the model. The caller is responsible // for the lifetime of the given sequence. // void setSequence(trackerboy::Sequence *seq); void setSize(int size); void setLoop(uint8_t pos); void removeLoop(); void replaceData(std::vector<uint8_t> const& data); trackerboy::Sequence* sequence() const; private: trackerboy::Sequence *mSequence; };
19.238095
77
0.69802
thebigG
0f2a0e28aa7a187dcde06ca5959f83b4b677d9da
373
hpp
C++
include/awl/backends/sdl/system/event/timer_type_fwd.hpp
freundlich/libawl
0d51f388a6b662373058cb51a24ef25ed826fa0f
[ "BSL-1.0" ]
null
null
null
include/awl/backends/sdl/system/event/timer_type_fwd.hpp
freundlich/libawl
0d51f388a6b662373058cb51a24ef25ed826fa0f
[ "BSL-1.0" ]
null
null
null
include/awl/backends/sdl/system/event/timer_type_fwd.hpp
freundlich/libawl
0d51f388a6b662373058cb51a24ef25ed826fa0f
[ "BSL-1.0" ]
null
null
null
#ifndef AWL_BACKENDS_SDL_SYSTEM_EVENT_TIMER_TYPE_FWD_HPP_INCLUDED #define AWL_BACKENDS_SDL_SYSTEM_EVENT_TIMER_TYPE_FWD_HPP_INCLUDED #include <awl/backends/sdl/system/event/type_fwd.hpp> #include <fcppt/declare_strong_typedef.hpp> namespace awl::backends::sdl::system::event { FCPPT_DECLARE_STRONG_TYPEDEF(awl::backends::sdl::system::event::type, timer_type); } #endif
24.866667
82
0.836461
freundlich
0f2d9d06364c7ffad253c80beaee054f06872230
170
hxx
C++
src/Primitives.hxx
LittleGreyCells/escheme-oops
61adf2416e1ffe91f205e074d68d72d4ffbf49b9
[ "MIT" ]
null
null
null
src/Primitives.hxx
LittleGreyCells/escheme-oops
61adf2416e1ffe91f205e074d68d72d4ffbf49b9
[ "MIT" ]
null
null
null
src/Primitives.hxx
LittleGreyCells/escheme-oops
61adf2416e1ffe91f205e074d68d72d4ffbf49b9
[ "MIT" ]
null
null
null
#ifndef SCHEME_PRIMITIVES_HXX #define SCHEME_PRIMITIVES_HXX #include "Node.hxx" namespace scheme { namespace Primitives { void initialize(); } } #endif
11.333333
29
0.711765
LittleGreyCells
0f321520bac6a5826c58bccdacb60ab7281a61c5
9,120
cc
C++
src/logic/lib/factpp/expression.cc
amartya00/libowlcpp
cea67243502d007d1b97ee2bd5d5bc66553df0ad
[ "BSL-1.0" ]
null
null
null
src/logic/lib/factpp/expression.cc
amartya00/libowlcpp
cea67243502d007d1b97ee2bd5d5bc66553df0ad
[ "BSL-1.0" ]
null
null
null
src/logic/lib/factpp/expression.cc
amartya00/libowlcpp
cea67243502d007d1b97ee2bd5d5bc66553df0ad
[ "BSL-1.0" ]
null
null
null
/** @file "/owlcpp/lib/logic/factpp/expression.cpp" part of owlcpp project. @n @n Distributed under the Boost Software License, Version 1.0; see doc/license.txt. @n Copyright Mikhail K Levin 2012 *******************************************************************************/ #include "expression.hpp" #include "obj_type.hpp" #include "obj_property.hpp" #include "data_property.hpp" #include "data_type.hpp" #include "data_range.hpp" #include "data_instance.hpp" #include "owlcpp/rdf/print_node.hpp" #include "owlcpp/rdf/query_node.hpp" #include "node_property_declaration.hpp" #include "node_type_declaration.hpp" #include "find_node_declaration.hpp" #include "owlcpp/detail/datatype_impl.hpp" namespace owlcpp{ namespace logic{ namespace factpp{ using namespace owlcpp::terms; /* *******************************************************************************/ template<> Expression<Obj_type>::ptr_t make_expression<Obj_type>(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Obj_type>::ptr_t ptr_t; typedef Expression<Obj_type>::Err Err; if( ea.handle == owl_Thing::id() ) return ptr_t(new Ot_thing()); if( ea.handle == owl_Nothing::id() ) return ptr_t(new Ot_nothing()); if( is_iri(ts[ea.handle].ns_id()) ) return ptr_t(new Ot_declared(ea, ts)); if( ea.e_type == owl_Restriction::id() ) return make_restriction_ote(ea, ts); if( ea.e_type == owl_Class::id() ) return make_class_ote(ea, ts); switch (ea.pred1()) { case owl_intersectionOf::index: case owl_unionOf::index: return ptr_t(new Ot_type_list(ea, ts)); case owl_complementOf::index: return ptr_t(new Ot_complement(ea, ts)); case owl_oneOf::index: return ptr_t(new Ot_instance_list(ea, ts)); default: BOOST_THROW_EXCEPTION( Err() << Err::msg_t("unsupported object type") << Err::str1_t(ea.string(ts)) ); /* no break */ } } /* *******************************************************************************/ template<> Expression<Obj_prop>::ptr_t make_expression<Obj_prop>(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Obj_prop>::ptr_t ptr_t; typedef Expression<Obj_prop>::Err Err; if( ea.handle == owl_topObjectProperty::id() ) return ptr_t(new Op_top()); if( ea.handle == owl_bottomObjectProperty::id() ) return ptr_t(new Op_bottom()); if( is_iri(ts[ea.handle].ns_id()) ) return ptr_t(new Op_declared(ea, ts)); if( ea.pred1 == owl_inverseOf::id() ) return ptr_t(new Op_inverse(ea, ts)); BOOST_THROW_EXCEPTION( Err() << Err::msg_t("unsupported object property") << Err::str1_t(ea.string(ts)) ); } /* *******************************************************************************/ template<> Expression<Data_range>::ptr_t make_expression<Data_range>(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Data_range>::ptr_t ptr_t; typedef Expression<Data_range>::Err Err; if( is_empty(ea.handle) ) BOOST_THROW_EXCEPTION( Err() << Err::msg_t("data range not declared") ); switch( internal_type_id(ea.handle) ) { case detail::Empty_tid: case detail::Unknown_tid: break; default: return ptr_t(new Dr_standard(ea, ts)); } if( is_iri(ts[ea.handle].ns_id()) ) return ptr_t(new Dt_declared(ea, ts)); switch(ea.pred1()) { case owl_intersectionOf::index: case owl_unionOf::index: return ptr_t(new Dt_junction(ea, ts)); case owl_datatypeComplementOf::index: return ptr_t(new Dt_complement(ea, ts)); case owl_oneOf::index: return ptr_t(new Dt_oneof(ea, ts)); case owl_onDatatype::index: return ptr_t(new Dt_restriction(ea, ts)); } BOOST_THROW_EXCEPTION( Err() << Err::msg_t("unsupported data range") << Err::str1_t(ea.string(ts)) ); } /* *******************************************************************************/ template<> Expression<Data_type>::ptr_t make_expression<Data_type>(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Data_type>::ptr_t ptr_t; typedef Expression<Data_type>::Err Err; if( is_empty(ea.handle) ) BOOST_THROW_EXCEPTION( Err() << Err::msg_t("data type not declared") ); if( ! is_iri(ts[ea.handle].ns_id()) ) BOOST_THROW_EXCEPTION( Err() << Err::msg_t("unsupported data type") << Err::str1_t(ea.string(ts)) ); switch( internal_type_id(ea.handle) ) { case detail::Unknown_tid: return ptr_t(new Dt_declared(ea, ts)); default: return ptr_t(new Dt_standard(ea, ts)); } } /* *******************************************************************************/ template<> Expression<Data_prop>::ptr_t make_expression<Data_prop>(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Data_prop>::ptr_t ptr_t; typedef Expression<Data_prop>::Err Err; if( ea.handle == owl_topDataProperty::id() ) return ptr_t(new Dp_top()); if( ea.handle == owl_bottomDataProperty::id() ) return ptr_t(new Dp_bottom()); if( is_iri(ts[ea.handle].ns_id()) ) return ptr_t(new Dp_declared(ea, ts)); BOOST_THROW_EXCEPTION( Err() << Err::msg_t("unsupported data property") << Err::str1_t(ea.string(ts)) ); } /* *******************************************************************************/ template<> Expression<Data_facet>::ptr_t make_expression<Data_facet>(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Data_facet>::ptr_t ptr_t; //typedef Expression<Data_facet>::Err Err; Node_literal const& node = to_literal(ts[ea.obj1]); return ptr_t(new Facet_restriction(ea.pred1, node, ts)); } /* *******************************************************************************/ template<> Expression<Data_inst>::ptr_t make_expression<Data_inst>(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Data_inst>::ptr_t ptr_t; Node_literal const& nl = to_literal(ts[ea.handle]); return ptr_t( new D_value(nl, ts)); } /* *******************************************************************************/ Expression<Obj_type>::ptr_t make_restriction_ote(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Obj_type>::ptr_t ptr_t; typedef Expression<Obj_type>::Err Err; if( ea.pred1 != owl_onProperty::id() ) BOOST_THROW_EXCEPTION( Err() << Err::msg_t( "\"_:x rdf:type owl:Restriction\" without \"_:x " "owl:onProperty y\"" ) << Err::str1_t(ea.string(ts)) ); const Node_property np = declaration<Node_property>(ea.obj1, ts); if( ! np.is_object() && ! np.is_data() ) BOOST_THROW_EXCEPTION( Err() << Err::msg_t( "object in \"_:x owl:onProperty y\" should be defined as " "object or data property" ) << Err::str1_t(ea.string(ts)) ); switch (ea.cardinality()) { case empty_::index: break; case owl_cardinality::index: case owl_maxCardinality::index: case owl_minCardinality::index: case owl_maxQualifiedCardinality::index: case owl_minQualifiedCardinality::index: case owl_qualifiedCardinality::index: if( np.is_object() ) return ptr_t(new Ot_opc_restriction(ea, ts)); if( np.is_data() ) return ptr_t(new Ot_dpc_restriction(ea, ts)); /* no break */ default: BOOST_THROW_EXCEPTION( Err() << Err::msg_t("unexpected cardinality node in owl:Restriction expression") << Err::str1_t(ea.string(ts)) ); /* no break */ } switch (ea.pred2()) { case owl_allValuesFrom::index: case owl_hasValue::index: if( np.is_data() ) return ptr_t(new Ot_data_has_value(ea, ts)); /* no break */ case owl_hasSelf::index: case owl_someValuesFrom::index: if( np.is_object() ) return ptr_t(new Ot_op_restriction(ea, ts)); if( np.is_data() ) return ptr_t(new Ot_dp_restriction(ea, ts)); /* no break */ default: BOOST_THROW_EXCEPTION( Err() << Err::msg_t("unsupported predicate for owl:Restriction expression") << Err::str1_t(ea.string(ts)) ); /* no break */ } } /* *******************************************************************************/ Expression<Obj_type>::ptr_t make_class_ote(Expression_args const& ea, Triple_store const& ts) { typedef Expression<Obj_type>::ptr_t ptr_t; typedef Expression<Obj_type>::Err Err; switch (ea.pred1()) { case owl_intersectionOf::index: case owl_unionOf::index: return ptr_t(new Ot_type_list(ea, ts)); case owl_complementOf::index: return ptr_t(new Ot_complement(ea, ts)); case owl_oneOf::index: return ptr_t(new Ot_instance_list(ea, ts)); default: BOOST_THROW_EXCEPTION( Err() << Err::msg_t("unsupported predicate for owl:Class expression") << Err::str1_t(ea.string(ts)) ); /* no break */ } } }//namespace factpp }//namespace logic }//namespace owlcpp
34.029851
86
0.600329
amartya00
0f3663fc3d6a8895897b7c20af75d7b6731506fd
3,099
cc
C++
gltracesim/src/generator/pipeline/analysis_queue.cc
JRPan/gltracesim
79708f503047922538ca2983392c0e9f99a4345a
[ "BSD-3-Clause" ]
11
2018-06-12T01:38:52.000Z
2021-05-21T19:53:27.000Z
gltracesim/src/generator/pipeline/analysis_queue.cc
JRPan/gltracesim
79708f503047922538ca2983392c0e9f99a4345a
[ "BSD-3-Clause" ]
null
null
null
gltracesim/src/generator/pipeline/analysis_queue.cc
JRPan/gltracesim
79708f503047922538ca2983392c0e9f99a4345a
[ "BSD-3-Clause" ]
3
2019-03-31T15:00:50.000Z
2021-12-07T22:05:03.000Z
#include "generator/pipeline/analysis_queue.hh" namespace gltracesim { namespace pipeline { AnalysisQueue::AnalysisQueue() : fout_buffer(&_data0), analysis_buffer(&_data1) { } AnalysisQueue::~AnalysisQueue() { } // void AnalysisQueue::add_work_thread(int tid) { // work_threads.push_back(work_thread_t()); // tid work_threads.back().tid = tid; } // void AnalysisQueue::add_work_item(int aid) { // work_items.push_back(aid); } // void AnalysisQueue::push(const packet_t &pkt) { // producer_mtx.lock(); // fout_buffer->data[fout_buffer->pos] = pkt; // ++fout_buffer->pos; // Buffer is full, need to process if (fout_buffer->pos >= fout_buffer->data.size()) { // Wait for (size_t i = 0; i < work_threads.size(); ++i) { // work_threads[i].done.wait(); // work_threads[i].done.clear(); } consumer_mtx.lock(); // rotate_buffers(); // job_queue.insert( job_queue.begin(), work_items.begin(), work_items.end() ); // Start consumers for (size_t i = 0; i < work_threads.size(); ++i) { work_threads[i].has_work.set(); } consumer_mtx.unlock(); } // producer_mtx.unlock(); } void AnalysisQueue::start() { // producer_mtx.lock(); // Push all analazers on work queue job_queue.insert( job_queue.begin(), work_items.begin(), work_items.end() ); // for (size_t i = 0; i < work_threads.size(); ++i) { work_threads[i].has_work.set(); } // producer_mtx.unlock(); } void AnalysisQueue::rotate_buffers() { // temp buffer_t *p = fout_buffer; // P <- A fout_buffer = analysis_buffer; // analysis_buffer = p; // fout_buffer->pos = 0; } int AnalysisQueue::pop(int timeout, int tid) { // if (work_threads[tid].has_work.wait(timeout) == false) { return -1; } // consumer_mtx.lock(); // No more jobs, clear state if (job_queue.empty()) { // No more work work_threads[tid].has_work.clear(); // Nothing alse todo work_threads[tid].done.set(); // consumer_mtx.unlock(); // return -1; } // int aid = job_queue.front(); // job_queue.pop_front(); // consumer_mtx.unlock(); // return aid; } void AnalysisQueue::signal_producer(int tid, int aid) { // consumer_mtx.lock(); // No more jobs, clear state if (job_queue.empty()) { // No more work work_threads[tid].has_work.clear(); // work_threads[tid].done.set(); } // consumer_mtx.unlock(); } void AnalysisQueue::wait() { // producer_mtx.lock(); for (size_t i = 0; i < work_threads.size(); ++i) { // work_threads[i].done.wait(); // work_threads[i].done.clear(); } // producer_mtx.unlock(); } } // end namespace pipeline } // end namespace gltracesim
15.974227
67
0.547273
JRPan
0f3a1fdbf8a8affc85768b879a621344e82feeb1
2,577
hpp
C++
src/emu6502/common.hpp
macsimbodnar/emu
017bac23e38269065f2229dae89d92e788aeee73
[ "MIT" ]
3
2019-10-01T12:20:10.000Z
2021-03-02T15:31:46.000Z
src/emu6502/common.hpp
macsimbodnar/emu
017bac23e38269065f2229dae89d92e788aeee73
[ "MIT" ]
null
null
null
src/emu6502/common.hpp
macsimbodnar/emu
017bac23e38269065f2229dae89d92e788aeee73
[ "MIT" ]
null
null
null
#pragma once #include <stdint.h> #include <string> enum class access_mode_t { // Access mode type READ = 0, // Read from memory WRITE, // Write to memory READ_ONLY }; /** * Callback used by the MOS6502 Class to read / write memory * * usr_data User data will be passed here * address Address of memory to access in range from 0x0000 to 0xFFFF * read_write Memory access mode. If READ data stored at 'address' will be * copied in 'data', if WRITE 'data' will be copied at 'address' * data Data used to store/read. If 'read_write' is READ 'data' is * output parameter, if WRITE 'data' is input parameter * */ typedef void (*mem_access_callback)(void *usr_data, const uint16_t address, const access_mode_t read_write, uint8_t &data); // Data structure returned by get_status() // and contain the current status of the MOS6502 struct p_state_t { uint8_t A; // Register A uint8_t X; // Index X uint8_t Y; // Index Y uint8_t S; // Stack pointer uint8_t P; // Processor stats uint16_t PC; // Program counter // Mnemonic name of the last executed instruction std::string opcode_name; uint8_t opcode; // Last executed operational code // The size of byte of the current opcode. Can be 1, 2 or 3 unsigned int opcode_size; uint8_t data_bus; // last data passed through the data bus uint16_t address; // Last abbsolute address used uint16_t relative_adderess; // Last relative address // Last data stored in temporary buffer used for // inner logic uint16_t tmp_buff; // Cycles left for current opcode. NOTE(max): currently allways 0 unsigned int cycles_count; // Cycles need fo last opcode to complete. NOTE(max): currently not accurate unsigned int cycles_needed; uint16_t PC_executed; // Address of the last opcode executed // Argument 1 of the last opcode executed. Is valid only // if opcode_size > 1 uint8_t arg1; // Argument 2 of the last opcode executed. Is valid only if opcode_size > 2 uint8_t arg2; // Total cycles executed by the cpu. NOTE(max): currently not used uint32_t tot_cycles; int64_t time; // Time that this cycle take to execute in ms }; // This is the callback that the cpu use to log. If set the CPU will log, if not // the log will be just skipped typedef void (*log_callback)(const std::string &log);
37.347826
80
0.648428
macsimbodnar
0f3a597799a7eaa8093311e54cb6677504541707
1,169
hpp
C++
include/PageContainer.hpp
FORTYSS0/lab-refactoring-12
898d5011a74fdfff3c9c077c9cfa45c9aa3f9f6f
[ "MIT" ]
null
null
null
include/PageContainer.hpp
FORTYSS0/lab-refactoring-12
898d5011a74fdfff3c9c077c9cfa45c9aa3f9f6f
[ "MIT" ]
null
null
null
include/PageContainer.hpp
FORTYSS0/lab-refactoring-12
898d5011a74fdfff3c9c077c9cfa45c9aa3f9f6f
[ "MIT" ]
null
null
null
// Copyright 2021 by FORTYSS #ifndef INCLUDE_PAGECONTAINER_HPP_ #define INCLUDE_PAGECONTAINER_HPP_ #include <algorithm> #include <set> #include <sstream> #include <string> #include <vector> #include <iostream> #include "Histogram.hpp" #include "Loger.hpp" #include "Statistic.hpp" #include "UsedMemory.hpp" constexpr size_t kMinLines = 10; class PageContainer { public: void RawLoad(std::istream& file); [[nodiscard]] const Item& ByIndex(const size_t& i) const; [[nodiscard]] const Item& ById(const std::string& id) const; [[nodiscard]] size_t GetRawDataSize() const; [[nodiscard]] size_t GetDataSize() const; void DataLoad(const float& threshold); static bool IsCorrect(std::string& line); void PrintTable() const; explicit PageContainer(UsedMemory* memory_counter = new UsedMemory(), Statistic* statistic_sender = new Statistic()) : memory_counter_(memory_counter), statistic_sender_(statistic_sender){} ~PageContainer(); private: UsedMemory* memory_counter_; Statistic* statistic_sender_; std::vector<Item> data_; std::vector<std::string> raw_data_; }; #endif // INCLUDE_PAGECONTAINER_HPP_
23.38
78
0.727973
FORTYSS0
0f3e553415fd79a5674ae86830770da5e4a8354c
248
cpp
C++
C++/04_structor_example/04_structor_example.cpp
alientek-openedv/Embedded-Qt-Tutorial
3c75142235b4d39c22e1ad56a5bd92d08c1a0d42
[ "MIT" ]
1
2022-02-21T03:19:36.000Z
2022-02-21T03:19:36.000Z
C++/04_structor_example/04_structor_example.cpp
alientek-openedv/Embedded-Qt-Tutorial
3c75142235b4d39c22e1ad56a5bd92d08c1a0d42
[ "MIT" ]
null
null
null
C++/04_structor_example/04_structor_example.cpp
alientek-openedv/Embedded-Qt-Tutorial
3c75142235b4d39c22e1ad56a5bd92d08c1a0d42
[ "MIT" ]
1
2021-10-19T04:03:56.000Z
2021-10-19T04:03:56.000Z
#include <iostream> #include <string> using namespace std; class Dog { public: Dog(); ~Dog(); }; int main() { Dog dog; cout<<"构造与析构函数示例"<<endl; return 0; } Dog::Dog() { cout<<"构造函数执行!"<<endl; } Dog::~Dog() { cout<<"析构函数执行!"<<endl; }
8.551724
25
0.572581
alientek-openedv
0f43c0b90bd56351ccf107153b23eb75c5e60b44
4,487
cc
C++
src/kiwi/http/server.cc
hugopeixoto/kiwi-http
7149939dcbb59a793e87b27ae4df771123356467
[ "MIT" ]
null
null
null
src/kiwi/http/server.cc
hugopeixoto/kiwi-http
7149939dcbb59a793e87b27ae4df771123356467
[ "MIT" ]
null
null
null
src/kiwi/http/server.cc
hugopeixoto/kiwi-http
7149939dcbb59a793e87b27ae4df771123356467
[ "MIT" ]
null
null
null
/** * @file response.h * kiwi/http * * Copyright (c) 2013 Hugo Peixoto. * Distributed under the MIT License. */ #include "kiwi/http/server.h" #include "kiwi/http/response.h" #include "kiwi/http/parser.h" #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/select.h> #include <netinet/in.h> #include <netinet/ip.h> /* superset of previous */ #include <netinet/tcp.h> #include <assert.h> #include <list> using kiwi::http::Server; struct Connection { int fd; kiwi::http::Parser parser; kiwi::http::Response response; Connection () { fd = -1; } bool in_use () const { return fd != -1; } bool ready () const { return false; } void close () { ::close(fd); parser.reset(); fd = -1; } }; struct Server::Implementation { const static int MAX_CONNECTIONS = 32; int server_fd; Connection connections[MAX_CONNECTIONS]; int nconnections; int maxfd; char* buffer; void recalc () { maxfd = server_fd; for (uint32_t i = 0; i < MAX_CONNECTIONS; ++i) { if (connections[i].in_use()) { maxfd = std::max(maxfd, connections[i].fd); } } } ~Implementation () { for (uint32_t i = 0; i < MAX_CONNECTIONS; ++i) { if (connections[i].in_use()) { connections[i].close(); } } } }; Server::Server () { data = new Implementation(); data->server_fd = -1; data->nconnections = 0; data->buffer = new char[1<<12]; } bool Server::construct (uint16_t a_port) { sockaddr_in server; data->server_fd = socket(AF_INET, SOCK_STREAM, 0); if (data->server_fd < 0) { return false; } data->recalc(); { int reuseaddr = 1; setsockopt(data->server_fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr)); } server.sin_family = AF_INET; server.sin_port = htons(a_port); server.sin_addr.s_addr = INADDR_ANY; if (bind(data->server_fd, (sockaddr*)&server, sizeof(server)) != 0) { return false; } if (listen(data->server_fd, Implementation::MAX_CONNECTIONS) != 0) { return false; } return true; } Server::~Server () { close(data->server_fd); delete[] data->buffer; delete data; } bool Server::close (uint32_t a_idx) { data->connections[a_idx].close(); --data->nconnections; return true; } bool Server::accept () { if (data->nconnections == Implementation::MAX_CONNECTIONS) { return true; } int fd = ::accept(data->server_fd, NULL, NULL); if (fd < 0) { return false; } for (uint32_t i = 0; i < Implementation::MAX_CONNECTIONS; ++i) { if (!data->connections[i].in_use()) { //printf("pos %d\n", i); data->connections[i].fd = fd; data->connections[i].response.set_socket(fd); ++data->nconnections; if (fd > data->maxfd) data->maxfd = fd; break; } } return true; } bool Server::begin (Request*& a_request, Response*& a_response) { // TODO(hpeixoto): this should go into a C file or something. a_request = NULL; a_response = NULL; for (uint32_t i = 0; i < Implementation::MAX_CONNECTIONS; ++i) { if (data->connections[i].parser.pop_request(a_request)) { a_response = &data->connections[i].response; return true; } } fd_set fds; FD_ZERO(&fds); FD_SET(data->server_fd, &fds); for (uint32_t i = 0; i < Implementation::MAX_CONNECTIONS; ++i) { if (data->connections[i].in_use()) { FD_SET(data->connections[i].fd, &fds); } } int active = select(data->maxfd + 1, &fds, NULL, NULL, NULL); if (active < 0) { return false; } if (FD_ISSET(data->server_fd, &fds)) { if (!accept()) { return false; } } for (uint32_t i = 0; i < Implementation::MAX_CONNECTIONS; ++i) { if (data->connections[i].in_use()) { if (FD_ISSET(data->connections[i].fd, &fds)) { receive(i); } } } return true; } bool Server::receive (uint32_t a_idx) { int received = recv(data->connections[a_idx].fd, data->buffer, 1<<12, 0); //printf("received %d bytes\n", received); if (received <= 0) { close(a_idx); return true; } if (data->connections[a_idx].parser.feed(data->buffer, received) == false) { close(a_idx); return true; } return true; } bool Server::end (Request*& a_request, Response*& a_response) { for (uint32_t i = 0; i < Implementation::MAX_CONNECTIONS; ++i) { if (data->connections[i].fd == a_response->socket()) { close(i); break; } } return true; }
19.76652
89
0.611767
hugopeixoto
0f574392a4810bec21ea7f18cc3411d1b382d42e
38,669
cc
C++
system-test/maxtest/src/mariadb_nodes.cc
mariadb-corporation/MaxScale
e18ccc287d7714165479992f5214aacc7486048d
[ "BSD-3-Clause" ]
1,157
2015-01-06T15:44:47.000Z
2022-03-28T02:52:37.000Z
system-test/maxtest/src/mariadb_nodes.cc
mariadb-corporation/MaxScale
e18ccc287d7714165479992f5214aacc7486048d
[ "BSD-3-Clause" ]
80
2015-02-13T11:49:05.000Z
2022-01-17T09:00:11.000Z
system-test/maxtest/src/mariadb_nodes.cc
mariadb-corporation/MaxScale
e18ccc287d7714165479992f5214aacc7486048d
[ "BSD-3-Clause" ]
361
2015-01-14T03:01:00.000Z
2022-03-28T00:14:04.000Z
/** * @file mariadb_nodes.cpp - backend nodes routines * * @verbatim * Revision History * * Date Who Description * 17/11/14 Timofey Turenko Initial implementation * * @endverbatim */ #include <maxtest/mariadb_nodes.hh> #include <algorithm> #include <cassert> #include <future> #include <functional> #include <fstream> #include <iostream> #include <string> #include <vector> #include <maxbase/format.hh> #include <maxtest/envv.hh> #include <maxtest/log.hh> #include <maxtest/mariadb_connector.hh> #include <maxtest/test_dir.hh> using std::cout; using std::endl; using std::string; using std::move; using SslMode = mxt::MariaDBServer::SslMode; namespace { // These need to match the values in create_user.sh. const string admin_user = "test-admin"; const string admin_pw = "test-admin-pw"; } /** * Tries to find MariaDB server version number in the output of 'mysqld --version' * * @param version String returned by 'mysqld --version' * @return String with version number */ string MariaDBCluster::extract_version_from_string(const string& version) { int pos1 = 0; int pos2 = 0; int l = version.length(); while ((!isdigit(version[pos1])) && (pos1 < l)) { pos1++; } pos2 = pos1; while (((isdigit(version[pos2]) || version[pos2] == '.')) && (pos2 < l)) { pos2++; } return version.substr(pos1, pos2 - pos1); } MariaDBCluster::MariaDBCluster(mxt::SharedData* shared, const std::string& cnf_server_prefix) : Nodes(shared) , m_cnf_server_prefix(cnf_server_prefix) { m_test_dir = mxt::SOURCE_DIR; } bool MariaDBCluster::setup(const mxt::NetworkConfig& nwconfig, int n_min_expected) { bool rval = true; m_n_req_backends = n_min_expected; int found = read_nodes_info(nwconfig); if (found < n_min_expected) { logger().add_failure("Found %i node(s) in network_config when at least %i was expected.", found, n_min_expected); rval = false; } return rval; } MariaDBCluster::~MariaDBCluster() { for (int i = 0; i < N; i++) { if (m_blocked[i]) { unblock_node(i); } } close_connections(); } int MariaDBCluster::connect(int i, const std::string& db) { if (nodes[i] == NULL || mysql_ping(nodes[i]) != 0) { if (nodes[i]) { mysql_close(nodes[i]); } nodes[i] = open_conn_db_timeout(port[i], ip4(i), db.c_str(), m_user_name, m_password, 50, m_ssl); } if ((nodes[i] == NULL) || (mysql_errno(nodes[i]) != 0)) { return 1; } else { return 0; } } int MariaDBCluster::connect(const std::string& db) { int res = 0; for (int i = 0; i < N; i++) { res += connect(i, db); } return res; } bool MariaDBCluster::robust_connect(int n) { bool rval = false; for (int i = 0; i < n; i++) { if (connect("") == 0) { // Connected successfully, return immediately rval = true; break; } // We failed to connect, disconnect and wait for a second before trying again disconnect(); sleep(1); } return rval; } void MariaDBCluster::close_connections() { for (int i = 0; i < N; i++) { if (nodes[i] != NULL) { mysql_close(nodes[i]); nodes[i] = NULL; } } } int MariaDBCluster::read_nodes_info(const mxt::NetworkConfig& nwconfig) { auto prefixc = nwconf_prefix().c_str(); string key_user = mxb::string_printf("%s_user", prefixc); m_user_name = envvar_get_set(key_user.c_str(), "skysql"); string key_pw = mxb::string_printf("%s_password", prefixc); m_password = envvar_get_set(key_pw.c_str(), "skysql"); string key_ssl = mxb::string_printf("%s_ssl", prefixc); setenv(key_ssl.c_str(), m_ssl ? "true" : "false", 1); const string space = " "; const char start_db_def[] = "systemctl start mariadb || service mysql start"; const char stop_db_def[] = "systemctl stop mariadb || service mysql stop"; const char clean_db_def[] = "rm -rf /var/lib/mysql/*; killall -9 mysqld"; clear_vms(); m_backends.clear(); int i = 0; while (i < N_MAX) { string node_name = mxb::string_printf("%s_%03d", prefixc, i); if (add_node(nwconfig, node_name)) { string cnf_name = m_cnf_server_prefix + std::to_string(i + 1); auto srv = std::make_unique<mxt::MariaDBServer>(&m_shared, cnf_name, *node(i), *this, i); string key_port = node_name + "_port"; port[i] = readenv_int(key_port.c_str(), 3306); string key_socket = node_name + "_socket"; string val_socket = envvar_get_set(key_socket.c_str(), "%s", space.c_str()); m_socket_cmd[i] = (val_socket != space) ? ("--socket=" + val_socket) : space; string key_socket_cmd = node_name + "_socket_cmd"; setenv(key_socket_cmd.c_str(), m_socket_cmd[i].c_str(), 1); string key_start_db_cmd = node_name + "_start_db_command"; srv->m_settings.start_db_cmd = envvar_get_set(key_start_db_cmd.c_str(), start_db_def); string key_stop_db_cmd = node_name + "_stop_db_command"; srv->m_settings.stop_db_cmd = envvar_get_set(key_stop_db_cmd.c_str(), stop_db_def); string key_clear_db_cmd = node_name + "_cleanup_db_command"; srv->m_settings.cleanup_db_cmd = envvar_get_set(key_clear_db_cmd.c_str(), clean_db_def); m_backends.push_back(move(srv)); i++; } else { break; } } assert(i == Nodes::n_nodes()); N = i; return i; } void MariaDBCluster::print_env() { auto namec = name().c_str(); for (int i = 0; i < N; i++) { printf("%s node %d \t%s\tPort=%d\n", namec, i, ip4(i), port[i]); printf("%s Access user %s\n", namec, access_user(i)); } printf("%s User name %s\n", namec, m_user_name.c_str()); printf("%s Password %s\n", namec, m_password.c_str()); } int MariaDBCluster::stop_node(int node) { return ssh_node(node, m_backends[node]->m_settings.stop_db_cmd, true); } int MariaDBCluster::start_node(int node, const char* param) { string cmd = mxb::string_printf("%s %s", m_backends[node]->m_settings.start_db_cmd.c_str(), param); return ssh_node(node, cmd, true); } bool MariaDBCluster::stop_nodes() { auto func = [this](int i) { return stop_node(i) == 0; }; return run_on_every_backend(func); } bool MariaDBCluster::start_nodes() { auto func = [this](int i) { return m_backends[i]->start_database(); }; return run_on_every_backend(func); } int MariaDBCluster::stop_slaves() { int i; int global_result = 0; connect(); for (i = 0; i < N; i++) { printf("Stopping slave %d\n", i); fflush(stdout); global_result += execute_query(nodes[i], (char*) "stop slave;"); } close_connections(); return global_result; } bool MariaDBCluster::create_base_users(int node) { using mxt::MariaDBServer; // Create the basic test admin user with ssh as the backend may not accept external connections. // The sql-command given to ssh must escape double quotes. auto vm = this->node(node); string drop_query = mxb::string_printf(R"(drop user \"%s\";)", admin_user.c_str()); vm->run_sql_query(drop_query); string create_query = mxb::string_printf( R"(create user \"%s\" identified by \"%s\"; grant all on *.* to \"%s\" with grant option;)", admin_user.c_str(), admin_pw.c_str(), admin_user.c_str()); auto res = vm->run_sql_query(create_query); bool rval = false; if (res.rc == 0) { auto be = backend(node); be->update_status(); auto sr = supports_require(); auto gen_all_grants_user = [be, sr](const string& name, const string& pw, SslMode ssl_mode) { mxt::MariaDBUserDef user_def; user_def.name = name; user_def.password = pw; bool rval = false; if (be->create_user(user_def, ssl_mode, sr) && be->admin_connection()->try_cmd_f("GRANT ALL ON *.* TO '%s'@'%%' WITH GRANT OPTION;", name.c_str())) { rval = true; } return rval; }; auto ssl_mode = ssl() ? SslMode::ON : SslMode::OFF; if (gen_all_grants_user(m_user_name, m_password, ssl_mode) && gen_all_grants_user("repl", "repl", SslMode::OFF) && gen_all_grants_user("skysql", "skysql", ssl_mode) && gen_all_grants_user("maxskysql", "skysql", ssl_mode) && gen_all_grants_user("maxuser", "maxuser", ssl_mode)) { rval = true; } else { logger().log_msgf("Failed to generate all users on cluster %s node %i.", name().c_str(), node); } } else { logger().log_msgf("Command '%s' failed on cluster '%s' node %i. Return value: %i, %s.", create_query.c_str(), name().c_str(), node, res.rc, res.output.c_str()); } return rval; } int MariaDBCluster::clean_iptables(int node) { return ssh_node_f(node, true, "while [ \"$(iptables -n -L INPUT 1|grep '%d')\" != \"\" ]; do iptables -D INPUT 1; done;" "while [ \"$(ip6tables -n -L INPUT 1|grep '%d')\" != \"\" ]; do ip6tables -D INPUT 1; done;" "while [ \"$(iptables -n -L OUTPUT 1|grep '3306')\" != \"\" ]; do iptables -D OUTPUT 1; done;", port[node], port[node]); } void MariaDBCluster::block_node_from_node(int src, int dest) { std::ostringstream ss; ss << "iptables -I OUTPUT 1 -p tcp -d " << ip4(dest) << " --dport 3306 -j DROP;"; ssh_node_f(src, true, "%s", ss.str().c_str()); } void MariaDBCluster::unblock_node_from_node(int src, int dest) { std::ostringstream ss; ss << "iptables -D OUTPUT -p tcp -d " << ip4(dest) << " --dport 3306 -j DROP;"; ssh_node_f(src, true, "%s", ss.str().c_str()); } std::string MariaDBCluster::block_command(int node) const { const char FORMAT[] = "iptables -I INPUT -p tcp --dport %d -j REJECT;" "ip6tables -I INPUT -p tcp --dport %d -j REJECT"; char command[sizeof(FORMAT) + 20]; sprintf(command, FORMAT, port[node], port[node]); return command; } std::string MariaDBCluster::unblock_command(int node) const { const char FORMAT[] = "iptables -I INPUT -p tcp --dport %d -j ACCEPT;" "ip6tables -I INPUT -p tcp --dport %d -j ACCEPT"; char command[sizeof(FORMAT) + 20]; sprintf(command, FORMAT, port[node], port[node]); return command; } bool MariaDBCluster::block_node(int node) { std::string command = block_command(node); int res = ssh_node_f(node, true, "%s", command.c_str()); m_blocked[node] = true; return res == 0; } bool MariaDBCluster::unblock_node(int node) { string command = unblock_command(node); int res = clean_iptables(node); res += ssh_node_f(node, true, "%s", command.c_str()); m_blocked[node] = false; return res == 0; } int MariaDBCluster::block_all_nodes() { auto func = [this](int i) { return block_node(i); }; return run_on_every_backend(func); } bool MariaDBCluster::unblock_all_nodes() { auto func = [this](int i) { return unblock_node(i); }; return run_on_every_backend(func); } bool MariaDBCluster::fix_replication() { auto namec = name().c_str(); auto& log = logger(); // First, check that all backends can be connected to. If not, try to start any failed ones. bool dbs_running = false; if (update_status()) { dbs_running = true; } else { log.log_msgf("Some servers of %s could not be queried. Trying to restart and reconnect.", namec); start_nodes(); sleep(1); if (update_status()) { dbs_running = true; log.log_msgf("Reconnection to %s worked.", namec); } else { log.log_msgf("Reconnection to %s failed.", namec); } } bool need_fixing = true; if (dbs_running) { if (check_replication() && prepare_servers_for_test()) { need_fixing = false; } } bool rval = false; if (need_fixing) { log.log_msgf("%s is broken, fixing ...", namec); if (unblock_all_nodes()) { log.log_msgf("Firewalls on %s open.", namec); if (reset_servers()) { log.log_msgf("%s reset. Starting replication.", namec); start_replication(); int attempts = 0; bool cluster_ok = false; while (!cluster_ok && attempts < 10) { if (attempts > 0) { log.log_msgf("Iteration %i, %s is still broken, waiting.", attempts, namec); sleep(10); } if (check_replication()) { cluster_ok = true; } attempts++; } if (cluster_ok) { log.log_msgf("%s is replicating/synced.", namec); rval = prepare_servers_for_test(); } else { log.add_failure("%s is still broken.", namec); } } else { logger().add_failure("Server preparation on %s failed.", name().c_str()); } } else { logger().add_failure("Failed to unblock %s.", name().c_str()); } } else { rval = true; } disconnect(); return rval; } int MariaDBCluster::get_server_id(int index) { int id = -1; char str[1024]; if (find_field(this->nodes[index], "SELECT @@server_id", "@@server_id", (char*) str) == 0) { id = atoi(str); } else { printf("find_field failed for %s:%d\n", ip4(index), this->port[index]); } return id; } std::string MariaDBCluster::get_server_id_str(int index) { std::stringstream ss; ss << get_server_id(index); return ss.str(); } std::vector<std::string> MariaDBCluster::get_all_server_ids_str() { std::vector<std::string> rval; for (int i = 0; i < N; i++) { rval.push_back(get_server_id_str(i)); } return rval; } std::vector<int> MariaDBCluster::get_all_server_ids() { std::vector<int> rval; for (int i = 0; i < N; i++) { rval.push_back(get_server_id(i)); } return rval; } std::string MariaDBCluster::anonymous_users_query() const { return "SELECT CONCAT('\\'', user, '\\'@\\'', host, '\\'') FROM mysql.user WHERE user = ''"; } bool MariaDBCluster::prepare_servers_for_test() { // Remove anonymous users. TODO: Extend this to detect leftover users and create any missing users. bool drop_ok = false; auto master = m_backends[0].get(); // Assume that first server is a master for all cluster types. if (master->ping_or_open_admin_connection()) { auto conn = master->admin_connection(); auto res = conn->query(anonymous_users_query()); if (res) { drop_ok = true; int rows = res->get_row_count(); if (rows > 0) { logger().log_msgf("Detected %i anonymous users on %s, dropping them.", rows, name().c_str()); while (res->next_row()) { string user = res->get_string(0); string query = mxb::string_printf("DROP USER %s;", user.c_str()); if (!conn->try_cmd(query)) { drop_ok = false; } } } } } bool rval = false; if (drop_ok) { bool normal_conn_ok = check_normal_conns(); if (!normal_conn_ok) { // Try to regenerate users. The user generation script replaces users. As the cluster // is replicating, doing this on the master should be enough. auto vmname = m_backends[0]->m_vm.m_name.c_str(); logger().log_msgf("Recreating users on '%s' with SSL %s.", vmname, m_ssl ? "on" : "off"); if (create_users(0)) { sleep(1); // Wait for cluster sync. Could come up with something better. normal_conn_ok = check_normal_conns(); logger().log_msgf("Connections to %s %s after recreating users.", name().c_str(), normal_conn_ok ? "worked" : "failed"); } else { logger().log_msgf("User recreation on '%s' failed.", vmname); } } if (normal_conn_ok) { rval = true; for (int i = 0; i < N; i++) { auto srv = m_backends[i].get(); srv->ping_or_open_admin_connection(); auto conn = srv->admin_connection(); if (conn->cmd("SET GLOBAL max_connections=10000")) { conn->try_cmd("SET GLOBAL max_connect_errors=10000000"); // fails on Xpand } else { rval = false; } } } } return rval; } int MariaDBCluster::execute_query_all_nodes(const char* sql) { int local_result = 0; connect(); for (int i = 0; i < N; i++) { local_result += execute_query(nodes[i], "%s", sql); } close_connections(); return local_result; } void MariaDBCluster::close_active_connections() { if (this->nodes[0] == NULL) { this->connect(); } const char* sql = "select id from information_schema.processlist where id != @@pseudo_thread_id and user not in ('system user', 'repl')"; for (int i = 0; i < N; i++) { if (!mysql_query(nodes[i], sql)) { MYSQL_RES* res = mysql_store_result(nodes[i]); if (res) { MYSQL_ROW row; while ((row = mysql_fetch_row(res))) { std::string q("KILL "); q += row[0]; execute_query_silent(nodes[i], q.c_str()); } mysql_free_result(res); } } } } void MariaDBCluster::stash_server_settings(int node) { ssh_node(node, "sudo rm -rf /etc/my.cnf.d.backup/", true); ssh_node(node, "sudo mkdir /etc/my.cnf.d.backup/", true); ssh_node(node, "sudo cp -r /etc/my.cnf.d/* /etc/my.cnf.d.backup/", true); } void MariaDBCluster::restore_server_settings(int node) { ssh_node(node, "sudo mv -f /etc/my.cnf.d.backup/* /etc/my.cnf.d/", true); } void MariaDBCluster::disable_server_setting(int node, const char* setting) { ssh_node_f(node, true, "sudo sed -i 's/%s/#%s/' /etc/my.cnf.d/*", setting, setting); } void MariaDBCluster::add_server_setting(int node, const char* setting) { ssh_node_f(node, true, "sudo sed -i '$a [server]' /etc/my.cnf.d/*server*.cnf"); ssh_node_f(node, true, "sudo sed -i '$a %s' /etc/my.cnf.d/*server*.cnf", setting); } void MariaDBCluster::reset_server_settings(int node) { string cnf_dir = m_test_dir + "/mdbci/cnf/"; string cnf_file = get_srv_cnf_filename(node); string cnf_path = cnf_dir + cnf_file; // Note: This is a CentOS specific path ssh_node(node, "rm -rf /etc/my.cnf.d/*", true); copy_to_node(node, cnf_path.c_str(), "~/"); ssh_node_f(node, false, "sudo install -o root -g root -m 0644 ~/%s /etc/my.cnf.d/", cnf_file.c_str()); // Always configure the backend for SSL std::string ssl_dir = m_test_dir + "/ssl-cert"; std::string ssl_cnf = m_test_dir + "/ssl.cnf"; copy_to_node_legacy(ssl_dir.c_str(), "~/", node); copy_to_node_legacy(ssl_cnf.c_str(), "~/", node); ssh_node_f(node, true, "cp %s/ssl.cnf /etc/my.cnf.d/", access_homedir(node)); ssh_node_f(node, true, "cp -r %s/ssl-cert /etc/", access_homedir(node)); ssh_node_f(node, true, "chown mysql:mysql -R /etc/ssl-cert"); } void MariaDBCluster::reset_all_servers_settings() { for (int node = 0; node < N; node++) { reset_server_settings(node); } } bool MariaDBCluster::reset_server(int i) { auto& srv = m_backends[i]; srv->stop_database(); srv->cleanup_database(); reset_server_settings(i); auto& vm = srv->vm_node(); auto namec = vm.m_name.c_str(); // Note: These should be done by MDBCI vm.run_cmd_sudo("test -d /etc/apparmor.d/ && " "ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld && " "sudo service apparmor restart && " "chmod a+r -R /etc/my.cnf.d/*"); bool reset_ok = false; const char vrs_cmd[] = "/usr/sbin/mysqld --version"; auto res_version = vm.run_cmd_output(vrs_cmd); if (res_version.rc == 0) { string version_digits = extract_version_from_string(res_version.output); if (version_digits.compare(0, 3, "10.") == 0) { const char reset_db_cmd[] = "mysql_install_db; sudo chown -R mysql:mysql /var/lib/mysql"; logger().log_msgf("Running '%s' on '%s'", reset_db_cmd, namec); if (vm.run_cmd_sudo(reset_db_cmd) == 0) { reset_ok = true; } else { logger().add_failure("'%s' failed on '%s'.", reset_db_cmd, namec); } } else { logger().add_failure("'%s' on '%s' returned '%s'. Detected server version '%s' is not " "supported by the test system.", vrs_cmd, vm.m_name.c_str(), res_version.output.c_str(), version_digits.c_str()); } } else { logger().add_failure("'%s' failed on '%s'.", vrs_cmd, vm.m_name.c_str()); } bool started = srv->start_database(); if (!started) { logger().add_failure("Database process start failed on '%s' after reset.", namec); } return reset_ok && started; } bool MariaDBCluster::reset_servers() { auto func = [this](int i) { return reset_server(i); }; return run_on_every_backend(func); } std::string MariaDBCluster::cnf_servers() { string rval; rval.reserve(100 * N); bool use_ip6 = using_ipv6(); for (int i = 0; i < N; i++) { auto& name = m_backends[i]->cnf_name(); string one_server = mxb::string_printf("[%s]\n" "type=server\n" "address=%s\n" "port=%i\n\n", name.c_str(), use_ip6 ? ip6(i) : ip_private(i), port[i]); rval += one_server; } return rval; } std::string MariaDBCluster::cnf_servers_line() { string rval; string sep; for (int i = 0; i < N; i++) { rval.append(sep).append(m_backends[i]->cnf_name()); sep = ","; } return rval; } const char* MariaDBCluster::ip(int i) const { return m_use_ipv6 ? Nodes::ip6(i) : Nodes::ip4(i); } void MariaDBCluster::set_use_ipv6(bool use_ipv6) { m_use_ipv6 = use_ipv6; } const char* MariaDBCluster::ip_private(int i) const { return Nodes::ip_private(i); } const char* MariaDBCluster::ip6(int i) const { return Nodes::ip6(i); } const char* MariaDBCluster::access_homedir(int i) const { return Nodes::access_homedir(i); } const char* MariaDBCluster::access_sudo(int i) const { return Nodes::access_sudo(i); } const char* MariaDBCluster::ip4(int i) const { return Nodes::ip4(i); } bool MariaDBCluster::using_ipv6() const { return m_use_ipv6; } const std::string& MariaDBCluster::cnf_server_prefix() const { return m_cnf_server_prefix; } bool MariaDBCluster::update_status() { bool rval = true; for (auto& srv : m_backends) { if (!srv->update_status()) { rval = false; } } return rval; } bool MariaDBCluster::check_backend_versions(uint64_t min_vrs) { bool rval = false; if (update_status()) { bool version_ok = true; for (auto& srv : m_backends) { if (srv->m_status.version_num < min_vrs) { // Old backend is classified as test skip, not a failed test. logger().log_msgf("Server version on '%s' is %lu when at least %lu is required.", srv->m_vm.m_name.c_str(), srv->m_status.version_num, min_vrs); version_ok = false; } } rval = version_ok; } else { logger().add_failure("Failed to update servers of %s.", name().c_str()); } return rval; } mxt::TestLogger& MariaDBCluster::logger() { return m_shared.log; } mxt::MariaDBServer* MariaDBCluster::backend(int i) { return m_backends[i].get(); } bool MariaDBCluster::check_create_test_db() { bool rval = false; if (!m_backends.empty()) { auto srv = m_backends[0].get(); if (srv->ping_or_open_admin_connection()) { auto conn = srv->admin_connection(); if (conn->cmd("DROP DATABASE IF EXISTS test;") && conn->cmd("CREATE DATABASE test;")) { rval = true; } } } return rval; } bool MariaDBCluster::basic_test_prepare() { auto prepare_one = [this](int i) { auto srv = m_backends[i].get(); bool rval = false; auto& vm = srv->m_vm; if (vm.init_ssh_master()) { rval = true; if (vm.is_remote()) { const char truncate_cmd[] = "truncate -s 0 /var/lib/mysql/*.err;" "truncate -s 0 /var/log/syslog;" "truncate -s 0 /var/log/messages;" "rm -f /etc/my.cnf.d/binlog_enc*;"; auto ret = vm.run_cmd_sudo(truncate_cmd); if (ret != 0) { // Should this be a fatal error? Maybe some of the files don't exist. logger().log_msgf("Log truncation failed. '%s' returned %i.", truncate_cmd, ret); } } } return rval; }; return run_on_every_backend(prepare_one); } int MariaDBCluster::ping_or_open_admin_connections() { std::atomic_int rval {0}; auto add_connection = [this, &rval](int i) { bool success = m_backends[i]->ping_or_open_admin_connection(); if (success) { rval++; } return true; }; run_on_every_backend(add_connection); return rval; } bool MariaDBCluster::run_on_every_backend(const std::function<bool(int)>& func) { mxt::BoolFuncArray funcs; funcs.reserve(N); for (int i = 0; i < N; i++) { auto wrapper_func = [&func, i]() { return func(i); }; funcs.push_back(std::move(wrapper_func)); } return m_shared.concurrent_run(funcs); } bool MariaDBCluster::check_normal_conns() { return check_conns(m_user_name, m_password); } bool MariaDBCluster::check_conns(const std::string& a_user_name, const std::string& a_password) { // NOTE: There is a this->user_name and this->password and that's the reason for // NOTE: 'a_user_name' and 'a_password'. Even without the prefix they would hide, // NOTE: but that would be confusing. // Check that normal connections to backends work. If ssl-mode is on, the connector refuses non-ssl // connections. bool rval = true; for (int i = 0; i < N; i++) { auto srv = backend(i); if (m_ssl) { auto conn = srv->try_open_connection(SslMode::ON, a_user_name, a_password); if (!conn->is_open()) { logger().log_msgf("Connecting to '%s' as '%s' with SSL failed when SSL should be enabled.", srv->m_vm.m_name.c_str(), a_user_name.c_str()); rval = false; } // Normal connections without ssl should not work. conn = srv->try_open_connection(SslMode::OFF, a_user_name, a_password); if (conn->is_open()) { logger().log_msgf("Connecting to '%s' as '%s' without SSL succeeded when " "SSL should be required.", srv->m_vm.m_name.c_str(), a_user_name.c_str()); rval = false; } } else { auto conn = srv->try_open_connection(SslMode::OFF, a_user_name, a_password); if (!conn->is_open()) { logger().log_msgf("Connecting to '%s' as '%s' without SSL failed when SSL should not " "be required.", srv->m_vm.m_name.c_str(), a_user_name.c_str()); rval = false; } // SSL-connections would likely work as well, as server is always configured for it. No need to // test it, though. } } return rval; } bool MariaDBCluster::ssl() const { return m_ssl; } SslMode MariaDBCluster::ssl_mode() const { return m_ssl ? SslMode::ON : SslMode::OFF; } void MariaDBCluster::set_use_ssl(bool use_ssl) { m_ssl = use_ssl; } void MariaDBCluster::remove_extra_backends() { if (m_backends.size() > (size_t)m_n_req_backends) { for (size_t i = m_n_req_backends; i < m_backends.size(); i++) { auto srv = m_backends[i].get(); if (srv->ping_or_open_admin_connection()) { logger().log_msgf("Shutting down MariaDB Server running on '%s', " "as it's not required by test.", srv->m_vm.m_name.c_str()); srv->stop_database(); } } m_backends.erase(m_backends.begin() + m_n_req_backends, m_backends.end()); N = m_backends.size(); } } bool MariaDBCluster::copy_logs(const std::string& dest_prefix) { auto func = [this, &dest_prefix](int i) { // Do not copy MariaDB logs in case of local backend bool rval = true; auto be = backend(i); if (be->m_vm.is_remote()) { string destination = mxb::string_printf("%s/LOGS/%s/%s%d_mariadb_log", mxt::BUILD_DIR, m_shared.test_name.c_str(), dest_prefix.c_str(), i); rval = be->copy_logs(destination); } return rval; }; return run_on_every_backend(func); } mxt::MariaDBUserDef MariaDBCluster::service_user_def() const { mxt::MariaDBUserDef rval; rval.name = "maxservice"; rval.password = "maxservice"; rval.grants = {"SELECT ON mysql.user", "SELECT ON mysql.db", "SELECT ON mysql.tables_priv", "SELECT ON mysql.columns_priv", "SELECT ON mysql.procs_priv", "SELECT ON mysql.proxies_priv", "SELECT ON mysql.roles_mapping", "SHOW DATABASES ON *.*"}; return rval; } const std::string& MariaDBCluster::user_name() const { return m_user_name; } const std::string& MariaDBCluster::password() const { return m_password; } namespace maxtest { maxtest::MariaDBServer::MariaDBServer(mxt::SharedData* shared, const string& cnf_name, VMNode& vm, MariaDBCluster& cluster, int ind) : m_cnf_name(cnf_name) , m_vm(vm) , m_cluster(cluster) , m_ind(ind) , m_shared(*shared) { } bool MariaDBServer::start_database() { return m_vm.run_cmd_sudo(m_settings.start_db_cmd) == 0; } bool MariaDBServer::stop_database() { return m_vm.run_cmd_sudo(m_settings.stop_db_cmd) == 0; } bool MariaDBServer::cleanup_database() { return m_vm.run_cmd_sudo(m_settings.cleanup_db_cmd) == 0; } const MariaDBServer::Status& MariaDBServer::status() const { return m_status; } bool MariaDBServer::update_status() { bool rval = false; if (ping_or_open_admin_connection()) { m_status.version_num = m_admin_conn->version_info().version; auto res = m_admin_conn->query("SELECT @@server_id, @@read_only;"); if (res && res->next_row()) { m_status.server_id = res->get_int(0); m_status.read_only = res->get_bool(1); if (!res->error()) { rval = true; } } } return rval; } MariaDBServer::SMariaDB MariaDBServer::try_open_connection(SslMode ssl, const std::string& db) { return try_open_connection(ssl, m_cluster.user_name(), m_cluster.password(), db); } MariaDBServer::SMariaDB MariaDBServer::try_open_connection(SslMode ssl, const std::string& user, const std::string& password, const std::string& db) { auto conn = std::make_unique<mxt::MariaDB>(m_vm.log()); auto& sett = conn->connection_settings(); sett.user = user; sett.password = password; if (ssl == SslMode::ON) { sett.ssl.key = mxb::string_printf("%s/ssl-cert/client-key.pem", SOURCE_DIR); sett.ssl.cert = mxb::string_printf("%s/ssl-cert/client-cert.pem", SOURCE_DIR); sett.ssl.ca = mxb::string_printf("%s/ssl-cert/ca.pem", SOURCE_DIR); sett.ssl.enabled = true; } sett.timeout = 10; auto& ip = m_cluster.using_ipv6() ? m_vm.ip6s() : m_vm.ip4s(); conn->try_open(ip, port(), db); return conn; } MariaDBServer::SMariaDB MariaDBServer::try_open_connection(const std::string& db) { return try_open_connection(m_cluster.ssl_mode(), db); } MariaDBServer::SMariaDB MariaDBServer::open_connection(const string& db) { auto conn = try_open_connection(m_cluster.ssl_mode()); m_shared.log.expect(conn->is_open(), "Failed to open MySQL connection to '%s'.", m_vm.m_name.c_str()); return conn; } bool MariaDBServer::ping_or_open_admin_connection() { bool rval = false; if (m_admin_conn && m_admin_conn->is_open() && m_admin_conn->ping()) { // Connection already exists and works. rval = true; } else { auto conn = std::make_unique<mxt::MariaDB>(m_vm.log()); auto& sett = conn->connection_settings(); sett.user = admin_user; sett.password = admin_pw; sett.clear_sql_mode = true; sett.timeout = 10; conn->try_open(m_vm.ip4s(), port()); m_admin_conn = move(conn); // Saved even if not open, so that m_admin_conn is not left null. if (m_admin_conn->is_open()) { rval = true; } } return rval; } MariaDBServer::Version MariaDBServer::version() { auto v = m_status.version_num; uint32_t major = v / 10000; uint32_t minor = (v - major * 10000) / 100; uint32_t patch = v - major * 10000 - minor * 100; return {major, minor, patch}; } std::string MariaDBServer::version_as_string() { auto v = version(); return mxb::string_printf("%i.%i.%i", v.major, v.minor, v.patch); } const string& MariaDBServer::cnf_name() const { return m_cnf_name; } VMNode& MariaDBServer::vm_node() { return m_vm; } int MariaDBServer::port() { return m_cluster.port[m_ind]; } int MariaDBServer::ind() const { return m_ind; } mxt::MariaDB* MariaDBServer::admin_connection() { // Can assume that the connection has been created. return m_admin_conn.get(); } bool MariaDBServer::copy_logs(const std::string& destination_prefix) { string log_retrive_commands[] = { "cat /var/lib/mysql/*.err", "cat /var/log/syslog | grep mysql", "cat /var/log/messages | grep mysql" }; int cmd_ind = 1; for (const auto& cmd : log_retrive_commands) { auto output = m_vm.run_cmd_output_sudo(cmd).output; if (!output.empty()) { std::ofstream outfile(destination_prefix + std::to_string(cmd_ind++)); if (outfile) { outfile << output; } } } return true; } bool MariaDBServer::create_user(const MariaDBUserDef& user, SslMode ssl, bool supports_require) { auto c = m_admin_conn.get(); string userhost = mxb::string_printf("'%s'@'%s'", user.name.c_str(), user.host.c_str()); auto userhostc = userhost.c_str(); bool create_ok = false; bool grant_error = false; // Xpand lacks support for "if exists" so avoid it and simply disregard any errors on the "drop" query. // Xpand also does not understand "require none", so instead use empty string. c->try_cmd_f("drop user %s;", userhostc); string require; if (supports_require) { require += "require "; require += (ssl == SslMode::ON ? "ssl" : "none"); } if (c->try_cmd_f("create user %s identified by '%s' %s;", userhostc, user.password.c_str(), require.c_str())) { create_ok = true; for (auto& e : user.grants) { if (!c->try_cmd_f("grant %s to %s;", e.c_str(), userhostc)) { grant_error = true; } } } return create_ok && !grant_error; } }
28.122909
131
0.552768
mariadb-corporation
0f576940fad4537a92bde833800536844b2229db
1,619
hpp
C++
psrdada_cpp/effelsberg/edd/test/SpectralKurtosis.hpp
MPIfR-BDG/psrdada_cpp
aa9436e59eeb6ee597173caeba8a9e15db8d7d46
[ "MIT" ]
null
null
null
psrdada_cpp/effelsberg/edd/test/SpectralKurtosis.hpp
MPIfR-BDG/psrdada_cpp
aa9436e59eeb6ee597173caeba8a9e15db8d7d46
[ "MIT" ]
3
2020-02-15T12:57:36.000Z
2020-04-08T14:48:57.000Z
psrdada_cpp/effelsberg/edd/test/SpectralKurtosis.hpp
MPIfR-BDG/psrdada_cpp
aa9436e59eeb6ee597173caeba8a9e15db8d7d46
[ "MIT" ]
5
2020-01-09T14:34:54.000Z
2022-03-14T07:15:39.000Z
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSIS_HPP #define PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSIS_HPP #include "psrdada_cpp/common.hpp" #include <complex> #include <vector> #include <numeric> namespace psrdada_cpp { namespace effelsberg { namespace edd { struct RFIStatistics{ std::vector<int> rfi_status; float rfi_fraction; }; class SpectralKurtosis{ public: /** * @brief constructor * * @param nchannels number of channels. * window_size number of samples per window. * sk_min minimum value of spectral kurtosis. * sk_max maximum value of spectral kurtosis. */ SpectralKurtosis(std::size_t nchannels, std::size_t window_size, float sk_min = 0.9, float sk_max = 1.1); ~SpectralKurtosis(); /** * @brief computes spectral kurtosis for the given data and returns its rfi statistics. * * @param data input data * stats RFI statistics * */ void compute_sk(std::vector<std::complex<float>> const& data, RFIStatistics& stats); private: std::size_t _nchannels; //number of channels std::size_t _window_size; //window size std::size_t _nwindows; //number of windows std::size_t _sample_size; //size of input data float _sk_min, _sk_max; std::vector<float> _p1, _p2, _s1, _s2, _sk; /** * @brief initializes the data members of the class. * * */ void init(); }; } //edd } //effelsberg } //psrdada_cpp #endif //PSRDADA_CPP_EFFELSBERG_EDD_SPECTRALKURTOSIS_HPP
26.983333
95
0.644842
MPIfR-BDG
0f5866e40250bcd794a374b9e0bd22db67eceb0f
33,597
hh
C++
include/maxscale/buffer.hh
crspecter/MaxScale
471fa20a09ebc954fc3304500037b6b55dbbf9f1
[ "BSD-3-Clause" ]
1
2021-02-07T01:57:32.000Z
2021-02-07T01:57:32.000Z
include/maxscale/buffer.hh
crspecter/MaxScale
471fa20a09ebc954fc3304500037b6b55dbbf9f1
[ "BSD-3-Clause" ]
null
null
null
include/maxscale/buffer.hh
crspecter/MaxScale
471fa20a09ebc954fc3304500037b6b55dbbf9f1
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2018 MariaDB Corporation Ab * * Use of this software is governed by the Business Source License included * in the LICENSE.TXT file and at www.mariadb.com/bsl11. * * Change Date: 2025-01-25 * * On the date above, in accordance with the Business Source License, use * of this software will be governed by version 2 or later of the General * Public License. */ #pragma once #include <maxscale/ccdefs.hh> #include <algorithm> #include <iterator> #include <memory> #include <stdint.h> #include <string.h> #include <vector> #include <maxbase/assert.h> #include <maxscale/hint.h> class SERVER; namespace maxscale { class Buffer; } enum gwbuf_type_t { GWBUF_TYPE_UNDEFINED = 0, GWBUF_TYPE_HTTP = (1 << 0), GWBUF_TYPE_IGNORABLE = (1 << 1), GWBUF_TYPE_COLLECT_RESULT = (1 << 2), GWBUF_TYPE_RESULT = (1 << 3), GWBUF_TYPE_REPLY_OK = (1 << 4), GWBUF_TYPE_REPLAYED = (1 << 5), GWBUF_TYPE_TRACK_STATE = (1 << 6), }; enum gwbuf_info_t { GWBUF_INFO_NONE = 0x0, GWBUF_INFO_PARSED = 0x1 }; /** * A structure for cleaning up memory allocations of structures which are * referred to by GWBUF and deallocated in gwbuf_free but GWBUF doesn't * know what they are. * All functions on the list are executed before freeing memory of GWBUF struct. */ enum bufobj_id_t { GWBUF_PARSING_INFO }; struct buffer_object_t; /** * A structure to encapsulate the data in a form that the data itself can be * shared between multiple GWBUF's without the need to make multiple copies * but still maintain separate data pointers. */ struct SHARED_BUF { buffer_object_t* bufobj; /*< List of objects referred to by GWBUF */ int32_t refcount; /*< Reference count on the buffer */ uint32_t info; /*< Info bits */ unsigned char data[1]; /*< Actual memory that was allocated */ }; /** * The buffer structure used by the descriptor control blocks. * * Linked lists of buffers are created as data is read from a descriptor * or written to a descriptor. The use of linked lists of buffers with * flexible data pointers is designed to minimise the need for data to * be copied within the gateway. */ struct GWBUF { GWBUF* next; /*< Next buffer in a linked chain of buffers */ GWBUF* tail; /*< Last buffer in a linked chain of buffers */ void* start; /*< Start of the valid data */ void* end; /*< First byte after the valid data */ SHARED_BUF* sbuf; /*< The shared buffer with the real data */ HINT* hint; /*< Hint data for this buffer */ SERVER* server; /*< The target server where the buffer is executed */ uint32_t gwbuf_type; /*< buffer's data type information */ #ifdef SS_DEBUG int owner; /*< Owner of the thread, only for debugging */ #endif }; inline bool gwbuf_is_type_undefined(GWBUF* b) { return b->gwbuf_type == 0; } inline bool gwbuf_is_ignorable(GWBUF* b) { return b->gwbuf_type & GWBUF_TYPE_IGNORABLE; } inline bool gwbuf_is_collected_result(GWBUF* b) { return b->gwbuf_type & GWBUF_TYPE_RESULT; } inline bool gwbuf_should_collect_result(GWBUF* b) { return b->gwbuf_type & GWBUF_TYPE_COLLECT_RESULT; } inline bool gwbuf_is_reply_ok(GWBUF* b) { return b->gwbuf_type & GWBUF_TYPE_REPLY_OK; } // True if the query is not initiated by the client but an internal replaying mechanism inline bool gwbuf_is_replayed(GWBUF* b) { return b->gwbuf_type & GWBUF_TYPE_REPLAYED; } // Track session state change response inline bool gwbuf_should_track_state(GWBUF* b) { return b->gwbuf_type & GWBUF_TYPE_TRACK_STATE; } inline bool gwbuf_is_parsed(GWBUF* b) { return b->sbuf->info & GWBUF_INFO_PARSED; } /*< * Macros to access the data in the buffers */ /*< First valid, unconsumed byte in the buffer */ inline uint8_t* gwbuf_link_data(GWBUF* b) { return static_cast<uint8_t*>(b->start); } inline const uint8_t* gwbuf_link_data(const GWBUF* b) { return static_cast<uint8_t*>(b->start); } inline uint8_t* GWBUF_DATA(GWBUF* b) { return gwbuf_link_data(b); } inline const uint8_t* GWBUF_DATA(const GWBUF* b) { return gwbuf_link_data(b); } /*< Number of bytes in the individual buffer */ inline size_t gwbuf_link_length(const GWBUF* b) { return (size_t)((char*)b->end - (char*)b->start); } inline size_t GWBUF_LENGTH(const GWBUF* b) { return gwbuf_link_length(b); } /*< Check whether the buffer is contiguous*/ inline bool gwbuf_is_contiguous(const GWBUF* b) { mxb_assert(b); return b->next == nullptr; } /*< True if all bytes in the buffer have been consumed */ inline bool gwbuf_link_empty(const GWBUF* b) { return (char*)b->start >= (char*)b->end; } inline bool GWBUF_EMPTY(const GWBUF* b) { return gwbuf_link_empty(b); } /*< Consume a number of bytes in the buffer */ inline void gwbuf_link_consume(GWBUF* b, unsigned int bytes) { b->start = bytes > ((char*)b->end - (char*)b->start) ? b->end : (void*)((char*)b->start + bytes); } inline void GWBUF_CONSUME(GWBUF* b, unsigned int bytes) { gwbuf_link_consume(b, bytes); } inline void gwbuf_link_rtrim(GWBUF* b, unsigned int bytes) { b->end = bytes > ((char*)b->end - (char*)b->start) ? b->start : (void*)((char*)b->end - bytes); } inline void GWBUF_RTRIM(GWBUF* b, unsigned int bytes) { gwbuf_link_rtrim(b, bytes); } inline uint32_t gwbuf_type(const GWBUF* b) { return b->gwbuf_type; } /*< * Function prototypes for the API to maniplate the buffers */ /** * Allocate a new gateway buffer of specified size. * * @param size The size in bytes of the data area required * * @return Pointer to the buffer structure or NULL if memory could not * be allocated. */ extern GWBUF* gwbuf_alloc(unsigned int size); /** * Allocate a new gateway buffer structure of specified size and load with data. * * @param size The size in bytes of the data area required * @param data Pointer to the data (size bytes) to be loaded * * @return Pointer to the buffer structure or NULL if memory could not * be allocated. */ extern GWBUF* gwbuf_alloc_and_load(unsigned int size, const void* data); /** * Free a chain of gateway buffers * * @param buf The head of the list of buffers to free, can be NULL. */ extern void gwbuf_free(GWBUF* buf); /** * Clone a GWBUF. Note that if the GWBUF is actually a list of * GWBUFs, then every GWBUF in the list will be cloned. Note that but * for the GWBUF structure itself, the data is shared. * * @param buf The GWBUF to be cloned. * * @return The cloned GWBUF, or NULL if any part of @buf could not be cloned. */ extern GWBUF* gwbuf_clone(GWBUF* buf); /** * @brief Deep clone a GWBUF * * Clone the data inside a GWBUF into a new buffer. The created buffer has its * own internal buffer and any modifications to the deep cloned buffer will not * reflect on the original one. Any buffer objects attached to the original buffer * will not be copied. Only the buffer type of the original buffer will be copied * over to the cloned buffer. * * @param buf Buffer to clone * * @return Deep copy of @c buf or NULL on error */ extern GWBUF* gwbuf_deep_clone(const GWBUF* buf); /** * Compare two GWBUFs. Two GWBUFs are considered identical if their * content is identical, irrespective of whether one is segmented and * the other is not. * * @param lhs One GWBUF * @param rhs Another GWBUF * * @return 0 if the content is identical, * -1 if @c lhs is less than @c rhs, and * 1 if @c lhs is more than @c rhs. * * @attention A shorter @c GWBUF less than a longer one. Otherwise the * sign of the return value is determined by the sign of the * difference between the first pair of bytes (interpreted as * unsigned char) that differ in lhs and rhs. */ extern int gwbuf_compare(const GWBUF* lhs, const GWBUF* rhs); /** * Append a buffer onto a linked list of buffer structures. * * @param head The current head of the linked list or NULL. * @param tail Another buffer to make the tail of the linked list, must not be NULL * * @return The new head of the linked list */ extern GWBUF* gwbuf_append(GWBUF* head, GWBUF* tail); /** * @brief Consume data from buffer chain * * Data is consumed from @p head until either @p length bytes have been * processed or @p head is empty. If @p head points to a chain of buffers, * those buffers are counted as a part of @p head and will also be consumed if * @p length exceeds the size of the first buffer. * * @param head The head of the linked list * @param length Number of bytes to consume * * @return The head of the linked list or NULL if everything was consumed */ extern GWBUF* gwbuf_consume(GWBUF* head, unsigned int length); /** * Trim bytes from the end of a GWBUF structure that may be the first * in a list. If the buffer has n_bytes or less then it will be freed and * the next buffer in the list will be returned, or if none, NULL. * * @param head The buffer to trim * @param n_bytes The number of bytes to trim off * * @return The buffer chain or NULL if buffer chain now empty */ extern GWBUF* gwbuf_rtrim(GWBUF* head, unsigned int length); /** * Return the number of bytes of data in the linked list. * * @param head The current head of the linked list * * @return The number of bytes of data in the linked list */ extern unsigned int gwbuf_length(const GWBUF* head); /** * Return the number of individual buffers in the linked list. * * Currently not used, provided mainly for use during debugging sessions. * * @param head The current head of the linked list * * @return The number of bytes of data in the linked list */ extern int gwbuf_count(const GWBUF* head); /** * @brief Copy bytes from a buffer * * Copy bytes from a chain of buffers. Supports copying data from buffers where * the data is spread across multiple buffers. * * @param buffer Buffer to copy from * @param offset Offset into the buffer * @param bytes Number of bytes to copy * @param dest Destination where the bytes are copied * * @return Number of bytes copied. */ extern size_t gwbuf_copy_data(const GWBUF* buffer, size_t offset, size_t bytes, uint8_t* dest); /** * @brief Split a buffer in two * * The returned value will be @c length bytes long. If the length of @c buf * exceeds @c length, the remaining buffers are stored in @buf. * * @param buf Buffer chain to split * @param length Number of bytes that the returned buffer should contain * * @return Head of the buffer chain. */ extern GWBUF* gwbuf_split(GWBUF** buf, size_t length); /** * Set given type to all buffers on the list. * * * @param buf The shared buffer * @param type Type to be added, mask of @c gwbuf_type_t values. */ extern void gwbuf_set_type(GWBUF* head, uint32_t type); /** * Convert a chain of GWBUF structures into a single GWBUF structure * * @param orig The chain to convert, must not be used after the function call * * @return A contiguous version of @c buf. * * @attention Never returns NULL, memory allocation failures abort the process */ extern GWBUF* gwbuf_make_contiguous(GWBUF* buf); /** * Add a buffer object to GWBUF buffer. * * @param buf GWBUF where object is added * @param id Type identifier for object * @param data Object data * @param donefun_fp Clean-up function to be executed before buffer is freed. */ void gwbuf_add_buffer_object(GWBUF* buf, bufobj_id_t id, void* data, void (* donefun_fp)(void*)); /** * Search buffer object which matches with the id. * * @param buf GWBUF to be searched * @param id Identifier for the object * * @return Searched buffer object or NULL if not found */ void* gwbuf_get_buffer_object_data(GWBUF* buf, bufobj_id_t id); #if defined (BUFFER_TRACE) extern void dprintAllBuffers(void* pdcb); #endif /** * Debug function for dumping buffer contents to log * * @see mxs::Buffer::hexdump * * @param buffer Buffer to dump * @param log_level Log priority where the message is written */ void gwbuf_hexdump(GWBUF* buffer, int log_level = LOG_INFO); /** * Debug function for pretty-printing buffer contents to log * * @see mxs::Buffer::hexdump_pretty * * @param buffer Buffer to dump * @param log_level Log priority where the message is written */ void gwbuf_hexdump_pretty(GWBUF* buffer, int log_level = LOG_INFO); /** * Return pointer of the byte at offset from start of chained buffer * Warning: It not guaranteed to point to a contiguous segment of memory, * it is only safe to modify the first byte this pointer point to. * * @param buffer one or more chained buffer * @param offset Offset into the buffer * @return if total buffer length is bigger than offset then return * the offset byte pointer, otherwise return null */ extern uint8_t* gwbuf_byte_pointer(GWBUF* buffer, size_t offset); #ifdef SS_DEBUG /** * Set the owner of the GWBUF. * * @param int An integer identifying the owner. */ inline void gwbuf_set_owner(GWBUF* buf, int owner) { buf->owner = owner; buf = buf->next; while (buf) { buf->owner = owner; buf = buf->next; } } #endif namespace std { template<> struct default_delete<GWBUF> { void operator()(GWBUF* pBuffer) { gwbuf_free(pBuffer); } }; } namespace maxscale { /** * @class Buffer * * @c Buffer is a simple wrapper around @ GWBUF that is more convenient to * use in a C++ context. * * As @c Buffer is a handle class, it should be created on the stack or as a * member of an enclosing class, *never* dynamically. * * @c Buffer exposed _forward_ iterators to the underlying buffer that can * be used in conjunction with standard C++ algorithms and functions. */ class Buffer { public: // buf_type : The type of the buffer, either "GWBUF*" or "const GWBUF*" // pointer_type : The type of a pointer to an element, either "uint8_t*" or "const uint8_t*". // reference_type: The type of a reference to an element, either "uint8_t&" or "const uint8_t&". template<class buf_type, class pointer_type, class reference_type> class iterator_base : public std::iterator< std::forward_iterator_tag // The type of the iterator , uint8_t // The type of the elems , std::ptrdiff_t // Difference between two its , pointer_type // The type of pointer to an elem , reference_type> // The reference type of an elem { public: /** * Returns address of the internal pointer to a GWBUF. * * @attention This is provided as a backdoor for situations where it is * unavoidable to access the interal pointer directly. It should * carefully be assessed whether it actually can be avoided. * * @return Pointer to pointer to GWBUF. */ pointer_type* address_of() { return &m_i; } /** * Advance the iterator * * This provides similar behavior to random access iterators with operator+= but does it in * non-constant time. * * @param i Number of steps to advance the iterator */ void advance(int i) { mxb_assert(m_i != m_end || i == 0); mxb_assert(i >= 0); while (m_i && m_i + i >= m_end) { i -= m_end - m_i; m_pBuffer = m_pBuffer->next; if (m_pBuffer) { m_i = GWBUF_DATA(m_pBuffer); m_end = m_i + GWBUF_LENGTH(m_pBuffer); } else { m_i = NULL; m_end = NULL; } } if (m_i) { m_i += i; } } protected: iterator_base(buf_type pBuffer = NULL) : m_pBuffer(pBuffer) , m_i(m_pBuffer ? GWBUF_DATA(m_pBuffer) : NULL) , m_end(m_pBuffer ? (m_i + GWBUF_LENGTH(m_pBuffer)) : NULL) { } void advance() { mxb_assert(m_i != m_end); ++m_i; if (m_i == m_end) { m_pBuffer = m_pBuffer->next; if (m_pBuffer) { m_i = GWBUF_DATA(m_pBuffer); m_end = m_i + GWBUF_LENGTH(m_pBuffer); } else { m_i = NULL; m_end = NULL; } } } bool eq(const iterator_base& rhs) const { return m_i == rhs.m_i; } bool neq(const iterator_base& rhs) const { return !eq(rhs); } protected: buf_type m_pBuffer; pointer_type m_i; pointer_type m_end; }; class const_iterator; // Buffer type, type of pointer to element and type of reference to element. typedef iterator_base<GWBUF*, uint8_t*, uint8_t&> iterator_base_typedef; /** * A forward iterator to Buffer. */ class iterator : public iterator_base_typedef { friend class const_iterator; public: explicit iterator(GWBUF* pBuffer = NULL) : iterator_base_typedef(pBuffer) { } iterator& operator++() { advance(); return *this; } iterator operator++(int) { iterator rv(*this); ++(*this); return rv; } bool operator==(const iterator& rhs) const { return eq(rhs); } bool operator!=(const iterator& rhs) const { return neq(rhs); } reference operator*() { mxb_assert(m_i); return *m_i; } }; // Buffer type, type of pointer to element and type of reference to element. typedef iterator_base<const GWBUF*, const uint8_t*, const uint8_t&> const_iterator_base_typedef; /** * A const forward iterator to Buffer. */ class const_iterator : public const_iterator_base_typedef { public: explicit const_iterator(const GWBUF* pBuffer = NULL) : const_iterator_base_typedef(pBuffer) { } const_iterator(const Buffer::iterator& rhs) : const_iterator_base_typedef(rhs.m_pBuffer) { m_i = rhs.m_i; m_end = rhs.m_end; } const_iterator& operator++() { advance(); return *this; } const_iterator operator++(int) { const_iterator rv(*this); ++(*this); return rv; } bool operator==(const const_iterator& rhs) const { return eq(rhs); } bool operator!=(const const_iterator& rhs) const { return neq(rhs); } reference operator*() const { mxb_assert(m_i); return *m_i; } }; /** * Creates an empty buffer. */ Buffer() : m_pBuffer(NULL) { } /** * Copy constructor. * * @param rhs The @c Buffer to copy. * * @throws @c std::bad_alloc if the underlying @c GWBUF cannot be cloned. * */ Buffer(const Buffer& rhs) { if (rhs.m_pBuffer) { m_pBuffer = gwbuf_clone(rhs.m_pBuffer); if (!m_pBuffer) { mxb_assert(!true); throw std::bad_alloc(); } } else { m_pBuffer = NULL; } } #if __cplusplus >= 201103 /** * Move constructor. * * @param rhs The @c Buffer to be moved. */ Buffer(Buffer&& rhs) : m_pBuffer(NULL) { swap(rhs); } #endif /** * Creates a @Buffer from a @ GWBUF * * @param pBuffer The buffer to create the @c Buffer from. * * @attention The ownership of @c pBuffer is transferred to the * @c Buffer being created. */ Buffer(GWBUF* pBuffer) : m_pBuffer(pBuffer) { mxb_assert(pBuffer); } /** * Creates a buffer of specified size. * * @param size The size of the buffer. * * @attention @c std::bad_alloc is thrown if the allocation fails. */ Buffer(size_t size) : m_pBuffer(gwbuf_alloc(size)) { if (!m_pBuffer) { throw std::bad_alloc(); } } /** * Creates a buffer from existing data. * * @param pData Pointer to data. * @param size The size of the data. * * @attention @c std::bad_alloc is thrown if the allocation fails. */ Buffer(const void* pData, size_t size) : m_pBuffer(gwbuf_alloc_and_load(size, pData)) { if (!m_pBuffer) { throw std::bad_alloc(); } } /** * Creates a buffer from a std::vector. * * @param data The data to be copied. * * @attention @c std::bad_alloc is thrown if the allocation fails. */ Buffer(const std::vector<uint8_t>& data) : m_pBuffer(gwbuf_alloc(data.size())) { if (m_pBuffer) { std::copy(data.begin(), data.end(), GWBUF_DATA(m_pBuffer)); } else { throw std::bad_alloc(); } } /** * Destructor */ ~Buffer() { reset(); } /** * Assignment operator * * @param rhs The @c Buffer to be assigned to this. * * @return this * * @attention The @c Buffer provided as argument will be copied, which * may cause @c std::bad_alloc to be thrown. * * @attention Does not invalidates iterators, but after the call, the iterators * will refer to the data of the other @c Buffer. * * @see Buffer::copy_from */ Buffer& operator=(const Buffer& rhs) { Buffer temp(rhs); swap(temp); return *this; } #if __cplusplus >= 201103 /** * Move assignment operator * * @param rhs The @c Buffer to be moves. */ Buffer& operator=(Buffer&& rhs) { reset(); swap(rhs); return *this; } #endif /** * Returns a forward iterator to the beginning of the Buffer. * * @return A forward iterator. */ iterator begin() { return iterator(m_pBuffer); } /** * Returns a forward iterator to the end of the Buffer. * * @return A forward iterator. */ iterator end() { return iterator(); } /** * Returns a const forward iterator to the beginning of the Buffer. * * @return A const forward iterator. */ const_iterator begin() const { return const_iterator(m_pBuffer); } /** * Returns a const forward iterator to the end of the Buffer. * * @return A const forward iterator. */ const_iterator end() const { return const_iterator(); } /** * Swap the contents with another @c Buffer * * @param buffer The @c Buffer to swap contents with. */ void swap(Buffer& buffer) { GWBUF* pBuffer = buffer.m_pBuffer; buffer.m_pBuffer = m_pBuffer; m_pBuffer = pBuffer; } /** * Clones the underlying @c GWBUF of the provided @c Buffer, and frees * the current buffer. Effectively an assignment operator that does * not throw. * * @param rhs The @c Buffer to be copied. * * @return True, if the buffer could be copied. * * @attention Invalidates all iterators. * * @see Buffer::operator = */ bool copy_from(const Buffer& rhs) { return copy_from(rhs.m_pBuffer); } /** * Clone a GWBUF and free the current buffer * * @param buf Buffer to clone * * @return True if buffer was copied * * @attention Invalidates all iterators. */ bool copy_from(GWBUF* pBuffer) { bool copied = true; if (pBuffer) { pBuffer = gwbuf_clone(pBuffer); if (!pBuffer) { copied = false; } } if (copied) { reset(pBuffer); } return copied; } /** * Compare content with another @ Buffer * * @param buffer The buffer to compare with. * * @return 0 if identical, * -1 if this less that @c buffer, and * +1 if @c buffer less than this. */ int compare(const Buffer& buffer) const { return gwbuf_compare(m_pBuffer, buffer.m_pBuffer); } /** * Compare content with a @c GWBUF * * @param buffer The buffer to compare with. * * @return 0 if identical, * -1 if this less that @c buffer, and * +1 if @c buffer less than this. */ int compare(const GWBUF& buffer) const { return gwbuf_compare(m_pBuffer, &buffer); } /** * Is content identical * * @param buffer The buffer to compare with. * * @return True, if identical, otherwise false. */ bool eq(const Buffer& buffer) const { return compare(buffer) == 0; } /** * Is content identical. * * @param pBuffer The buffer to compare with. * * @return True, if identical, otherwise false. */ bool eq(const GWBUF& buffer) const { return compare(buffer) == 0; } /** * Appends a @GWBUF to this. * * @param pBuffer The buffer to be appended to this @c Buffer. Becomes * the property of the buffer. * * @return this * * @attention Does not invalidate any iterators, but an iterator * that has reached the end will remain there. */ Buffer& append(GWBUF* pBuffer) { m_pBuffer = gwbuf_append(m_pBuffer, pBuffer); return *this; } /** * Appends a @Buffer to this. * * @param buffer The buffer to be appended to this Buffer. * * @return this * * @attention After the call, the @c Buffer provided as argument * will be empty. * * @attention Does not invalidate any iterators, but an iterator * that has reached the end will remain there. */ Buffer& append(Buffer& buffer) { m_pBuffer = gwbuf_append(m_pBuffer, buffer.release()); return *this; } /** * Appends a vector of bytes to this. * * @param buffer The std::vector<uint8_t> to append * * @return this * * @attention Does not invalidate any iterators, but an iterator * that has reached the end will remain there. */ Buffer& append(const std::vector<uint8_t>& data) { m_pBuffer = gwbuf_append(m_pBuffer, gwbuf_alloc_and_load(data.size(), data.data())); return *this; } iterator erase(const_iterator first, const_iterator last) { if (first == end()) { // Nothing to do return end(); } else if (first == last) { // Empty range deletion is a no-op that must return a non-const version of the given iterators iterator it = begin(); it.advance(std::distance(const_iterator(it), first)); mxb_assert(const_iterator(it) == first); return it; } else if (first == begin() && last == end()) { // Clear out the whole buffer reset(); return end(); } iterator rval; const_iterator b = begin(); auto offset = std::distance(b, first); auto num_bytes = std::distance(first, last); mxb_assert(num_bytes > 0); auto head = gwbuf_split(&m_pBuffer, offset); if (m_pBuffer && (m_pBuffer = gwbuf_consume(m_pBuffer, num_bytes))) { if (head) { m_pBuffer = gwbuf_append(head, m_pBuffer); } else { mxb_assert(offset == 0); } rval = begin(); rval.advance(offset + 1); } else { m_pBuffer = head; rval = end(); } return rval; } /** * Get the underlying GWBUF. * * @return The underlying @c GWBUF. * * @attention This does not release ownership of the buffer. The returned pointer must never be * freed by the caller. */ GWBUF* get() { return m_pBuffer; } const GWBUF* get() const { return m_pBuffer; } /** * Resets the underlying GWBUF. * * @param pBuffer The @c GWBUF the @c Buffer should be reset with. * * @attention The ownership of @c pBuffer is moved to the @c Buffer. * * @attention Invalidates all iterators. */ void reset(GWBUF* pBuffer = NULL) { gwbuf_free(m_pBuffer); m_pBuffer = pBuffer; } /** * Releases the underlying GWBUF. * * @return The underlying @c GWBUF. * * @attention The ownership of the buffer is transferred to the caller. * * @attention Does not invalidate existing iterators, but any manipulation * of the returned @c GWBUF may invalidate them. */ GWBUF* release() { GWBUF* pBuffer = m_pBuffer; m_pBuffer = NULL; return pBuffer; } /** * The total length of the buffer. * * @return The total length of the buffer. */ size_t length() const { return m_pBuffer ? gwbuf_length(m_pBuffer) : 0; } /** * Whether the buffer is empty. * * @return True if the buffer is empty */ bool empty() const { return m_pBuffer == nullptr; } /** * Whether the buffer is contiguous. * * @return True, if the buffer is contiguous. */ bool is_contiguous() const { return gwbuf_is_contiguous(m_pBuffer); } /** * Make the buffer contiguous. * * @return True, if the buffer could be made contiguous. * * @attention Invalidates all iterators. */ bool make_contiguous(std::nothrow_t) { GWBUF* pBuffer = gwbuf_make_contiguous(m_pBuffer); if (pBuffer) { m_pBuffer = pBuffer; } return pBuffer != NULL; } /** * Make the buffer contiguous. * * @throws @c std::bad_alloc if an allocation failed. * * @attention Invalidates all iterators. */ void make_contiguous() { if (!make_contiguous(std::nothrow)) { mxb_assert(!true); throw std::bad_alloc(); } } /** * Get pointer to internal data. The data can only be assumed contiguous if 'make_contiguous' has been * called. * * @return Pointer to internal data. */ uint8_t* data(); const uint8_t* data() const; /** * Debug function for dumping buffer contents to log * * Prints contents as hexadecimal. Only the first 1024 bytes are dumped to avoid filling up the log. * * @param log_level Log priority where the message is written */ void hexdump(int log_level = LOG_INFO) const; /** * Debug function for pretty-printing buffer contents to log * * The output format is similar to `hexdump -C` and provides both hex and human-readable values. * * @param log_level Log priority where the message is written */ void hexdump_pretty(int log_level = LOG_INFO) const; private: // To prevent @c Buffer from being created on the heap. void* operator new(size_t); // standard new void* operator new(size_t, void*); // placement new void* operator new[](size_t); // array new void* operator new[](size_t, void*);// placement array new private: GWBUF* m_pBuffer; }; /** * Checks two @c Buffers for equality. * * @return True if equal, false otherwise. */ inline bool operator==(const Buffer& lhs, const Buffer& rhs) { return lhs.eq(rhs); } /** * Checks a @c Buffer and a @c GWBUF for equality. * * @return True if equal, false otherwise. */ inline bool operator==(const Buffer& lhs, const GWBUF& rhs) { return lhs.eq(rhs); } /** * Checks two @c Buffers for un-equality. * * @return True if un-equal, false otherwise. */ inline bool operator!=(const Buffer& lhs, const Buffer& rhs) { return !lhs.eq(rhs); } /** * Checks a @c Buffer and a @c GWBUF for un-equality. * * @return True if un-equal, false otherwise. */ inline bool operator!=(const Buffer& lhs, const GWBUF& rhs) { return !lhs.eq(rhs); } }
25.337104
106
0.589547
crspecter
0f5974c018f76d79140baea5a192be4cb146ed94
701
cpp
C++
libc/test/src/math/ldexp_test.cpp
dongkyunahn-intel/llvm
a3bbc1105cf41809e6ea546ee1c541e8522db6d6
[ "Apache-2.0" ]
null
null
null
libc/test/src/math/ldexp_test.cpp
dongkyunahn-intel/llvm
a3bbc1105cf41809e6ea546ee1c541e8522db6d6
[ "Apache-2.0" ]
null
null
null
libc/test/src/math/ldexp_test.cpp
dongkyunahn-intel/llvm
a3bbc1105cf41809e6ea546ee1c541e8522db6d6
[ "Apache-2.0" ]
1
2021-11-23T17:16:34.000Z
2021-11-23T17:16:34.000Z
//===-- Unittests for ldexp -----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "LdExpTest.h" #include "include/math.h" #include "src/math/ldexp.h" #include "utils/CPP/Functional.h" #include "utils/FPUtil/FPBits.h" #include "utils/FPUtil/ManipulationFunctions.h" #include "utils/FPUtil/TestHelpers.h" #include "utils/UnitTest/Test.h" #include <limits.h> LIST_LDEXP_TESTS(double, __llvm_libc::ldexp)
31.863636
80
0.606277
dongkyunahn-intel
0f5ae69f1efba23d170638182fc096508665ec27
3,105
cpp
C++
sources/libcore/geometry/linesDistances.cpp
ucpu/cage
c7abf329d84a81a40ff11f93c6ce88290bb898ac
[ "MIT" ]
23
2018-03-18T14:28:26.000Z
2022-03-25T20:32:29.000Z
sources/libcore/geometry/linesDistances.cpp
ucpu/cage
c7abf329d84a81a40ff11f93c6ce88290bb898ac
[ "MIT" ]
8
2018-08-12T20:14:34.000Z
2021-09-04T21:24:19.000Z
sources/libcore/geometry/linesDistances.cpp
ucpu/cage
c7abf329d84a81a40ff11f93c6ce88290bb898ac
[ "MIT" ]
2
2019-11-03T17:11:51.000Z
2021-03-31T02:05:33.000Z
#include <cage-core/geometry.h> namespace cage { namespace { Real distanceLines(const Vec3 a1, const Vec3 &a2, const Vec3 &b1, const Vec3 &b2) { // algorithm taken from http://geomalgorithms.com/a07-_distance.html and modified // Copyright 2001 softSurfer, 2012 Dan Sunday // This code may be freely used, distributed and modified for any purpose // providing that this copyright notice is included with it. // SoftSurfer makes no warranty for this code, and cannot be held // liable for any real or imagined damage resulting from its use. // Users of this code must verify correctness for their application. Vec3 u = a2 - a1; Vec3 v = b2 - b1; Vec3 w = a1 - b1; Real a = dot(u, u); Real b = dot(u, v); Real c = dot(v, v); Real d = dot(u, w); Real e = dot(v, w); Real D = a * c - b * b; Real sc, tc; if (D < 1e-5) { sc = 0.0; tc = (b > c ? d / b : e / c); } else { sc = (b * e - c * d) / D; tc = (a * e - b * d) / D; } Vec3 dP = w + (sc * u) - (tc * v); return length(dP); } Real distanceSegments(const Vec3 a1, const Vec3 &a2, const Vec3 &b1, const Vec3 &b2) { // algorithm taken from http://geomalgorithms.com/a07-_distance.html and modified // Copyright 2001 softSurfer, 2012 Dan Sunday // This code may be freely used, distributed and modified for any purpose // providing that this copyright notice is included with it. // SoftSurfer makes no warranty for this code, and cannot be held // liable for any real or imagined damage resulting from its use. // Users of this code must verify correctness for their application. Vec3 u = a2 - a1; Vec3 v = b2 - b1; Vec3 w = a1 - b1; Real a = dot(u, u); Real b = dot(u, v); Real c = dot(v, v); Real d = dot(u, w); Real e = dot(v, w); Real D = a * c - b * b; Real sc, sN, sD = D; Real tc, tN, tD = D; if (D < 1e-5) { sN = 0.0; sD = 1.0; tN = e; tD = c; } else { sN = (b * e - c * d); tN = (a * e - b * d); if (sN < 0.0) { sN = 0.0; tN = e; tD = c; } else if (sN > sD) { sN = sD; tN = e + b; tD = c; } } if (tN < 0.0) { tN = 0.0; if (-d < 0.0) sN = 0.0; else if (-d > a) sN = sD; else { sN = -d; sD = a; } } else if (tN > tD) { tN = tD; if ((-d + b) < 0.0) sN = 0; else if ((-d + b) > a) sN = sD; else { sN = (-d + b); sD = a; } } sc = (abs(sN) < 1e-5 ? 0.0 : sN / sD); tc = (abs(tN) < 1e-5 ? 0.0 : tN / tD); Vec3 dP = w + (sc * u) - (tc * v); return length(dP); } } Real distance(const Line &a, const Line &b) { if (a.isLine() && b.isLine()) return distanceLines(a.origin, a.origin + a.direction, b.origin, b.origin + b.direction); if (a.isSegment() && b.isSegment()) return distanceSegments(a.a(), a.b(), b.a(), b.b()); if (a.isPoint()) return distance(a.a(), b); if (b.isPoint()) return distance(a, b.a()); CAGE_THROW_CRITICAL(NotImplemented, "geometry"); } }
23.522727
92
0.530757
ucpu
0f5b88720be614925babe717f4aa09ee3937960c
450
cpp
C++
jp.atcoder/abc027/abc027_b/11437293.cpp
kagemeka/atcoder-submissions
91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e
[ "MIT" ]
1
2022-02-09T03:06:25.000Z
2022-02-09T03:06:25.000Z
jp.atcoder/abc027/abc027_b/11437293.cpp
kagemeka/atcoder-submissions
91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e
[ "MIT" ]
1
2022-02-05T22:53:18.000Z
2022-02-09T01:29:30.000Z
jp.atcoder/abc027/abc027_b/11437293.cpp
kagemeka/atcoder-submissions
91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n+1); for (int i = 0; i < n; i++) {cin >> a[i+1]; a[i+1] += a[i];} if (a[n] % n) {cout << -1 << '\n'; return 0;} int tot = 0; int q = a[n] / n; int l = 1; for (int r = 1; r < n + 1; r++) { if ((a[r] - a[l-1]) == q * (r - l + 1)) { tot += r - l; l = r + 1; } } cout << tot << '\n'; return 0; }
19.565217
63
0.366667
kagemeka
0f5d8c5fa66dd891ed707137bd40ded78638a874
4,429
cpp
C++
Testing/nbsimBasicTest.cpp
NottingDuck/PHAS0100Assignment2
d1b191f3133fe084c856ea15cefe1f1e536de50c
[ "BSD-3-Clause" ]
null
null
null
Testing/nbsimBasicTest.cpp
NottingDuck/PHAS0100Assignment2
d1b191f3133fe084c856ea15cefe1f1e536de50c
[ "BSD-3-Clause" ]
null
null
null
Testing/nbsimBasicTest.cpp
NottingDuck/PHAS0100Assignment2
d1b191f3133fe084c856ea15cefe1f1e536de50c
[ "BSD-3-Clause" ]
null
null
null
/*============================================================================= PHAS0100ASSIGNMENT2: PHAS0100 Assignment 2 Gravitational N-body Simulation Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt in the top level directory for details. =============================================================================*/ #include "catch.hpp" #include "nbsimCatchMain.h" #include "nbsimMyFunctions.h" #include "nbsimParticle.h" #include "nbsimMassiveParticle.h" #include <iostream> #include <vector> #include <Eigen/Dense> TEST_CASE( "My first test", "[some group identifier]" ) { int a = 5; REQUIRE( a < 6 ); } TEST_CASE( "My second test", "[some group identifier]" ) { std::vector<int> a; REQUIRE( a.size() == 0 ); } TEST_CASE( "Simple add", "[MyFirstAddFunction]") { REQUIRE( nbsim::MyFirstAddFunction(1, 2) == 3); } // ------ // // Testing for Task 1: TEST_CASE( "Test a: No acceleration", "[Particle]") { Eigen::Vector3d a(0,0,0); Eigen::Vector3d p_test(0,0,0); Eigen::Vector3d v_test(1,1,1); Eigen::Vector3d p_expect(0.01,0.01,0.01); Eigen::Vector3d v_expect(1,1,1); nbsim::Particle particle_a(p_test,v_test); double dt = 0.01; REQUIRE(particle_a.getPosition().isApprox(p_test)); REQUIRE(particle_a.getVelocity().isApprox(v_test)); particle_a.integrateTimestep(a,dt); REQUIRE(particle_a.getPosition().isApprox(p_expect)); REQUIRE(particle_a.getVelocity().isApprox(v_expect)); } TEST_CASE( "Test b: Constant acceleration", "[Particle]") { Eigen::Vector3d a(1,1,1); Eigen::Vector3d p_test(0,0,0); Eigen::Vector3d v_test(1,1,1); Eigen::Vector3d p_expect1(0.01,0.01,0.01); Eigen::Vector3d v_expect1(1.01,1.01,1.01); nbsim::Particle particle_b(p_test,v_test); double dt = 0.01; particle_b.integrateTimestep(a,dt); REQUIRE(particle_b.getPosition().isApprox(p_expect1)); REQUIRE(particle_b.getVelocity().isApprox(v_expect1)); Eigen::Vector3d p_expect2(0.0201,0.0201,0.0201); Eigen::Vector3d v_expect2(1.02,1.02,1.02); particle_b.integrateTimestep(a,dt); REQUIRE(particle_b.getPosition().isApprox(p_expect2)); REQUIRE(particle_b.getVelocity().isApprox(v_expect2)); } TEST_CASE( "Test c: Fictitious centripetal acceleration", "[Particle]") { Eigen::Vector3d p_test(0,0,0); Eigen::Vector3d v_test(1,1,1); nbsim::Particle particle_c(p_test,v_test); double dt = 0.1; double time = 0.3; for(double i=0;i<time;i+=dt){ Eigen::Vector3d a = -particle_c.getPosition(); particle_c.integrateTimestep(a,dt); } Eigen::Vector3d p_expect(0.299,0.299,0.299); Eigen::Vector3d v_expect(0.97,0.97,0.97); REQUIRE(particle_c.getPosition().isApprox(p_expect)); REQUIRE(particle_c.getVelocity().isApprox(v_expect)); } TEST_CASE( "Test a: Still models linear motion correctly with no attractors", "[MassiveParticle]") { Eigen::Vector3d p_test(0,0,0); Eigen::Vector3d v_test(1,1,1); Eigen::Vector3d p_expect(0.1,0.1,0.1); Eigen::Vector3d v_expect(1,1,1); double mass = 1; double dt = 0.1; nbsim::MassiveParticle MassiveParticle_a(p_test,v_test,mass); MassiveParticle_a.calculateAcceleration(); MassiveParticle_a.integrateTimestep(dt); REQUIRE(MassiveParticle_a.getPosition().isApprox(p_expect)); REQUIRE(MassiveParticle_a.getVelocity().isApprox(v_expect)); } TEST_CASE( "Test b: With gravitationally attractors", "[MassiveParticle]") { Eigen::Vector3d p_1(1,0,0); Eigen::Vector3d v_1(0,0.5,0); Eigen::Vector3d p_2(-1,0,0); Eigen::Vector3d v_2(0,-0.5,0); double mu = 1; std::shared_ptr<nbsim::MassiveParticle> attractor_ptr1(new nbsim::MassiveParticle(p_1,v_1,mu)); std::shared_ptr<nbsim::MassiveParticle> attractor_ptr2(new nbsim::MassiveParticle(p_2,v_2,mu)); attractor_ptr1 -> addAttractor(attractor_ptr2); attractor_ptr2 -> addAttractor(attractor_ptr1); double dt = 0.001; double t = 1; for (double i=0;i<=t;i+=dt){ attractor_ptr1->calculateAcceleration(); attractor_ptr1->integrateTimestep(dt); attractor_ptr2->calculateAcceleration(); attractor_ptr2->integrateTimestep(dt); } double distance = (attractor_ptr1->getPosition() - attractor_ptr2->getPosition()).norm(); double error_expect = std::abs(distance-2); REQUIRE(error_expect <= 0.01); }
27.855346
100
0.688191
NottingDuck
0f5e824b4206373e208449a040f3c019d3bcc63a
14,882
tpp
C++
src/biomolecules/sprelay/core/command_queue.tpp
lumik/sprelay
aaae1167038fc5477fc5dc9ee026d08c1d1b88bc
[ "BSD-3-Clause" ]
null
null
null
src/biomolecules/sprelay/core/command_queue.tpp
lumik/sprelay
aaae1167038fc5477fc5dc9ee026d08c1d1b88bc
[ "BSD-3-Clause" ]
65
2017-04-11T14:40:39.000Z
2022-01-28T18:24:39.000Z
src/biomolecules/sprelay/core/command_queue.tpp
lumik/sprelay
aaae1167038fc5477fc5dc9ee026d08c1d1b88bc
[ "BSD-3-Clause" ]
null
null
null
// -*-c++-*- /*************************************************************************** ** ** ** Controlling interface for K8090 8-Channel Relay Card from Velleman ** ** through usb using virtual serial port in Qt. ** ** Copyright (C) 2018 Jakub Klener ** ** ** ** This file is part of SpRelay application. ** ** ** ** You can redistribute it and/or modify it under the terms of the ** ** 3-Clause BSD License as published by the Open Source Initiative. ** ** ** ** This program is distributed in the hope that it will be useful, ** ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** ** 3-Clause BSD License for more details. ** ** ** ** You should have received a copy of the 3-Clause BSD License along ** ** with this program. ** ** If not, see https://opensource.org/licenses/ ** ** ** ****************************************************************************/ /*! * \file command_queue.tpp * \brief The biomolecules::sprelay::core::command_queue::CommandQueue class and some other related stuff. * * \author Jakub Klener <lumiksro@centrum.cz> * \date 2018-03-07 * \copyright Copyright (C) 2018 Jakub Klener. All rights reserved. * * \copyright This project is released under the 3-Clause BSD License. You should have received a copy of the 3-Clause * BSD License along with this program. If not, see https://opensource.org/licenses/. */ #include <limits> namespace biomolecules { namespace sprelay { namespace core { /*! * \brief Namespace containing CommmandQueue. */ namespace command_queue { /*! * \namespace biomolecules::sprelay::core::command_queue::impl_ * \brief Namespace containing implementation details. Not intended for public use. */ /*! * \class biomolecules::sprelay::core::command_queue::impl_::CommandPriority * \tparam TCommand See CommandQueue template class. * \remark reentrant */ /*! * \class biomolecules::sprelay::core::command_queue::impl_::PendingCommands * The class abuses constant pointer access. You can get from it `TList<const TCommand*>` which is directly * stored inside but you can also modify stored `TCommand` using `PendingCommands::updateEntry()` method (so the * `TCommand` is not realy const, only returned list should not be used to modify them because it can distort * integrity of the queue). * * \tparam TCommand See CommandQueue template class. * \tparam tSize See CommandQueue template class. * \tparam TList See CommandQueue template class. * \remark reentrant */ /*! * \var CommandPriority::stamp * \brief Time stamp for command priority determination. * * See CommandPriority::operator<(). */ /*! * \var CommandPriority::command * \brief Owns command and manages its memory. * * Its member TCommand::priority is used to determine ordering. See * CommandPriority::operator<(). */ /*! * \fn CommandPriority::operator<(const CommandPriority& other) const * \brief Defines CommandPriority ordering. * * Ordering is defined according to TCommand::priority and time stamp CommandPriority::stamp. Higher priority and * lower time stamp is greater. */ /*! * \fn CommandPriority::setPriority(int p) * \brief Sets contained command priority to p. * * \param p The priority. */ /*! * \fn const TList<const TCommand*>& PendingCommands::operator[](std::size_t id) const * \brief Direct constant member access. * * Index id is not controlled for validity. * * \param id Index * \return List containing all commands with desired id. */ /*! * \fn TList<const TCommand*>& PendingCommands::operator[](std::size_t id) * \brief Direct member access. * * Index id is not controlled for validity. * * \param id Index * \return List containing all commands with desired id. */ /*! * \fn void PendingCommands::updateEntry(int idx, const TCommand& command) * \brief Enables update of desired command. * * Indices command.id nor idx are not controlled for validity. * * \param idx Index. * \param command Command for update. */ /*! * \class CommandQueue * The queue sorts commands according to priority and time stamp. The commands can be inserted in unique mode, where * old commands are replaced by newer ones but preserving their time stamps or non-unique mode in which more commands * with the same id can be inserted. See CommandQueue::push() for more details. * * \warning Beware time stamp overflow, see the CommandQueue::push() method description. * * Commands inside CommandQueue can be also updated using method CommandQueue::updateCommand(). To query stored * commands with desired id, you can use CommandQueue::get() method. * * Example usage: * * \code * #include "command_queue.h" * * const int N = 10; * * struct Command * { * using IdType = unsigned int; * using NumberType = unsigned int; * * Command() : id(N) {} * Command(IdType id) : id(id) {} * static NumberType idAsNumber(IdType id) { return id; } * * IdType id; * int priority; * }; * * int main() * { * using namespace biomolecules::sprelay::core::command_queue; * CommandQueue<Command, N> command_queue; * * unsigned int cmd_id1 = 0; * unsigned int priority1 = 1; * Command cmd1{cmd_id1, priority1}; * command_queue.push(cmd1); * const QList<const Command*>& cmd_list = command_queue.get(cmd_id1); * Command cmd2 = *cmd_list[0]; * cmd2.priority = 2; * command_queue.updateCommand(0, cmd2); * Command cmd3 = command_queue.pop(); * * return 0; * } * \endcode * * See ConcurentCommandQueue for thread-safe version of CommandQueue. * * \tparam TCommand Command representation, which must containt `IdType` and `NumberType` typedefs, default * constructor which initializes id to none value, `id` member of type `IdType`, `int priority` member, static * method `static NumberType idAsNumber(IdType)`. * \tparam tSize Number of command ids. Command ids `NumberType` should be continuous sequence of numbers, the highest * number must be less than `tSize`. * \tparam TList Type of container with one template parameter, which stores commands of the same id. Defaults to * QList. * \remark reentrant */ /*! * \brief Default constructor */ template<typename TCommand, int tSize, template<typename> class TList> CommandQueue<TCommand, tSize, TList>::CommandQueue() : none_command_{}, none_list_{&none_command_}, stamp_counter_{0} { unique_.fill(true); } /*! * \fn CommandQueue::empty() * \return True if the queue is empty. */ /*! * \fn CommandQueue::size() * \return Number of stored items. */ /*! * \brief Inserts command with given priority to the end of the queue. * * The inserted command also gets time stamp CommandQueue::stamp_counter(), which resolves priority ties. Older * commands preceedes new ones. * * Commands can be inserted in two modes. In unique mode, all previously inserted commands with the same id is cleared * and the new command with the time stamp of the oldest from the removed commands is inserted instead. If the * non-unique mode, the command is inserted without any control for the already inserted commands with the same id. * * \warning Time stamp is `usnigned int`, so beware overflows when there are many commands stored in the queue. The * queue is designed to be empty most of the time. When queue is empty, the time stamp is reset to zero but if the * queue is never empty, the time stamp increments to infinity and there is overflow risk. * * \param command Command to be inserted. * \param unique If the insertion should be unique. * \return True if the operation was successful, false otherwise. */ template<typename TCommand, int tSize, template<typename> class TList> bool CommandQueue<TCommand, tSize, TList>::push(const TCommand& command, bool unique) { typename TCommand::NumberType id = TCommand::idAsNumber(command.id); // TODO(lumik): Use exceptions. if (id >= tSize || id < 0) { return false; } // TODO(lumik): treat overflows of stamp_counter. if (!unique || pending_commands_[id].empty()) { // no command with this id is inside impl_::CommandPriority<TCommand> command_priority{ stamp_counter_++, std::unique_ptr<TCommand>{new TCommand{command}}}; pending_commands_[id].append(command_priority.command.get()); unique_[id] = unique; std::priority_queue<impl_::CommandPriority<TCommand>>::emplace(std::move(command_priority)); } else if (unique && unique_[id]) { // unique push with different priorities updatePriorities(id, 0, command.priority); pending_commands_.updateEntry(0, command); } else if (unique && !unique_[id]) { // wasn't unique but now it is // erase all previously inserted commands with the same id and copy all the remaining commands. std::priority_queue<impl_::CommandPriority<TCommand>> temp_command_queue; unsigned int stamp = std::numeric_limits<unsigned int>::max(); for (impl_::CommandPriority<TCommand>& command_priority : this->c) { if (command_priority.command->id != command.id) { temp_command_queue.emplace(std::move(command_priority)); } else if (command_priority.stamp < stamp) { stamp = command_priority.stamp; } } pending_commands_[id].clear(); // insert new command impl_::CommandPriority<TCommand> command_priority{stamp, std::unique_ptr<TCommand>{new TCommand{command}}}; pending_commands_[id].append(command_priority.command.get()); unique_[id] = unique; temp_command_queue.emplace(std::move(command_priority)); // move new temporary queue to stored one std::priority_queue<impl_::CommandPriority<TCommand>>::operator=(std::move(temp_command_queue)); } return true; } /*! * \brief Removes oldest most importat (according to its priority) element from the queue and returns it to the user. * * If the queue is empty, the defalut constructed TCommand is returned. * * \return The oldest most importat element. */ template<typename TCommand, int tSize, template<typename> class TList> TCommand CommandQueue<TCommand, tSize, TList>::pop() { if (empty()) { return TCommand{}; } TCommand command = *std::priority_queue<impl_::CommandPriority<TCommand>>::top().command; typename TCommand::NumberType id = TCommand::idAsNumber(command.id); pending_commands_[id].removeOne(std::priority_queue<impl_::CommandPriority<TCommand>>::top().command.get()); std::priority_queue<impl_::CommandPriority<TCommand>>::pop(); // erases command which is holded in unique_ptr if (pending_commands_[id].isEmpty()) { unique_[id] = true; } if (empty()) { stamp_counter_ = 0; } return command; } /*! * \brief Gets a list of commands with specified command id. * * If the id is not valid or the command is not in the queue the list to default constructed TCommand is returned. The * pointed to commands shouldn't be changed because it can corrupt CommandQueue consistency. You can update command * with specific index by calling CommandQueue::updateCommand() method. The pointers in the list are valid only until * the command is popped out of the CommandQueue and the indices in list is consistent with the indices, which would * be returned by another CommandQueue::get() method call, only until the CommandQueue is modified with the command * with the same id. Validity of the returned list also ends with a destruction of CommandQueue. * * \param command_id Command id. * \return Requested command or default constructed TCommand. */ template<typename TCommand, int tSize, template<typename> class TList> const TList<const TCommand*>& CommandQueue<TCommand, tSize, TList>::get(typename TCommand::IdType command_id) const { typename TCommand::NumberType id = TCommand::idAsNumber(command_id); // TODO(lumik): Use exceptions. if (id >= tSize || id < 0) { return none_list_; } return pending_commands_[id]; } /*! * \fn CommandQueue::stampCounter * \brief Gets current stamp counter. * \return Current stamp counter. */ /*! * \brief Enables command inside CommandQueue modification. * * Command is modified according to its valid index which can be determined from the list returned by the * CommandQueue::get() method. * * \param idx Index of the command. For more info see CommandQueue::get(). * \param command Command which replaces the stored command. */ template<typename TCommand, int tSize, template<typename> class TList> bool CommandQueue<TCommand, tSize, TList>::updateCommand(int idx, const TCommand& command) { typename TCommand::NumberType id = TCommand::idAsNumber(command.id); if (id >= tSize || id < 0 || idx < 0 || idx >= pending_commands_[id].size()) { return false; } updatePriorities(id, idx, command.priority); pending_commands_.updateEntry(idx, command); return true; } template<typename TCommand, int tSize, template<typename> class TList> void CommandQueue<TCommand, tSize, TList>::updatePriorities( typename TCommand::NumberType command_id, int idx, int priority) { if (pending_commands_[command_id].at(idx)->priority != priority) { std::priority_queue<impl_::CommandPriority<TCommand>> temp_command_queue; impl_::CommandPriority<TCommand> temp_priority; for (impl_::CommandPriority<TCommand>& command_priority : this->c) { if (command_priority.command.get() == pending_commands_[command_id].at(idx)) { temp_priority = std::move(command_priority); temp_priority.setPriority(priority); temp_command_queue.emplace(std::move(temp_priority)); } else { temp_command_queue.emplace(std::move(command_priority)); } } std::priority_queue<impl_::CommandPriority<TCommand>>::operator=(std::move(temp_command_queue)); } } } // namespace command_queue } // namespace core } // namespace sprelay } // namespace biomolecules
38.654545
118
0.662814
lumik
0f5ee5e711b35806f48ab3cd7c1f23426c6e469c
808
cpp
C++
xtd.forms/src/xtd/forms/button_base.cpp
lineCode/xtd.forms
53b126a41513b4009870498b9f8e522dfc94c8de
[ "MIT" ]
1
2022-02-04T08:15:31.000Z
2022-02-04T08:15:31.000Z
xtd.forms/src/xtd/forms/button_base.cpp
lineCode/xtd.forms
53b126a41513b4009870498b9f8e522dfc94c8de
[ "MIT" ]
null
null
null
xtd.forms/src/xtd/forms/button_base.cpp
lineCode/xtd.forms
53b126a41513b4009870498b9f8e522dfc94c8de
[ "MIT" ]
null
null
null
#include "../../../include/xtd/forms/button_base.hpp" #include <xtd/forms/native/window_button.hpp> using namespace xtd; using namespace xtd::forms; button_base::button_base() { this->make_control(*this); this->control::data_->auto_size_mode_ = forms::auto_size_mode::grow_only; this->control::data_->size_ = this->default_size(); } button_base& button_base::operator=(const button_base& value) { this->control::operator=(value); this->data_ = value.data_; return *this; } forms::create_params button_base::create_params() const { forms::create_params create_params = this->control::create_params(); create_params.class_name("button"); return create_params; } drawing::size button_base::measure_control() const { return this->control::measure_text() + drawing::size(13, 0); }
26.064516
75
0.72896
lineCode
0f60ef3f6b37b1f32a7ceaa0b1683fcc73d0ad03
5,753
hpp
C++
src/core/linear-algebra/Tines_Gemv.hpp
mschmidt271/Tines
2e754c930dcb0bfb52f0c8d06064076bc5f68230
[ "BSD-2-Clause" ]
null
null
null
src/core/linear-algebra/Tines_Gemv.hpp
mschmidt271/Tines
2e754c930dcb0bfb52f0c8d06064076bc5f68230
[ "BSD-2-Clause" ]
null
null
null
src/core/linear-algebra/Tines_Gemv.hpp
mschmidt271/Tines
2e754c930dcb0bfb52f0c8d06064076bc5f68230
[ "BSD-2-Clause" ]
null
null
null
/*---------------------------------------------------------------------------------- Tines - Time Integrator, Newton and Eigen Solver - version 1.0 Copyright (2021) NTESS https://github.com/sandialabs/Tines Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. This file is part of Tines. Tines is open-source software: you can redistribute it and/or modify it under the terms of BSD 2-Clause License (https://opensource.org/licenses/BSD-2-Clause). A copy of the license is also provided under the main directory Questions? Kyungjoo Kim <kyukim@sandia.gov>, or Oscar Diaz-Ibarra at <odiazib@sandia.gov>, or Cosmin Safta at <csafta@sandia.gov>, or Habib Najm at <hnnajm@sandia.gov> Sandia National Laboratories, New Mexico, USA ----------------------------------------------------------------------------------*/ #ifndef __TINES_GEMV_DECL_HPP__ #define __TINES_GEMV_DECL_HPP__ /// \author Kyungjoo Kim (kyukim@sandia.gov) #include "Tines_Gemv_Internal.hpp" #include "Tines_Internal.hpp" namespace Tines { int Gemv_HostTPL(const int trans_tag, const int m, const int n, const double alpha, const double *A, const int as0, const int as1, const double *x, const int xs0, const double beta, double *y, const int ys0); int Gemv_HostTPL(const int trans_tag, const int m, const int n, const Kokkos::complex<double> alpha, const Kokkos::complex<double> *A, const int as0, const int as1, const Kokkos::complex<double> *x, const int xs0, const Kokkos::complex<double> beta, Kokkos::complex<double> *y, const int ys0); int Gemv_HostTPL(const int trans_tag, const int m, const int n, const std::complex<double> alpha, const std::complex<double> *A, const int as0, const int as1, const std::complex<double> *x, const int xs0, const std::complex<double> beta, std::complex<double> *y, const int ys0); template <typename ArgTrans> struct Gemv { template <typename MemberType, typename ScalarType, typename AViewType, typename xViewType, typename yViewType> KOKKOS_INLINE_FUNCTION static int device_invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, const xViewType &x, const ScalarType beta, const yViewType &y) { using value_type_a = typename AViewType::non_const_value_type; using value_type_x = typename xViewType::non_const_value_type; using value_type_y = typename yViewType::non_const_value_type; constexpr bool is_value_type_same = (std::is_same<value_type_a, value_type_x>::value && std::is_same<value_type_a, value_type_y>::value); static_assert(is_value_type_same, "value_type of A, x and y does not match"); const int m = A.extent(0), n = A.extent(1); using value_type = value_type_a; value_type *Aptr = A.data(); const int as0 = A.stride(0), as1 = A.stride(1); value_type *xptr = x.data(); const int xs = x.stride(0); value_type *yptr = y.data(); const int ys = y.stride(0); int r_val(0); if (std::is_same<ArgTrans, Trans::NoTranspose>::value) { r_val = GemvInternal::invoke(member, m, n, alpha, Aptr, as0, as1, xptr, xs, beta, yptr, ys); } else if (std::is_same<ArgTrans, Trans::Transpose>::value || std::is_same<ArgTrans, Trans::ConjTranspose>::value) { r_val = GemvInternal::invoke(member, n, m, alpha, Aptr, as1, as0, xptr, xs, beta, yptr, ys); } return r_val; } template <typename MemberType, typename ScalarType, typename AViewType, typename xViewType, typename yViewType> KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, const xViewType &x, const ScalarType beta, const yViewType &y) { using value_type_a = typename AViewType::non_const_value_type; using value_type_x = typename xViewType::non_const_value_type; using value_type_y = typename yViewType::non_const_value_type; constexpr bool is_value_type_same = (std::is_same<value_type_a, value_type_x>::value && std::is_same<value_type_a, value_type_y>::value); static_assert(is_value_type_same, "value_type of A, x, and y does not match"); using value_type = value_type_a; int r_val(0); #if defined(TINES_ENABLE_TPL_CBLAS_ON_HOST) & !defined(__CUDA_ARCH__) if ((std::is_same<Kokkos::Impl::ActiveExecutionMemorySpace, Kokkos::HostSpace>::value) && (A.stride(0) == 1 || A.stride(1) == 1)) { value_type *Aptr = A.data(); const int as0 = A.stride(0), as1 = A.stride(1); value_type *xptr = x.data(); const int xs0 = x.stride(0); value_type *yptr = y.data(); const int ys0 = y.stride(0); const int m = A.extent(0), n = A.extent(1); Kokkos::single(Kokkos::PerTeam(member), [&]() { r_val = Gemv_HostTPL(ArgTrans::tag, m, n, alpha, Aptr, as0, as1, xptr, xs0, beta, yptr, ys0); }); } else { r_val = device_invoke(member, alpha, A, x, beta, y); } #else r_val = device_invoke(member, alpha, A, x, beta, y); #endif return r_val; } }; } // namespace Tines #endif
41.688406
84
0.61255
mschmidt271
0f637e5d6c69c8f24c304ff2b2620b98ed627980
335
cpp
C++
linepass/main.cpp
yalehwy/linepw
8e22ffaa49fa49dca44a6a8d6e38a16a64a41aa0
[ "Apache-2.0" ]
null
null
null
linepass/main.cpp
yalehwy/linepw
8e22ffaa49fa49dca44a6a8d6e38a16a64a41aa0
[ "Apache-2.0" ]
null
null
null
linepass/main.cpp
yalehwy/linepw
8e22ffaa49fa49dca44a6a8d6e38a16a64a41aa0
[ "Apache-2.0" ]
null
null
null
// // main.cpp // linepasswordindex // // Created by Saber on 2018/4/27. // Copyright © 2018年 Saber. All rights reserved. // // #include <iostream> #include "comprogram.hpp" int main(int argc,char* argv[]) { ComProgram *cp = new ComProgram(); int retVal = cp->main(argc, argv); delete cp; cp = nullptr; return retVal; }
17.631579
49
0.647761
yalehwy
0f63a4cf72ddde00946293cac4b29206657fed51
2,103
cpp
C++
dbms/src/Processors/Formats/Impl/JSONCompactRowOutputFormat.cpp
enriqueChen/ClickHouse
aef0e2c0a387e26645fca340e6ec7fc332562149
[ "Apache-2.0" ]
null
null
null
dbms/src/Processors/Formats/Impl/JSONCompactRowOutputFormat.cpp
enriqueChen/ClickHouse
aef0e2c0a387e26645fca340e6ec7fc332562149
[ "Apache-2.0" ]
null
null
null
dbms/src/Processors/Formats/Impl/JSONCompactRowOutputFormat.cpp
enriqueChen/ClickHouse
aef0e2c0a387e26645fca340e6ec7fc332562149
[ "Apache-2.0" ]
1
2020-05-22T18:44:44.000Z
2020-05-22T18:44:44.000Z
#include <Processors/Formats/Impl/JSONCompactRowOutputFormat.h> #include <Formats/FormatFactory.h> #include <IO/WriteHelpers.h> namespace DB { JSONCompactRowOutputFormat::JSONCompactRowOutputFormat( WriteBuffer & out_, const Block & header, const FormatSettings & settings_) : JSONRowOutputFormat(out_, header, settings_) { } void JSONCompactRowOutputFormat::writeField(const IColumn & column, const IDataType & type, size_t row_num) { type.serializeAsTextJSON(column, row_num, *ostr, settings); ++field_number; } void JSONCompactRowOutputFormat::writeFieldDelimiter() { writeCString(", ", *ostr); } void JSONCompactRowOutputFormat::writeTotalsFieldDelimiter() { writeCString(",", *ostr); } void JSONCompactRowOutputFormat::writeRowStartDelimiter() { if (row_count > 0) writeCString(",\n", *ostr); writeCString("\t\t[", *ostr); } void JSONCompactRowOutputFormat::writeRowEndDelimiter() { writeChar(']', *ostr); field_number = 0; ++row_count; } void JSONCompactRowOutputFormat::writeBeforeTotals() { writeCString(",\n", *ostr); writeChar('\n', *ostr); writeCString("\t\"totals\": [", *ostr); } void JSONCompactRowOutputFormat::writeAfterTotals() { writeChar(']', *ostr); } void JSONCompactRowOutputFormat::writeExtremesElement(const char * title, const Columns & columns, size_t row_num) { writeCString("\t\t\"", *ostr); writeCString(title, *ostr); writeCString("\": [", *ostr); size_t extremes_columns = columns.size(); for (size_t i = 0; i < extremes_columns; ++i) { if (i != 0) writeTotalsFieldDelimiter(); writeField(*columns[i], *types[i], row_num); } writeChar(']', *ostr); } void registerOutputFormatProcessorJSONCompact(FormatFactory & factory) { factory.registerOutputFormatProcessor("JSONCompact", []( WriteBuffer & buf, const Block & sample, const Context &, const FormatSettings & format_settings) { return std::make_shared<JSONCompactRowOutputFormat>(buf, sample, format_settings); }); } }
22.612903
114
0.68331
enriqueChen
0f6761a49555015a14415d6fe47b3a79e5af7542
3,592
cpp
C++
tagpool.cpp
theme/MangaLib
76af5a4f73c19cb52e00188bf8f01a5bb2e80e49
[ "BSD-3-Clause" ]
1
2017-09-23T14:32:48.000Z
2017-09-23T14:32:48.000Z
tagpool.cpp
theme/MangaLib
76af5a4f73c19cb52e00188bf8f01a5bb2e80e49
[ "BSD-3-Clause" ]
null
null
null
tagpool.cpp
theme/MangaLib
76af5a4f73c19cb52e00188bf8f01a5bb2e80e49
[ "BSD-3-Clause" ]
null
null
null
#include "tagpool.h" TagPool::TagPool(SQLiteDB *db, QObject *parent) : QObject(parent),db_(db) { connect(db_, SIGNAL(sigOpened()), this, SLOT(loadDBtags())); connect(db_, SIGNAL(sigClosed()), this, SLOT(clearCache())); } QString TagPool::tagType(QString tag) { if (tagcache_.contains(tag)){ return tagcache_.value(tag); } else { return queryType(tag); } } QStringList TagPool::tagsInString(QString str) const { QStringList tgts; // remove path QFileInfo fi(str); str = fi.fileName(); // rip file extension name QRegExp rx(".*(?=(\\.(zip|rar|cb[zr]))$)"); int pos = 0; if ((pos = rx.indexIn(str, pos)) != -1){ str = rx.cap(); } // qDebug() << str; // regex section take out QStringList expli; QMap<int,QString> caps; expli << "([^\\[\\]]+)(?=\\])" // [*] << "([^\\(\\)]+)(?=\\))" // (*) << "([^【】]+)(?=】)" // 【 】 << "([^()]+)(?=))" // () << "([^\\[\\]\\(\\)【】()~\\s\\-]+)"; for ( int i =0; i< expli.size(); ++i){ rx.setPattern(expli.at(i)); pos = 0; while ((pos = rx.indexIn(str, pos)) != -1) { if (!caps.contains(pos)){ caps.insert(pos,rx.cap()); } pos += rx.matchedLength(); } } QMap<int,QString>::const_iterator e = caps.begin(); while( e != caps.end()){ tgts << e.value(); ++e; } // qDebug() << tgts; // return results return tgts; } QStringList TagPool::typeOptions() const { QStringList li = db_->schema()->tables(); li.removeAll("file"); li.removeAll("rank"); li.removeAll("tag"); li.removeAll("link"); return li; } void TagPool::handleTagTypeChange(QString tagName, QString type, QString oldType) { if ( tagName.isEmpty()) return; if (type.isEmpty()){ //remove this->removeTag(tagName,type); } else { this->addTag(tagName,type); } } void TagPool::insertTags2Table() { QSqlQuery q = db_->select("tag"); QString ttype, tn; while(q.next()){ ttype = q.record().value(1).toString(); tn = q.record().value(0).toString(); if (!db_->hitValue(ttype,"name",tn)){ QStringList cols, vs; cols << "name"; vs << tn; db_->insert(ttype,cols,vs); } } } void TagPool::loadDBtags() { QStringList names = db_->allTableNameDotValuesOfField("name", "file"); QString ndv, n, v; int pos; for (int i = 0; i < names.size(); ++i){ ndv = names.at(i); pos = ndv.indexOf("."); n = ndv.left(pos); v = ndv.mid(pos+1); tagcache_.insert(v, n); } QSqlQuery q = db_->select("tag"); while(q.next()){ tagcache_.insert(q.record().value(0).toString(), q.record().value(1).toString()); } } void TagPool::clearCache() { tagcache_.clear(); } void TagPool::addTag(QString tagName, QString type) { QStringList cols, vs; cols << "name" << "type"; vs << tagName << type; if( db_->hitValue("tag", "name", tagName) ){ // exist, update db_->update("tag", cols, vs, "name", tagName ); } else { db_->insert("tag", cols, vs); } tagcache_.insert(tagName,type); } void TagPool::removeTag(QString tagName, QString type) { db_->removeAll("tag", "name", tagName); tagcache_.remove(tagName); } QString TagPool::queryType(QString tag) { if (!db_->isOpen()) return QString(); return db_->whichTableContainsName(tag); }
23.788079
89
0.521993
theme
0f6839e4435289ca259207c7437b4d92c7447a6b
632
cpp
C++
CPP/language/interface.cpp
lemming-life/Snippets
796d34f3d33cb0e38d38197938bc36397ce8a27b
[ "Unlicense" ]
null
null
null
CPP/language/interface.cpp
lemming-life/Snippets
796d34f3d33cb0e38d38197938bc36397ce8a27b
[ "Unlicense" ]
null
null
null
CPP/language/interface.cpp
lemming-life/Snippets
796d34f3d33cb0e38d38197938bc36397ce8a27b
[ "Unlicense" ]
null
null
null
// Author: http://lemming.life // Language: C++ // Description: Shows how to implement an interface in C++ /* At terminal do: g++ interface.cpp ./a.out */ #include <iostream> using namespace std; // An interface // - A promise that function(s) must be implemented. class Interface { public: virtual int getMe() { return 0; } }; class Implementation : public Interface { public: int getMe() { return 2; } }; int main() { // Principle: Program to an interface Interface* myInterface = new Implementation(); cout << "Calling getMe(). Expecting 2 got " << myInterface->getMe() << ".\n"; return 0; }
21.066667
81
0.643987
lemming-life
0f683d69652c37a156c1ff7e7d990c8bfb17f3cd
40,969
cpp
C++
examples/renderer/device_ispc/api/ispc_device.cpp
mbdriscoll/embree
77bb760c005fb7097335da2defe4b4711c15cdd3
[ "Intel", "Apache-2.0" ]
1
2016-03-20T23:59:42.000Z
2016-03-20T23:59:42.000Z
examples/renderer/device_ispc/api/ispc_device.cpp
mbdriscoll/embree
77bb760c005fb7097335da2defe4b4711c15cdd3
[ "Intel", "Apache-2.0" ]
null
null
null
examples/renderer/device_ispc/api/ispc_device.cpp
mbdriscoll/embree
77bb760c005fb7097335da2defe4b4711c15cdd3
[ "Intel", "Apache-2.0" ]
null
null
null
// ======================================================================== // // Copyright 2009-2013 Intel Corporation // // // // Licensed 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 "ispc_device.h" #include "image/image.h" #include "sys/taskscheduler.h" #include "api/swapchain.h" #include "sys/sync/barrier.h" /* include general stuff */ #include "api/handle.h" #include "api/data.h" #include "api/parms.h" #include "scene_ispc.h" #include "instance_ispc.h" #include "swapchain_ispc.h" /* include all cameras */ #include "cameras/pinholecamera.h" #include "cameras/depthoffieldcamera.h" /* include all lights */ #include "light_ispc.h" #include "lights/ambientlight.h" #include "lights/pointlight.h" #include "lights/spotlight.h" #include "lights/directionallight.h" #include "lights/distantlight.h" #include "lights/hdrilight.h" #include "lights/trianglelight.h" /* include all materials */ #include "materials/matte.h" #include "materials/plastic.h" #include "materials/dielectric.h" #include "materials/thindielectric.h" #include "materials/mirror.h" #include "materials/metal.h" #include "materials/metallicpaint.h" #include "materials/matte_textured.h" #include "materials/obj.h" #include "materials/velvet.h" /* include all shapes */ #include "shape_ispc.h" #include "shapes/trianglemesh.h" #include "shapes/sphere.h" #include "shapes/triangle.h" /* include all textures */ #include "image3c_ispc.h" #include "image3ca_ispc.h" #include "image3f_ispc.h" #include "image3fa_ispc.h" #include "textures/nearestneighbor.h" /* include all tonemappers */ #include "tonemappers/defaulttonemapper.h" /* include all renderers */ #include "renderer_ispc.h" #include "renderers/debugrenderer.h" #include "renderers/pathtracer.h" /* include ray tracing core interface */ #include "embree/include/embree.h" #include <stack> #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> #define strcasecmp lstrcmpiA #pragma warning(disable:4297) // function assumed not to throw an exception but does #endif double __get_seconds() { return embree::getSeconds(); } #define ASYNC_RENDER 0 extern "C" { int g_serverCount = 1; int g_serverID = 0; } namespace embree { /******************************************************************* creation of device *******************************************************************/ __dllexport Device* create(const char* parms, size_t numThreads, size_t verbose) { return new ISPCDevice(numThreads,verbose); } /******************************************************************* construction *******************************************************************/ #if ASYNC_RENDER volatile bool g_terminate = false; thread_t renderThread = NULL; BarrierSys renderBarrier; void renderThreadFunction(void* ptr); #endif ISPCDevice::ISPCDevice(size_t numThreads, size_t verbose) { rtcInit(); rtcStartThreads(numThreads); rtcSetVerbose(verbose); #if ASYNC_RENDER g_terminate = false; renderBarrier.init(2); renderThread = createThread((thread_func)renderThreadFunction,NULL,4*1024*1024); renderBarrier.wait(); #endif } ISPCDevice::~ISPCDevice() { #if ASYNC_RENDER g_terminate = true; renderBarrier.wait(); #endif rtcStopThreads(); rtcExit(); } Device::RTCamera ISPCDevice::rtNewCamera(const char* type) { if (!strcasecmp(type,"pinhole" )) return (Device::RTCamera) new ISPCCreateHandle<PinHoleCamera>; else if (!strcasecmp(type,"depthoffield")) return (Device::RTCamera) new ISPCCreateHandle<DepthOfFieldCamera>; else throw std::runtime_error("unknown camera type: "+std::string(type)); } Device::RTData ISPCDevice::rtNewData(const char* type, size_t bytes, const void* data) { if (!strcasecmp(type,"immutable" )) return (Device::RTData) new ConstHandle<Data>(new Data(bytes,data,true)); else if (!strcasecmp(type,"immutable_managed")) return (Device::RTData) new ConstHandle<Data>(new Data(bytes,data,false)); else throw std::runtime_error("unknown data buffer type: "+std::string(type)); } Device::RTData ISPCDevice::rtNewDataFromFile(const char* type, const char* fileName, size_t offset, size_t bytes) { /*! we always load locally */ if (!strncmp(fileName,"server:",7)) fileName += 7; if (!strcasecmp(type,"immutable")) { FILE* file = fopen(fileName,"rb"); if (!file) throw std::runtime_error("cannot open file "+(std::string)fileName); Data* data = new Data(bytes); fseek(file,(long)offset,SEEK_SET); if (bytes != fread(data->map(),1,bytes,file)) throw std::runtime_error("error filling data buffer from file"); fclose(file); return (Device::RTData) new ConstHandle<Data>(data); } else throw std::runtime_error("unknown data buffer type: "+std::string(type)); } Device::RTImage ISPCDevice::rtNewImage(const char* type, size_t width, size_t height, const void* data, const bool copy) { if (!strcasecmp(type,"RGB8")) return (Device::RTImage) new ISPCConstHandle(ispc::Image3c__new(width,height,(ispc::vec3uc*)data,copy)); else if (!strcasecmp(type,"RGBA8")) return (Device::RTImage) new ISPCConstHandle(ispc::Image3ca__new(width,height,(unsigned*)data,copy)); else if (!strcasecmp(type,"RGB_FLOAT32")) return (Device::RTImage) new ISPCConstHandle(ispc::Image3f__new(width,height,(ispc::vec3f*)data,copy)); else if (!strcasecmp(type,"RGBA_FLOAT32")) return (Device::RTImage) new ISPCConstHandle(ispc::Image3fa__new(width,height,(ispc::vec3fa*)data,copy)); else throw std::runtime_error("unknown image type: "+std::string(type)); } Device::RTImage ISPCDevice::rtNewImageFromFile(const char* file) { #if defined(__MIC__) throw std::runtime_error("rtNewImageFromFile not supported on MIC"); #else if (!strncmp(file,"server:",7)) file += 7; Ref<Image> image = loadImage(file); if (Ref<Image4f> img = image.dynamicCast<Image4f>()) return rtNewImage("RGBA_FLOAT32",img->width,img->height,img->steal_ptr(),false); else if (Ref<Image3f> img = image.dynamicCast<Image3f>()) return rtNewImage("RGB_FLOAT32",img->width,img->height,img->steal_ptr(),false); else if (Ref<Image4c> img = image.dynamicCast<Image4c>()) return rtNewImage("RGBA8",img->width,img->height,img->steal_ptr(),false); else if (Ref<Image3c> img = image.dynamicCast<Image3c>()) return rtNewImage("RGB8",img->width,img->height,img->steal_ptr(),false); else { int c = 0xFFFFFFFF; return rtNewImage("RGB8",1,1,&c,true); } #endif } Device::RTTexture ISPCDevice::rtNewTexture(const char* type) { if (!strcasecmp(type,"nearest")) return (Device::RTTexture) new ISPCCreateHandle<NearestNeighborTexture>; else if (!strcasecmp(type,"image" )) return (Device::RTTexture) new ISPCCreateHandle<NearestNeighborTexture>; else throw std::runtime_error("unknown texture type: "+std::string(type)); } Device::RTMaterial ISPCDevice::rtNewMaterial(const char* type) { if (!strcasecmp(type,"Matte")) return (Device::RTMaterial) new ISPCCreateHandle<Matte>; else if (!strcasecmp(type,"Plastic") ) return (Device::RTMaterial) new ISPCCreateHandle<Plastic>; else if (!strcasecmp(type,"Dielectric") ) return (Device::RTMaterial) new ISPCCreateHandle<Dielectric>; else if (!strcasecmp(type,"Glass") ) return (Device::RTMaterial) new ISPCCreateHandle<Dielectric>; else if (!strcasecmp(type,"ThinDielectric")) return (Device::RTMaterial) new ISPCCreateHandle<ThinDielectric>; else if (!strcasecmp(type,"ThinGlass") ) return (Device::RTMaterial) new ISPCCreateHandle<ThinDielectric>; else if (!strcasecmp(type,"Mirror") ) return (Device::RTMaterial) new ISPCCreateHandle<Mirror>; else if (!strcasecmp(type,"Metal") ) return (Device::RTMaterial) new ISPCCreateHandle<Metal>; //else if (!strcasecmp(type,"BrushedMetal") ) return (Device::RTMaterial) new ISPCCreateHandle<BrushedMetal>; else if (!strcasecmp(type,"MetallicPaint") ) return (Device::RTMaterial) new ISPCCreateHandle<MetallicPaint>; else if (!strcasecmp(type,"MatteTextured") ) return (Device::RTMaterial) new ISPCCreateHandle<MatteTextured>; else if (!strcasecmp(type,"Obj") ) return (Device::RTMaterial) new ISPCCreateHandle<Obj>; else if (!strcasecmp(type,"Velvet") ) return (Device::RTMaterial) new ISPCCreateHandle<Velvet>; //else if (!strcasecmp(type,"Velvet2") ) return (Device::RTMaterial) new ISPCCreateHandle<Velvet2>; //else if (!strcasecmp(type,"Satin") ) return (Device::RTMaterial) new ISPCCreateHandle<Satin>; //else if (!strcasecmp(type,"Skin") ) return (Device::RTMaterial) new ISPCCreateHandle<Skin>; //else if (!strcasecmp(type,"Cotton") ) return (Device::RTMaterial) new ISPCCreateHandle<Cotton>; //else if (!strcasecmp(type,"Woven") ) return (Device::RTMaterial) new ISPCCreateHandle<Woven>; //else if (!strcasecmp(type,"WovenIsotropic")) return (Device::RTMaterial) new ISPCCreateHandle<WovenIsotropic>; //else if (!strcasecmp(type,"Eye" )) return (Device::RTMaterial) new ISPCCreateHandle<Eye>; //else if (!strcasecmp(type,"EyeLash" )) return (Device::RTMaterial) new ISPCCreateHandle<EyeLash>; else { //throw std::runtime_error("unknown material type: "+std::string(type)); printf("WARNING: unknown material \"%s\", using Matte as default\n",type); return (Device::RTMaterial) new ISPCCreateHandle<Matte>; } } Device::RTShape ISPCDevice::rtNewShape(const char* type) { if (!strcasecmp(type,"trianglemesh")) return (Device::RTShape) new ISPCCreateHandle<ISPCTriangleMesh>; else if (!strcasecmp(type,"triangle") ) return (Device::RTShape) new ISPCCreateHandle<Triangle>; else if (!strcasecmp(type,"sphere") ) return (Device::RTShape) new ISPCCreateHandle<Sphere>; //else if (!strcasecmp(type,"disk") ) return (Device::RTShape) new ISPCCreateHandle<Disk,Shape>; else throw std::runtime_error("unknown shape type: "+std::string(type)); } Device::RTLight ISPCDevice::rtNewLight(const char* type) { if (!strcasecmp(type,"ambientlight" )) return (Device::RTLight) new ISPCCreateHandle<AmbientLight>; else if (!strcasecmp(type,"pointlight" )) return (Device::RTLight) new ISPCCreateHandle<PointLight>; else if (!strcasecmp(type,"spotlight" )) return (Device::RTLight) new ISPCCreateHandle<SpotLight>; else if (!strcasecmp(type,"directionallight")) return (Device::RTLight) new ISPCCreateHandle<DirectionalLight>; else if (!strcasecmp(type,"distantlight" )) return (Device::RTLight) new ISPCCreateHandle<DistantLight>; else if (!strcasecmp(type,"hdrilight" )) return (Device::RTLight) new ISPCCreateHandle<HDRILight>; else if (!strcasecmp(type,"trianglelight" )) return (Device::RTLight) new ISPCCreateHandle<TriangleLight>; else throw std::runtime_error("unknown light type: "+std::string(type)); } /*! Primitive Handle */ class PrimitiveHandle : public _RTHandle { ALIGNED_CLASS; public: /*! Constructs new primitive. */ PrimitiveHandle (const ISPCRef& shape, const ISPCRef& light, const ISPCRef& material, const AffineSpace3f& transform, light_mask_t illumMask = -1, light_mask_t shadowMask = -1) : shape(shape), light(light), material(material), transform(transform), illumMask(illumMask), shadowMask(shadowMask), light_instance(NULL), shape_instance(NULL) {} ~PrimitiveHandle () { if (shape_instance) rtcDeleteGeometry(shape_instance); shape_instance = NULL; } /*! Creation of new primitive. */ void create() { if (light) { light_instance = ispc::Light__transform(light.ptr, (ispc::vec3f&)transform.l.vx, (ispc::vec3f&)transform.l.vy, (ispc::vec3f&)transform.l.vz, (ispc::vec3f&)transform.p); } } /*! Setting parameters. */ void set(const std::string& property, const Variant& data) { if (property == "illumMask" ) illumMask = data.getInt(); else if (property == "shadowMask") shadowMask = data.getInt(); } ISPCRef getLightInstance() { if (!light_instance) create(); return light_instance; } RTCGeometry* getShapeInstance() { if (!shape_instance && shape) { Vec3fa lower,upper; size_t numTriangles = ispc::Shape__getNumTriangles(shape.ptr); size_t numVertices = ispc::Shape__getNumVertices(shape.ptr); RTCGeometry* mesh = rtcNewTriangleMesh (numTriangles, numVertices, "default"); RTCTriangle* triangles = (RTCTriangle*) rtcMapTriangleBuffer(mesh); Vec3fa* vertices = (Vec3fa* ) rtcMapPositionBuffer(mesh); numTriangles = 0; numVertices = 0; ispc::Shape__extract(shape.ptr,0x7FFFFFFF, (ispc::RTCTriangle*)triangles,(int&)numTriangles, (ispc::RTCVertex *)vertices ,(int&)numVertices, (ispc::vec3f&)lower,(ispc::vec3f&)upper); rtcSetApproxBounds(mesh, (float*)&lower, (float*)&upper); rtcUnmapTriangleBuffer(mesh); rtcUnmapPositionBuffer(mesh); rtcBuildAccel(mesh, "default"); shape_instance = mesh; } return shape_instance; } public: ISPCRef shape; //!< Shape in case of a shape primitive ISPCRef light; //!< Light in case of a light primitive ISPCRef material; //!< Material of shape primitive AffineSpace3f transform; //!< Transformation of primitive light_mask_t illumMask; light_mask_t shadowMask; ISPCRef light_instance; RTCGeometry* shape_instance; }; Device::RTPrimitive ISPCDevice::rtNewShapePrimitive(Device::RTShape shape_i, Device::RTMaterial material_i, const float* transform) { ISPCNormalHandle* shape = castHandle<ISPCNormalHandle>(shape_i,"shape"); ISPCNormalHandle* material = castHandle<ISPCNormalHandle>(material_i,"material"); AffineSpace3f space = transform ? copyFromArray(transform) : AffineSpace3f(one); return (Device::RTPrimitive) new PrimitiveHandle(shape->instance,NULL,material->instance,space); } Device::RTPrimitive ISPCDevice::rtNewLightPrimitive(Device::RTLight light_i, Device::RTMaterial material_i, const float* transform) { ISPCNormalHandle* light = castHandle<ISPCNormalHandle>(light_i,"light"); ISPCRef material = NULL; if (material_i) material = castHandle<ISPCNormalHandle>(material_i,"material")->instance; AffineSpace3f space = transform ? copyFromArray(transform) : AffineSpace3f(one); return (Device::RTPrimitive) new PrimitiveHandle(NULL,light->instance,material,space); } Device::RTPrimitive ISPCDevice::rtTransformPrimitive(Device::RTPrimitive primitive, const float* transform) { PrimitiveHandle* prim = dynamic_cast<PrimitiveHandle*>((_RTHandle*)primitive); AffineSpace3f space = transform ? copyFromArray(transform) : AffineSpace3f(one); return (Device::RTPrimitive) new PrimitiveHandle(prim->shape,prim->light,prim->material,space * prim->transform); } void calculateSize(PrimitiveHandle* prim, size_t& numTriangles, size_t& numVertices, size_t& numLights) { if (!prim) return; if (prim->shape) { numVertices += ispc::Shape__getNumVertices(prim->shape.ptr); numTriangles += ispc::Shape__getNumTriangles(prim->shape.ptr); } else if (prim->light) { numLights++; if (ISPCRef shape = ispc::Light__shape(prim->light.ptr)) { numVertices += ispc::Shape__getNumVertices(shape.ptr); numTriangles += ispc::Shape__getNumTriangles(shape.ptr); } } else throw std::runtime_error("invalid primitive"); } BBox3f extractTriangles(PrimitiveHandle* prim, ISPCRef* instances, size_t& numInstances, RTCTriangle* triangles, size_t& numTriangles, Vec3fa* vertices, size_t& numVertices, ISPCRef* allLights, size_t& numAllLights, ISPCRef* envLights, size_t& numEnvLights) { BBox3f bounds = empty; if (!prim) return bounds; /* extract geometry */ if (prim->shape) { ISPCRef shape = ispc::Shape__transform(prim->shape.ptr, (ispc::vec3f&)prim->transform.l.vx, (ispc::vec3f&)prim->transform.l.vy, (ispc::vec3f&)prim->transform.l.vz, (ispc::vec3f&)prim->transform.p); Vec3fa lower,upper; ispc::Shape__extract(shape.ptr,numInstances, (ispc::RTCTriangle*)triangles,(int&)numTriangles, (ispc::RTCVertex *)vertices ,(int&)numVertices, (ispc::vec3f&)lower,(ispc::vec3f&)upper); instances[numInstances++] = ispc::Instance__new(shape.ptr,prim->material.ptr,NULL); bounds.grow(BBox3f(lower,upper)); } /* extract lights */ else if (prim->light) { ISPCRef light = ispc::Light__transform(prim->light.ptr, (ispc::vec3f&)prim->transform.l.vx, (ispc::vec3f&)prim->transform.l.vy, (ispc::vec3f&)prim->transform.l.vz, (ispc::vec3f&)prim->transform.p); allLights[numAllLights++] = light; if (ispc::Light__getType(light.ptr) & ispc::ENV_LIGHT) envLights[numEnvLights++] = light; if (ISPCRef shape = ispc::Light__shape(light.ptr)) { Vec3fa lower,upper; ispc::Shape__extract(shape.ptr,numInstances, (ispc::RTCTriangle*)triangles,(int&)numTriangles, (ispc::RTCVertex *)vertices ,(int&)numVertices, (ispc::vec3f&)lower,(ispc::vec3f&)upper); instances[numInstances++] = ispc::Instance__new(shape.ptr,prim->material.ptr,light.ptr); bounds.grow(BBox3f(lower,upper)); } } else throw std::runtime_error("invalid primitive"); return bounds; } class SceneHandle : public _RTHandle { ALIGNED_CLASS; public: SceneHandle () : accelTy("default"), builderTy("default"), traverserTy("default"), instance(NULL) {} ~SceneHandle () { for (size_t i=0; i<prims.size(); i++) if (prims[i]) prims[i]->decRef(); } void set(const std::string& property, const Variant& data) { if (property == "accel" ) accelTy = data.getString(); else if (property == "builder" ) builderTy = data.getString(); else if (property == "traverser") traverserTy = data.getString(); } void set(size_t slot, PrimitiveHandle* prim) { if (slot >= prims.size()) { prims.resize(slot+1); modified.resize(slot+1); } if (prims[slot]) prims[slot]->decRef(); prims[slot] = prim; if (prims[slot]) prims[slot]->incRef(); modified[slot] = true; } public: std::string accelTy; std::string builderTy; std::string traverserTy; ISPCRef instance; std::vector<PrimitiveHandle*> prims; std::vector<bool> modified; }; class FlatSceneHandle : public SceneHandle { ALIGNED_CLASS; public: void create() { /* count number of vertices and triangles */ size_t numAllocatedTriangles = 0; size_t numAllocatedVertices = 0; size_t numAllocatedLights = 0; size_t numAllocatedInstances = prims.size(); for (size_t i=0; i<prims.size(); i++) calculateSize(prims[i],numAllocatedTriangles,numAllocatedVertices,numAllocatedLights); /* allocate triangle buffers */ size_t numInstances = 0; size_t numTriangles = 0; size_t numVertices = 0; size_t numAllLights = 0; size_t numEnvLights = 0; RTCGeometry* mesh = rtcNewTriangleMesh (numAllocatedTriangles, numAllocatedVertices,accelTy.c_str()); RTCTriangle* triangles = (RTCTriangle*) rtcMapTriangleBuffer(mesh); Vec3fa* positions = (Vec3fa* ) rtcMapPositionBuffer(mesh); ISPCRef* instances = new ISPCRef[numAllocatedInstances]; ISPCRef* allLights = new ISPCRef[numAllocatedLights]; ISPCRef* envLights = new ISPCRef[numAllocatedLights]; /* extract all primitives */ BBox3f bounds = empty; for (size_t i=0; i<prims.size(); i++) bounds.grow(extractTriangles(prims[i], instances,numInstances, triangles,numTriangles,positions,numVertices, allLights,numAllLights, envLights,numEnvLights)); if (numTriangles > numAllocatedTriangles) throw std::runtime_error("internal error"); if (numVertices > numAllocatedVertices ) throw std::runtime_error("internal error"); if (numAllLights > numAllocatedLights ) throw std::runtime_error("internal error"); if (numEnvLights > numAllocatedLights ) throw std::runtime_error("internal error"); if (numInstances > numAllocatedInstances) throw std::runtime_error("internal error"); rtcSetApproxBounds(mesh, (float*)&bounds.lower, (float*)&bounds.upper); rtcUnmapTriangleBuffer(mesh); rtcUnmapPositionBuffer(mesh); rtcBuildAccel(mesh, builderTy.c_str()); instance = ispc::Scene__new(mesh,(void*)traverserTy.c_str(), numAllLights, (void**) allLights, numEnvLights, (void**) envLights, numInstances, (void**) instances); } }; class InstancingSceneHandle : public SceneHandle { ALIGNED_CLASS; public: void create() { /*! create list of lights and shapes */ std::vector<ISPCRef> allLights; std::vector<ISPCRef> envLights; std::vector<ISPCRef> instances; RTCGeometry* objs = rtcNewVirtualGeometry(prims.size(),"default"); for (size_t i=0; i<prims.size(); i++) { PrimitiveHandle* prim = prims[i]; if (!prim) continue; if (prim->light) { ISPCRef light = ispc::Light__transform(prim->light.ptr, (ispc::vec3f&)prim->transform.l.vx, (ispc::vec3f&)prim->transform.l.vy, (ispc::vec3f&)prim->transform.l.vz, (ispc::vec3f&)prim->transform.p); allLights.push_back(light); if (ispc::Light__getType(light.ptr) & ispc::ENV_LIGHT) envLights.push_back(light); } if (prim->shape) { instances.push_back(ispc::Instance__new(prim->shape.ptr,prim->material.ptr,NULL)); RTCGeometry* geom = prim->getShapeInstance(); BBox3f bounds; rtcGetBounds(geom,&bounds.lower.x,&bounds.upper.x); Array12f array = copyToArray(prim->transform); rtcSetVirtualGeometryUserData (objs, i, i, 0, prim->shadowMask); rtcSetVirtualGeometryBounds(objs, i, &bounds.lower.x, &bounds.upper.x, (RTCTransformation*) (float*) array); #if defined (__ISPC_TARGET_SSE__) RTCIntersector4* intersector4 = rtcQueryIntersector4(geom,"default.default"); rtcSetVirtualGeometryIntersector4(objs,i,intersector4); #elif defined (__ISPC_TARGET_AVX__) RTCIntersector8* intersector8 = rtcQueryIntersector8(geom,"default.default"); rtcSetVirtualGeometryIntersector8(objs,i,intersector8); #elif defined (__ISPC_TARGET_MIC__) RTCIntersector16* intersector16 = rtcQueryIntersector16(geom,"default.default"); rtcSetVirtualGeometryIntersector16(objs,i,intersector16); #endif } } rtcBuildAccel(objs, "objectsplit"); instance = ispc::Scene__new(objs,(void*)"default.default", allLights.size(), allLights.size() ? (void**)&allLights.front() : NULL, envLights.size(), envLights.size() ? (void**)&envLights.front() : NULL, instances.size(), instances.size() ? (void**)&instances.front() : NULL); } }; Device::RTScene ISPCDevice::rtNewScene(const char* type) { if (!strcmp(type,"default" )) return (Device::RTScene) new FlatSceneHandle; else if (!strcmp(type,"flat" )) return (Device::RTScene) new FlatSceneHandle; else if (!strcmp(type,"twolevel")) return (Device::RTScene) new InstancingSceneHandle; else throw std::runtime_error("unknown scene type: "+std::string(type)); } void ISPCDevice::rtSetPrimitive(RTScene hscene, size_t slot, RTPrimitive hprim) { SceneHandle* scene = castHandle<SceneHandle>(hscene,"scene"); if (hprim == NULL) { scene->set(slot,NULL); return; } PrimitiveHandle* prim = dynamic_cast<PrimitiveHandle*>((_RTHandle*)hprim); scene->set(slot,prim); } Device::RTToneMapper ISPCDevice::rtNewToneMapper(const char* type) { if (!strcasecmp(type,"default")) return (Device::RTToneMapper) new ISPCCreateHandle<DefaultToneMapper>; else throw std::runtime_error("unknown tonemapper type: "+std::string(type)); } Device::RTRenderer ISPCDevice::rtNewRenderer(const char* type) { if (!strcasecmp(type,"debug" )) return (Device::RTRenderer) new ISPCCreateHandle<DebugRenderer>; else if (!strcasecmp(type,"pathtracer")) return (Device::RTRenderer) new ISPCCreateHandle<PathTracer>; else throw std::runtime_error("unknown renderer type: " + std::string(type)); } Device::RTFrameBuffer ISPCDevice::rtNewFrameBuffer(const char* type, size_t width, size_t height, size_t buffers, void** ptrs) { if (!strcasecmp(type,"RGB_FLOAT32")) return (Device::RTFrameBuffer) new ISPCConstHandle(ispc::SwapChainRGBFloat32__new(width,height,buffers,(void**)ptrs)); else if (!strcasecmp(type,"RGBA8" )) return (Device::RTFrameBuffer) new ISPCConstHandle(ispc::SwapChainRGBA8__new(width,height,buffers,(void**)ptrs)); #if !defined(__MIC__) else if (!strcasecmp(type,"RGB8" )) return (Device::RTFrameBuffer) new ISPCConstHandle(ispc::SwapChainRGB8__new(width,height,buffers,(void**)ptrs)); #endif else throw std::runtime_error("unknown framebuffer type: "+std::string(type)); } void* ISPCDevice::rtMapFrameBuffer(Device::RTFrameBuffer swapchain_i, int bufID) { ISPCConstHandle* swapchain = castHandle<ISPCConstHandle>(swapchain_i,"framebuffer"); return ispc::SwapChain__map(swapchain->instance.ptr,bufID); } void ISPCDevice::rtUnmapFrameBuffer(Device::RTFrameBuffer swapchain_i, int bufID) { ISPCConstHandle* swapchain = castHandle<ISPCConstHandle>(swapchain_i,"framebuffer"); ispc::SwapChain__unmap(swapchain->instance.ptr); } void ISPCDevice::rtSwapBuffers(Device::RTFrameBuffer swapchain_i) { ISPCConstHandle* swapchain = castHandle<ISPCConstHandle>(swapchain_i,"framebuffer"); ispc::SwapChain__swap(swapchain->instance.ptr); } void ISPCDevice::rtIncRef(Device::RTHandle handle) { ((_RTHandle*)handle)->incRef(); } void ISPCDevice::rtDecRef(Device::RTHandle handle) { ((_RTHandle*)handle)->decRef(); } /******************************************************************* setting of parameters *******************************************************************/ void ISPCDevice::rtSetBool1(Device::RTHandle handle, const char* property, bool x) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x)); } void ISPCDevice::rtSetBool2(Device::RTHandle handle, const char* property, bool x, bool y) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y)); } void ISPCDevice::rtSetBool3(Device::RTHandle handle, const char* property, bool x, bool y, bool z) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y,z)); } void ISPCDevice::rtSetBool4(Device::RTHandle handle, const char* property, bool x, bool y, bool z, bool w) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y,z,w)); } void ISPCDevice::rtSetInt1(Device::RTHandle handle, const char* property, int x) { Lock<MutexSys> lock(mutex); if (!property) throw std::runtime_error("invalid property"); if (!handle ) { if (!strcmp(property,"serverID" )) g_serverID = x; else if (!strcmp(property,"serverCount")) g_serverCount = x; return; } ((_RTHandle*)handle)->set(property,Variant(x)); } void ISPCDevice::rtSetInt2(Device::RTHandle handle, const char* property, int x, int y) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y)); } void ISPCDevice::rtSetInt3(Device::RTHandle handle, const char* property, int x, int y, int z) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y,z)); } void ISPCDevice::rtSetInt4(Device::RTHandle handle, const char* property, int x, int y, int z, int w) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y,z,w)); } void ISPCDevice::rtSetFloat1(Device::RTHandle handle, const char* property, float x) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x)); } void ISPCDevice::rtSetFloat2(Device::RTHandle handle, const char* property, float x, float y) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y)); } void ISPCDevice::rtSetFloat3(Device::RTHandle handle, const char* property, float x, float y, float z) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y,z)); } void ISPCDevice::rtSetFloat4(Device::RTHandle handle, const char* property, float x, float y, float z, float w) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(x,y,z,w)); } void ISPCDevice::rtSetArray(Device::RTHandle handle_i, const char* property, const char* type, Device::RTData data_i, size_t size, size_t stride, size_t ofs) { ConstHandle<Data>* data = castHandle<ConstHandle<Data> >(data_i,"data"); _RTHandle* handle = (_RTHandle*)handle_i; if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); if (!strcasecmp(type,"bool1" )) handle->set(property,Variant(data->instance,Variant::BOOL1 ,size,stride == size_t(-1) ? 1*sizeof(bool ) : stride, ofs)); else if (!strcasecmp(type,"bool2" )) handle->set(property,Variant(data->instance,Variant::BOOL2 ,size,stride == size_t(-1) ? 2*sizeof(bool ) : stride, ofs)); else if (!strcasecmp(type,"bool3" )) handle->set(property,Variant(data->instance,Variant::BOOL3 ,size,stride == size_t(-1) ? 3*sizeof(bool ) : stride, ofs)); else if (!strcasecmp(type,"bool4" )) handle->set(property,Variant(data->instance,Variant::BOOL4 ,size,stride == size_t(-1) ? 4*sizeof(bool ) : stride, ofs)); else if (!strcasecmp(type,"int1" )) handle->set(property,Variant(data->instance,Variant::INT1 ,size,stride == size_t(-1) ? 1*sizeof(int ) : stride, ofs)); else if (!strcasecmp(type,"int2" )) handle->set(property,Variant(data->instance,Variant::INT2 ,size,stride == size_t(-1) ? 2*sizeof(int ) : stride, ofs)); else if (!strcasecmp(type,"int3" )) handle->set(property,Variant(data->instance,Variant::INT3 ,size,stride == size_t(-1) ? 3*sizeof(int ) : stride, ofs)); else if (!strcasecmp(type,"int4" )) handle->set(property,Variant(data->instance,Variant::INT4 ,size,stride == size_t(-1) ? 4*sizeof(int ) : stride, ofs)); else if (!strcasecmp(type,"float1")) handle->set(property,Variant(data->instance,Variant::FLOAT1,size,stride == size_t(-1) ? 1*sizeof(float) : stride, ofs)); else if (!strcasecmp(type,"float2")) handle->set(property,Variant(data->instance,Variant::FLOAT2,size,stride == size_t(-1) ? 2*sizeof(float) : stride, ofs)); else if (!strcasecmp(type,"float3")) handle->set(property,Variant(data->instance,Variant::FLOAT3,size,stride == size_t(-1) ? 3*sizeof(float) : stride, ofs)); else if (!strcasecmp(type,"float4")) handle->set(property,Variant(data->instance,Variant::FLOAT4,size,stride == size_t(-1) ? 4*sizeof(float) : stride, ofs)); else throw std::runtime_error("unknown array type: "+std::string(type)); } void ISPCDevice::rtSetString(Device::RTHandle handle, const char* property, const char* str) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(str)); } void ISPCDevice::rtSetImage(Device::RTHandle handle, const char* property, Device::RTImage img) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); if (ISPCConstHandle* image = dynamic_cast<ISPCConstHandle*>((_RTHandle*)img)) { if (!image->instance) throw std::runtime_error("invalid image value"); ((_RTHandle*)handle)->set(property,Variant(Variant::IMAGE,image->instance)); } else throw std::runtime_error("invalid image handle"); } void ISPCDevice::rtSetTexture(Device::RTHandle handle, const char* property, Device::RTTexture tex) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ISPCNormalHandle* texture = castHandle<ISPCNormalHandle>(tex,"texture"); ((_RTHandle*)handle)->set(property,Variant(Variant::TEXTURE,texture->instance)); } void ISPCDevice::rtSetTransform(Device::RTHandle handle, const char* property, const float* transform) { Lock<MutexSys> lock(mutex); if (!handle ) throw std::runtime_error("invalid handle" ); if (!property) throw std::runtime_error("invalid property"); ((_RTHandle*)handle)->set(property,Variant(copyFromArray(transform))); } void ISPCDevice::rtClear(Device::RTHandle handle) { Lock<MutexSys> lock(mutex); if (!handle) throw std::runtime_error("invalid handle"); ((_RTHandle*)handle)->clear(); } void ISPCDevice::rtCommit(Device::RTHandle handle) { Lock<MutexSys> lock(mutex); if (!handle) throw std::runtime_error("invalid handle"); ((_RTHandle*)handle)->create(); } /******************************************************************* render call *******************************************************************/ #if ASYNC_RENDER ISPCNormalHandle* g_renderer = NULL; ISPCNormalHandle* g_camera = NULL; SceneHandle* g_scene = NULL; ISPCNormalHandle* g_toneMapper = NULL; ISPCConstHandle* g_swapchain = NULL; bool g_accumulate = false; void renderThreadFunction(void* ptr) try { renderBarrier.wait(); while (true) { renderBarrier.wait(); if (g_terminate) break; renderBarrier.wait(); ispc::Renderer__renderFrameInit(g_renderer->instance.ptr,g_scene->instance.ptr); double t0 = getSeconds(); int numRays = ispc::Renderer__renderFrame(g_renderer->instance.ptr,g_camera->instance.ptr,g_scene->instance.ptr,g_toneMapper->instance.ptr,g_swapchain->instance.ptr,g_accumulate); double dt = getSeconds() - t0; printf("render %3.2f fps, %.2f ms, %3.3f mrps\n",1.0f/dt,dt*1000.0f,numRays/dt*1E-6); flush(std::cout); } } catch (const std::exception& e) { std::cout << "Error: " << e.what() << std::endl; exit(1); } #endif void ISPCDevice::rtRenderFrame(Device::RTRenderer renderer_i, Device::RTCamera camera_i, Device::RTScene scene_i, Device::RTToneMapper toneMapper_i, Device::RTFrameBuffer swapchain_i, int accumulate) { Lock<MutexSys> lock(mutex); #if ASYNC_RENDER renderBarrier.wait(); g_renderer = castHandle<ISPCNormalHandle>(renderer_i ,"renderer" ); g_camera = castHandle<ISPCNormalHandle>(camera_i ,"camera" ); g_scene = castHandle<SceneHandle> (scene_i ,"scene" ); g_toneMapper = castHandle<ISPCNormalHandle>(toneMapper_i ,"tonemapper"); g_swapchain = castHandle<ISPCConstHandle> (swapchain_i,"framebuffer"); g_accumulate = accumulate; renderBarrier.wait(); #else ISPCNormalHandle* renderer = castHandle<ISPCNormalHandle>(renderer_i ,"renderer" ); ISPCNormalHandle* camera = castHandle<ISPCNormalHandle>(camera_i ,"camera" ); SceneHandle* scene = castHandle<SceneHandle> (scene_i ,"scene" ); ISPCNormalHandle* toneMapper = castHandle<ISPCNormalHandle>(toneMapper_i ,"tonemapper"); ISPCConstHandle* swapchain = castHandle<ISPCConstHandle> (swapchain_i,"framebuffer"); ispc::Renderer__renderFrameInit(renderer->instance.ptr,scene->instance.ptr); double t0 = getSeconds(); int numRays = ispc::Renderer__renderFrame(renderer->instance.ptr,camera->instance.ptr,scene->instance.ptr,toneMapper->instance.ptr,swapchain->instance.ptr,accumulate); double dt = getSeconds() - t0; printf("render %3.2f fps, %.2f ms, %3.3f mrps\n",1.0f/dt,dt*1000.0f,numRays/dt*1E-6); flush(std::cout); #endif } bool ISPCDevice::rtPick(Device::RTCamera camera_i, float x, float y, Device::RTScene scene_i, float& px, float& py, float& pz) { Lock<MutexSys> lock(mutex); /* extract objects from handles */ ISPCNormalHandle* camera = castHandle<ISPCNormalHandle>(camera_i,"camera"); SceneHandle* scene = castHandle<SceneHandle> (scene_i ,"scene" ); /* trace ray */ Vector3f p; bool hit = ispc::Renderer__pick(camera->instance.ptr,x,y,scene->instance.ptr,(ispc::vec3f&)p); px = p.x; py = p.y; pz = p.z; return hit; } }
45.070407
185
0.641802
mbdriscoll
0f69e5708189f5495a4218bb1e77140215dbecbc
1,439
hpp
C++
cpp/godot-cpp/include/gen/DampedSpringJoint2D.hpp
GDNative-Gradle/proof-of-concept
162f467430760cf959f68f1638adc663fd05c5fd
[ "MIT" ]
1
2021-03-16T09:51:00.000Z
2021-03-16T09:51:00.000Z
cpp/godot-cpp/include/gen/DampedSpringJoint2D.hpp
GDNative-Gradle/proof-of-concept
162f467430760cf959f68f1638adc663fd05c5fd
[ "MIT" ]
null
null
null
cpp/godot-cpp/include/gen/DampedSpringJoint2D.hpp
GDNative-Gradle/proof-of-concept
162f467430760cf959f68f1638adc663fd05c5fd
[ "MIT" ]
null
null
null
#ifndef GODOT_CPP_DAMPEDSPRINGJOINT2D_HPP #define GODOT_CPP_DAMPEDSPRINGJOINT2D_HPP #include <gdnative_api_struct.gen.h> #include <stdint.h> #include <core/CoreTypes.hpp> #include <core/Ref.hpp> #include "Joint2D.hpp" namespace godot { class DampedSpringJoint2D : public Joint2D { struct ___method_bindings { godot_method_bind *mb_get_damping; godot_method_bind *mb_get_length; godot_method_bind *mb_get_rest_length; godot_method_bind *mb_get_stiffness; godot_method_bind *mb_set_damping; godot_method_bind *mb_set_length; godot_method_bind *mb_set_rest_length; godot_method_bind *mb_set_stiffness; }; static ___method_bindings ___mb; public: static void ___init_method_bindings(); static inline const char *___get_class_name() { return (const char *) "DampedSpringJoint2D"; } static inline Object *___get_from_variant(Variant a) { godot_object *o = (godot_object*) a; return (o) ? (Object *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, o) : nullptr; } // enums // constants static DampedSpringJoint2D *_new(); // methods real_t get_damping() const; real_t get_length() const; real_t get_rest_length() const; real_t get_stiffness() const; void set_damping(const real_t damping); void set_length(const real_t length); void set_rest_length(const real_t rest_length); void set_stiffness(const real_t stiffness); }; } #endif
26.163636
245
0.789437
GDNative-Gradle
0f6a22b643f4ad1210e6ebd33e8ff0b62d56941d
1,479
cpp
C++
src/scomp/ast/expression.cpp
agatan/scomp
24965bf78193a45cea6050e9f7db400c640012b9
[ "MIT" ]
1
2017-10-11T06:22:01.000Z
2017-10-11T06:22:01.000Z
src/scomp/ast/expression.cpp
agatan/scomp
24965bf78193a45cea6050e9f7db400c640012b9
[ "MIT" ]
null
null
null
src/scomp/ast/expression.cpp
agatan/scomp
24965bf78193a45cea6050e9f7db400c640012b9
[ "MIT" ]
null
null
null
#include <scomp/ast/expression.hpp> #include <boost/format.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/range/adaptor/transformed.hpp> #include <scomp/ast/statement.hpp> namespace scomp { namespace ast { namespace node { std::string literal_expr::to_string() const { struct visitor { std::string operator()(int i) const { return std::to_string(i); } std::string operator()(bool b) const { return b ? "true" : "false"; } }; return boost::apply_visitor(visitor{}, value); } std::string binop_expr::to_string() const { return (boost::format("%s %s %s") % stringize(lhs) % op % stringize(rhs)).str(); } std::string apply_expr::to_string() const { return (boost::format("%s(%s)") % stringize(callee) % boost::algorithm::join( args | boost::adaptors::transformed( [](auto const& e) { return stringize(e); }), ", ")) .str(); } std::string block_expr::to_string() const { return (boost::format("{ %s }") % boost::algorithm::join( body | boost::adaptors::transformed( [](auto const& e) { return stringize(e); }), "; ")) .str(); } } // namespace node } // namespace ast } // namespace scomp
29
88
0.505747
agatan
0f6b243297e2dccdb90e39622fe1c93511270781
4,454
cpp
C++
Luna/app/postEffect/screenCaptureTask.cpp
MetroGirl/Src_LUNA
f59befa48bd79ab3a8bf71e3c5b975c8e76e6b79
[ "Artistic-2.0" ]
3
2015-04-09T10:09:38.000Z
2018-08-10T13:15:48.000Z
Luna/app/postEffect/screenCaptureTask.cpp
MetroGirl/Src_LUNA
f59befa48bd79ab3a8bf71e3c5b975c8e76e6b79
[ "Artistic-2.0" ]
null
null
null
Luna/app/postEffect/screenCaptureTask.cpp
MetroGirl/Src_LUNA
f59befa48bd79ab3a8bf71e3c5b975c8e76e6b79
[ "Artistic-2.0" ]
null
null
null
#include "stdafx.h" #include "screenCaptureTask.h" #include "app/renderer.h" #include "app/renderPass/postEffectPass.h" namespace luna{ LUNA_IMPLEMENT_CONCRETE(luna::ScreenCaptureTask); ScreenCaptureTask::ScreenCaptureTask() : mResourcePtr(nullptr) { } ScreenCaptureTask::~ScreenCaptureTask() { } bool ScreenCaptureTask::load() { if (!mResourcePtr){ mResourcePtr = ResourceManager::instance().load<ResourceLua>((wstring(L"data/script/screenCapture/") + getScene().getName() + wstring(L".lua")).c_str()); } if (!mResourcePtr){ return true;// たぶんリソースがない。終わったことにしておく。 } if (mResourcePtr && mResourcePtr->isValid()){ return true; } return false; } void ScreenCaptureTask::fixup() { updateEffectTbl(); } void ScreenCaptureTask::update() { const f32 ratio = getRatio(); if (!mResourcePtr){ return ; } if (mResourcePtr->isReloaded()) { updateEffectTbl(); } auto& rpc = Renderer::instance().getContext(); for (auto& effect : mEffectTbl){ const f32 sceneRatio = getScene().getCurrentFrameRatio(); if (effect.consumed){ continue; } if (effect.timing > ratio){ continue; } effect.consumed = true; auto& dc = rpc.mContext; { ID3D11RenderTargetView* rtvTbl[] = { rpc.mFrameBufferTbl[FrameBufferType_CaptureTexture0 + effect.slot].getColorRTV().Get() }; GraphicsDevice::instance().getDeviceContext().OMSetRenderTargets(1, rtvTbl, nullptr); ID3D11ShaderResourceView* srvTbl[] = { rpc.mFrameBufferTbl[FrameBufferType_SceneTexture0].getColorSRV().Get(), rpc.mFrameBufferTbl[FrameBufferType_SceneTexture1].getColorSRV().Get(), rpc.mFrameBufferTbl[FrameBufferType_SceneTexture2].getColorSRV().Get(), rpc.mFrameBufferTbl[FrameBufferType_SceneTexture3].getColorSRV().Get(), rpc.mFrameBufferTbl[FrameBufferType_SceneTexture0].getDepthSRV().Get(), rpc.mFrameBufferTbl[FrameBufferType_SceneTexture1].getDepthSRV().Get(), rpc.mFrameBufferTbl[FrameBufferType_SceneTexture2].getDepthSRV().Get(), rpc.mFrameBufferTbl[FrameBufferType_SceneTexture3].getDepthSRV().Get(), }; dc.PSSetShaderResources(0, _countof(srvTbl), srvTbl); auto techniquePtr = rpc.mShaderMap[L"posteffect"]->findTechnique(effect.technique.c_str()); auto& context = rpc.mContext; context.IASetVertexBuffers(0, 0, nullptr, nullptr, nullptr); context.IASetIndexBuffer(nullptr, (DXGI_FORMAT)0, 0); context.IASetInputLayout(nullptr); context.IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); context.VSSetShader(techniquePtr->mVS.shaderPtr, nullptr, 0); context.HSSetShader(techniquePtr->mHS.shaderPtr, nullptr, 0); context.DSSetShader(techniquePtr->mDS.shaderPtr, nullptr, 0); context.GSSetShader(techniquePtr->mGS.shaderPtr, nullptr, 0); context.CSSetShader(techniquePtr->mCS.shaderPtr, nullptr, 0); context.PSSetShader(techniquePtr->mPS.shaderPtr, nullptr, 0); context.Draw(3, 0); context.VSSetShader(nullptr, nullptr, 0); context.HSSetShader(nullptr, nullptr, 0); context.DSSetShader(nullptr, nullptr, 0); context.GSSetShader(nullptr, nullptr, 0); context.CSSetShader(nullptr, nullptr, 0); context.PSSetShader(nullptr, nullptr, 0); memset(srvTbl, 0, sizeof(srvTbl)); dc.PSSetShaderResources(0, _countof(srvTbl), srvTbl); } } } void ScreenCaptureTask::fixedUpdate() { const f32 ratio = getRatio(); } void ScreenCaptureTask::draw(Renderer& renderer) { const f32 ratio = getRatio(); } void ScreenCaptureTask::onRender(const luna::TypeInfo& type, RenderPassContext& rpc, Renderer& renderer, u32& arg) { } void ScreenCaptureTask::reset() { } void ScreenCaptureTask::updateEffectTbl() { if (!mResourcePtr){ return; } mEffectTbl.clear(); auto& L = mResourcePtr->getContext(); lua_getglobal(L, "Entries"); lua_pushnil(L); while (lua_next(L, -2)) { lua_pushnil(L); f32 timing = 0; u32 slot = 0; const c8* technique = "copyAsIs"; while (lua_next(L, -2)){ auto const* a = lua_tostring(L, -2); if (strcmp(a, "Timing") == 0){ timing = (f32)lua_tonumber(L, -1); } else if (strcmp(a, "Slot") == 0){ slot = (u32)lua_tonumber(L, -1); } lua_pop(L, 1); } EffectInfo info; info.timing = timing; info.slot = slot; info.consumed = false; info.technique = technique; mEffectTbl.push_back(info); lua_pop(L, 1); } lua_pop(L, 1); } }
26.35503
156
0.69533
MetroGirl
0f6bf355518a3d58829f8c1df8efbf1745480abd
40
cpp
C++
Engine/Code/Engine/Core/EngineCommon.cpp
cugone/Abrams2022
54efe5fdd7d2d9697f005ee45a171ecea68d0df8
[ "MIT" ]
1
2020-07-14T06:58:50.000Z
2020-07-14T06:58:50.000Z
Engine/Code/Engine/Core/EngineCommon.cpp
cugone/Abrams2022
54efe5fdd7d2d9697f005ee45a171ecea68d0df8
[ "MIT" ]
20
2021-11-29T14:09:33.000Z
2022-03-26T20:12:44.000Z
Engine/Code/Engine/Core/EngineCommon.cpp
cugone/Abrams2022
54efe5fdd7d2d9697f005ee45a171ecea68d0df8
[ "MIT" ]
2
2019-05-01T21:49:33.000Z
2021-04-01T08:22:21.000Z
#include "Engine/Core/EngineCommon.hpp"
20
39
0.8
cugone
0f6d34595c5014f2cf63ea5fc18e9d10e5902e98
12,053
cpp
C++
lib/var.cpp
scottshotgg/express
b4a2644154a731fc7486f77757deac035b18a8f3
[ "Apache-2.0" ]
3
2018-08-10T19:41:53.000Z
2020-02-10T18:18:25.000Z
lib/var.cpp
scottshotgg/express
b4a2644154a731fc7486f77757deac035b18a8f3
[ "Apache-2.0" ]
null
null
null
lib/var.cpp
scottshotgg/express
b4a2644154a731fc7486f77757deac035b18a8f3
[ "Apache-2.0" ]
null
null
null
#include <iostream> #include <list> #include <map> #include <string> using namespace std; enum varType { pointerType, intType, boolType, charType, floatType, stringType, structType, objectType, arrayType }; class var { private: varType type; void* data; public: void deallocate() { switch (type) { case intType: { // cout << "int decons; Type: " << type << " Value: " << *(int *)data // << " Pointer: " << data << endl; delete (int *)data; break; } case stringType: { // cout << "string decons; Type: " << type << " Value: " << *(string // *)data // << " Pointer: " << data << endl; // delete (string *)data; break; } case boolType: { // cout << "bool decons; Type: " << type << " Value: " << *(bool *)data // << " Pointer: " << data << endl; delete (bool *)data; break; } case charType: { // cout << "char decons; Type: " << type << " Value: " << *(char *)data // << " Pointer: " << data << endl; delete (char *)data; break; } case floatType: { // cout << "float decons; Type: " << type << " Value: " << *(float *)data // << " Pointer: " << data << endl; delete (float *)data; break; } case objectType: { // cout << "object decons; Type: " << type << " Value: " << *this // << " Pointer: " << data << endl; delete (map<string, var> *)data; break; } default: printf("don't know how to deallocate; Type: %u Value: %p\n", type, data); } } // var(const var &value) { // type = value.Type(); // switch (type) { // // Not sure how to deal with this for now // // case pointerType: // case intType: // int* dr = new int(*(int*)value.Value()); // } // } var(void) : type(objectType), data(new map<string, var>) {} var(void *value) : type(pointerType), data(value) {} var(int value) : type(intType), data(new int(value)) { // cout << "int cons; Type: " << type << " Value: " << value // << " Pointer: " << data << endl; } var(bool value) : type(boolType), data(new bool(value)) { // cout << "bool cons; Type: " << type << " Value: " << value // << " Pointer: " << data << endl; } var(char value) : type(charType), data(new char(value)) {} var(float value) : type(floatType), data(new float(value)) { // cout << "float cons; Type: " << type << " Value: " << value // << " Pointer: " << data << endl; } var(double value) : type(floatType), data(new float(value)) { // cout << "float cons; Type: " << type << " Value: " << value // << " Pointer: " << data << endl; } // all string literal constructions are going in here var(const char *value) : type(stringType), data(new string(value)) { // cout << "string cons; Type: " << type << " Value: \"" << value // << "\" Pointer: " << data << endl; } var(string value) : type(stringType), data(new string(value)) { // cout << "string cons; Type: " << type << " Value: \"" << value // << "\" Pointer: " << data << endl; } var(map<string, var> propMap) : type(objectType), data(new map<string, var>(propMap)) { // cout << "object cons; Type: " << type << " Value: \"" // << "\" Pointer: " << data << endl; // data = new map<string,var>(propMap); } var(initializer_list<var> propList) : type(objectType) { // if (propList.size() % 2 != 0) { // //cout << "ERROR: invalid amount of arguments to object" << endl; // exit(9); // } map<string, var> object; int i = 0; var lastItem; for (auto prop : propList) { if (i % 2 == 1) { // TODO: could think about supporting more than string here but that // will involve many more more checks object[*(string *)lastItem.Value()] = prop; } else { lastItem = prop; } i++; } // something weird is happening here.... data = new map<string, var>(object); // FIXME: ... somehow this will work ... // *(map<string, var>*)data = object; } // TODO: will have to do something special here, maybe code generation? // var(struct value) : type(structType), data(&value) {} // TODO: not sure if you can do this with a map, might have to copy everything // over var(map<string, var> value) : type(objectType), data(new map<string, // var>(value)) { // ////printf("obj cons\n"); // } // FIXME: might take this out, kind of unsafe var(varType iType, void *iData) : type(iType), data(iData) { // //printf("void*\n"); } varType Type(void) const { return type; } void *Value(void) const { return data; } var &operator[](string attribute) { if (type == objectType) { return (*(map<string, var> *)data)[attribute]; } else { type = objectType; map<string, var> object; object[attribute] = 0; data = (void *)&object; return (*(map<string, var> *)data)[attribute]; } } void operator+=(const int right) { // //printf("+= var int\n"); *(int *)data += right; } void operator+=(const double right) { // printf("+= var int\n"); *(float *)data += right; } void operator+=(const string right) { // printf("+= var int\n"); *(string *)data = *(string *)data + right; } void operator+=(const char *right) { // printf("+= var int\n"); *(string *)data = *(string *)data + right; } void operator+=(const bool right) { // printf("+= var int\n"); *(bool *)data = *(bool *)data || right; } void operator-=(const int right) { // //printf("+= var int\n"); *(int *)data -= right; } void operator-=(const double right) { // //printf("+= var int\n"); *(float *)data -= right; } void operator-=(const string right) { // //printf("+= var int\n"); *(string *)data += right; } void operator-=(const char *right) { // //printf("+= var int\n"); *(string *)data += right; } void operator-=(const bool right) { // //printf("+= var int\n"); *(bool *)data += right; } int operator*(const var &right) { // //printf("* var var\n"); return *(int *)data * *(int *)right.data; } void operator*=(const bool right) { // //printf("* var var\n"); *(bool *)data = *(bool *)data && right; } void operator=(const int right) { if (type == intType) { *(int *)data = right; } else { // var::~var(); deallocate(); // printf("int cons; Type: %u Value: %p\n", type, data); type = intType; data = new int(right); // *(int*)data = right; } } void operator=(const double right) { if (type == floatType) { *(float *)data = right; } else { // var::~var(); deallocate(); // printf("float cons; Type: %u Value: %p\n", type, data); type = floatType; data = new float(right); // *(float*)data = right; } } void operator=(const char *right) { if (type == stringType) { *(string *)data = right; } else { // var::~var(); deallocate(); // cout << "string cons; Type: " << type << " Value: \"" << right // << "\" Pointer: " << data << endl; type = stringType; data = new string(right); // *(string*)data = right; } } void operator=(const bool right) { if (type == boolType) { *(bool *)data = right; } else { // var::~var(); deallocate(); // printf("bool cons; Type: %u Value: %p\n", type, data); type = boolType; data = new bool(right); // *(bool*)data = right; } } // FIXME: fix this void operator=(initializer_list<var> propList) { deallocate(); // //cout << "object cons; Type: " << type << " Value: " << propList << " // Pointer: " << data << endl; // cout << "object cons; Type: " << type << " Pointer: " << data << endl; type = objectType; data = var(propList).data; // var thing = propList; // //cout << thing << endl; // data = thing.data; } friend ostream &operator<<(ostream &stream, var v) { switch (v.type) { case intType: // //printf("printing int\n"); return stream << *(int *)v.data; case boolType: if (*(bool *)v.data) { return stream << "true"; } return stream << "false"; case charType: return stream << "\"" << *(char *)v.data << "\""; case floatType: return stream << *(float *)v.data; case stringType: // //cout << "printing string" << endl;; return stream << "\"" << *(string *)v.data << "\""; case objectType: { int counter = 0; map<string, var> objectMap = *(map<string, var> *)v.data; stream << "{ "; for (auto property : objectMap) { // stream << property.first << property.second.first << // property.second.second << "\n"; stream << property.first << ": " << property.second; if (counter < objectMap.size() - 1) { stream << ", "; } counter++; } return stream << " }"; } default: printf("wtf to do Type: %u\n", v.type); } return stream; } }; // TODO: for right now, instead of doing the map[string]function to figure out // the value // https://stackoverflow.com/questions/4972795/how-do-i-typecast-with-type-info // https://stackoverflow.com/questions/2136998/using-a-stl-map-of-function-pointer // Integer operations int operator+(const int left, const var &right) { // //printf("+ int var\n"); return left + *(int *)right.Value(); } int operator-(const int left, const var &right) { // //printf("+ int var\n"); return left - *(int *)right.Value(); } int operator*(const int left, const var &right) { // //printf("+ int var\n"); return left * *(int *)right.Value(); } int operator/(const int left, const var &right) { // //printf("+ int var\n"); return left / *(int *)right.Value(); } int operator+=(int left, const var &right) { // printf("+= int var\n"); // //printf("+= int var\n"); return left += *(int *)right.Value(); } int operator+=(const var &left, const var &right) { // //printf("+= var var\n"); return *(int *)left.Value() + *(int *)right.Value(); } bool operator+(const bool left, const var &right) { return left || *(bool *)right.Value(); } // TODO: not sure about this one for now // char operator+(const char left, const var& right) { // return left || *(bool*)right.Value(); // } float operator+(const float left, const var &right) { return left + *(float *)right.Value(); } float operator+(const double left, const var &right) { return left + *(float *)right.Value(); } // String/Char* operations: convert char* to string with all of these functions string operator+(const char *left, const var &right) { return left + *(string *)right.Value(); } var operator+(const var &left, const char *right) { return var(*(string *)left.Value() + right); } // int operator+(const var &left, const var &right) { // //printf("hey its me"); // return *(int*)left.Value() + *(int*)right.Value(); // } // Generic constructor for right side value template <typename T> var operator+(const var &left, T right) { // FIXME: this is kinda inefficient return var(right + left); } // Generic constructor for right side value template <typename T> var operator-(const var &left, T right) { // FIXME: this is kinda inefficient return var(-right + left); } // // Generic constructor for right side value // template <typename T> var operator*(const var &left, T right) { // // FIXME: this is kinda inefficient // cout<<"right "<<right<<endl; // cout<<"left "<<left<<endl; // var thing = right * left; // cout<<"thing"<< thing << endl; // return thing; // } // Generic constructor for right side value template <typename T> var operator/(const var &left, T right) { // FIXME: this is kinda inefficient return var((1 / right) * left); } // };
26.374179
82
0.541608
scottshotgg
0f6e1d2ca7e2d3f7cbab6ab2a290237839e9182b
3,112
cpp
C++
Game/Xerces/src/xercesc/dom/impl/DOMNodeVector.cpp
hackerlank/SourceCode
b702c9e0a9ca5d86933f3c827abb02a18ffc9a59
[ "MIT" ]
4
2021-07-31T13:56:01.000Z
2021-11-13T02:55:10.000Z
Game/Xerces/src/xercesc/dom/impl/DOMNodeVector.cpp
shacojx/SourceCodeGameTLBB
e3cea615b06761c2098a05427a5f41c236b71bf7
[ "MIT" ]
null
null
null
Game/Xerces/src/xercesc/dom/impl/DOMNodeVector.cpp
shacojx/SourceCodeGameTLBB
e3cea615b06761c2098a05427a5f41c236b71bf7
[ "MIT" ]
7
2021-08-31T14:34:23.000Z
2022-01-19T08:25:58.000Z
/* * Copyright 2001-2002,2004 The Apache Software Foundation. * * Licensed 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. */ /* * $Id: DOMNodeVector.cpp 176317 2005-02-21 18:19:45Z cargilld $ */ // // file: DOMNodeVector.cpp // Implementation of class DOMNodeVector. // (Use of STL vector, or equivalent, would have been nice, // but is not available. 'DOMNode *' is the only type // kept in Vectors in this DOM implementation, so this is // a hardwired implementation for that type. // #include "DOMNodeVector.hpp" #include "DOMDocumentImpl.hpp" #include <assert.h> XERCES_CPP_NAMESPACE_BEGIN DOMNodeVector::DOMNodeVector(DOMDocument *doc) { init(doc, 10); } DOMNodeVector::DOMNodeVector(DOMDocument *doc, XMLSize_t size) { init(doc, size); } void DOMNodeVector::init(DOMDocument *doc, XMLSize_t size) { assert(size > 0); //data = new (doc) DOMNode *[size]; data = (DOMNode**) ((DOMDocumentImpl *)doc)->allocate(sizeof(DOMNode*) * size); assert(data != 0); XMLSize_t i; for (i=0; i<size; i++) data[i] = 0; allocatedSize = size; nextFreeSlot = 0; } DOMNodeVector::~DOMNodeVector() { } void DOMNodeVector::addElement(DOMNode *elem) { checkSpace(); data[nextFreeSlot] = elem; ++nextFreeSlot; } void DOMNodeVector::checkSpace() { if (nextFreeSlot == allocatedSize) { XMLSize_t grow = allocatedSize/2; if (grow < 10) grow = 10; XMLSize_t newAllocatedSize = allocatedSize + grow; DOMDocument *doc = data[0]->getOwnerDocument(); //DOMNode **newData = new (doc) DOMNode *[newAllocatedSize]; DOMNode **newData = (DOMNode**) ((DOMDocumentImpl *)doc)->allocate(sizeof(DOMNode*) * newAllocatedSize); assert(newData != 0); for (XMLSize_t i=0; i<allocatedSize; i++) { newData[i] = data[i]; } // delete [] data; // revisit. Can't delete! Recycle? allocatedSize = newAllocatedSize; data = newData; } } void DOMNodeVector::insertElementAt(DOMNode *elem, XMLSize_t index) { XMLSize_t i; assert(index <= nextFreeSlot); checkSpace(); for (i=nextFreeSlot; i>index; --i) { data[i] = data[i-1]; } data[index] = elem; ++nextFreeSlot; } void DOMNodeVector::removeElementAt(XMLSize_t index) { assert(index < nextFreeSlot); for (XMLSize_t i=index; i<nextFreeSlot-1; ++i) { data[i] = data[i+1]; } --nextFreeSlot; } void DOMNodeVector::reset() { nextFreeSlot = 0; } void DOMNodeVector::setElementAt(DOMNode *elem, XMLSize_t index) { assert(index < nextFreeSlot); data[index] = elem; } XERCES_CPP_NAMESPACE_END
24.503937
112
0.67063
hackerlank
0f6e546f36dc8c0ca1221eb76e3f814a8d3a9091
1,403
cpp
C++
tests/test_serialize_file.cpp
xaxousis/toml11
d82814fc86c4afd8ad013239322f83c4788e469f
[ "MIT" ]
null
null
null
tests/test_serialize_file.cpp
xaxousis/toml11
d82814fc86c4afd8ad013239322f83c4788e469f
[ "MIT" ]
null
null
null
tests/test_serialize_file.cpp
xaxousis/toml11
d82814fc86c4afd8ad013239322f83c4788e469f
[ "MIT" ]
null
null
null
#define BOOST_TEST_MODULE "test_serialize_file" #ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include <boost/test/unit_test.hpp> #else #define BOOST_TEST_NO_LIB #include <boost/test/included/unit_test.hpp> #endif #include <toml.hpp> #include <iostream> #include <fstream> BOOST_AUTO_TEST_CASE(test_example) { const auto data = toml::parse("toml/tests/example.toml"); { std::ofstream ofs("tmp1.toml"); ofs << std::setw(80) << data; } auto serialized = toml::parse("tmp1.toml"); { auto& owner = toml::get<toml::table>(serialized.at("owner")); auto& bio = toml::get<std::string>(owner.at("bio")); const auto CR = std::find(bio.begin(), bio.end(), '\r'); if(CR != bio.end()) { bio.erase(CR); } } BOOST_CHECK(data == serialized); } BOOST_AUTO_TEST_CASE(test_fruit) { const auto data = toml::parse("toml/tests/fruit.toml"); { std::ofstream ofs("tmp2.toml"); ofs << std::setw(80) << data; } const auto serialized = toml::parse("tmp2.toml"); BOOST_CHECK(data == serialized); } BOOST_AUTO_TEST_CASE(test_hard_example) { const auto data = toml::parse("toml/tests/hard_example.toml"); { std::ofstream ofs("tmp3.toml"); ofs << std::setw(80) << data; } const auto serialized = toml::parse("tmp3.toml"); BOOST_CHECK(data == serialized); }
25.509091
69
0.617249
xaxousis
0f6e7a342d4daa7b6da186ebc6910708efdbc484
1,034
cpp
C++
Mother Vertex - GFG/mother-vertex.cpp
champmaniac/LeetCode
65810e0123e0ceaefb76d0a223436d1525dac0d4
[ "MIT" ]
1
2022-02-27T09:01:07.000Z
2022-02-27T09:01:07.000Z
Mother Vertex - GFG/mother-vertex.cpp
champmaniac/LeetCode
65810e0123e0ceaefb76d0a223436d1525dac0d4
[ "MIT" ]
null
null
null
Mother Vertex - GFG/mother-vertex.cpp
champmaniac/LeetCode
65810e0123e0ceaefb76d0a223436d1525dac0d4
[ "MIT" ]
null
null
null
// { Driver Code Starts #include<bits/stdc++.h> using namespace std; // } Driver Code Ends class Solution { public: //Function to find a Mother Vertex in the Graph. void dfs(int s, vector<int>adj[], bool visit[], int &count){ visit[s] = true; count++; for(int v : adj[s]){ if(!visit[v]) dfs(v, adj, visit, count); } } int findMotherVertex(int V, vector<int>adj[]){ // Code here int ans =-1; bool visit[V]; for(int i =0; i<V; ++i){ int count =0; fill(visit, visit+V, false); dfs(i, adj, visit, count); if(count == V){ ans = i; break; } } return ans; } }; // { Driver Code Starts. int main(){ int tc; cin >> tc; while(tc--){ int V, E; cin >> V >> E; vector<int>adj[V]; for(int i = 0; i < E; i++){ int u, v; cin >> u >> v; adj[u].push_back(v); } Solution obj; int ans = obj.findMotherVertex(V, adj); cout << ans <<"\n"; } return 0; } // } Driver Code Ends
18.464286
64
0.502901
champmaniac
0f6e8036d5b28b84f20123b4952bc7f807d7966d
320
cpp
C++
abc_172/tempCodeRunnerFile.cpp
dashimaki360/atcoder
1462150d59d50f270145703df579dba8c306376c
[ "MIT" ]
null
null
null
abc_172/tempCodeRunnerFile.cpp
dashimaki360/atcoder
1462150d59d50f270145703df579dba8c306376c
[ "MIT" ]
null
null
null
abc_172/tempCodeRunnerFile.cpp
dashimaki360/atcoder
1462150d59d50f270145703df579dba8c306376c
[ "MIT" ]
null
null
null
int main() { // int n, m; // cin >> n >> m; // mint sum = 0; // rep(k,n+1){ // mint tmp = comb(m,k); // tmp *= comb.p(m-k, n-k); // if(k&1) sum -= tmp; // else sum += tmp; // // cout << "tmp " << tmp.val() << endl; // } // sum *= comb.p(m,n); // cout << sum << endl; // return 0; // }
21.333333
46
0.378125
dashimaki360
0f6f5108498ccb0b3000d9e64093d7c2f7e5623c
7,783
cpp
C++
org/ortc/RTCSrtpSdesTransport.cpp
ortclib/ortclib-uwp
7bf18f5a780a05ac6df7de5c30306699f634829b
[ "BSD-2-Clause" ]
3
2017-03-02T00:56:18.000Z
2019-07-24T09:30:13.000Z
org/ortc/RTCSrtpSdesTransport.cpp
ortclib/ortclib-uwp
7bf18f5a780a05ac6df7de5c30306699f634829b
[ "BSD-2-Clause" ]
3
2018-08-07T12:58:13.000Z
2019-02-08T21:33:12.000Z
org/ortc/RTCSrtpSdesTransport.cpp
ortclib/ortclib-uwp
7bf18f5a780a05ac6df7de5c30306699f634829b
[ "BSD-2-Clause" ]
7
2016-10-13T16:14:39.000Z
2018-10-19T02:30:30.000Z
#include "pch.h" #include <org/ortc/RTCSrtpSdesTransport.h> #include <org/ortc/RTCIceTransport.h> #include <org/ortc/helpers.h> #include <org/ortc/Error.h> #include <ortc/services/IHelper.h> #include <zsLib/SafeInt.h> using Platform::Collections::Vector; using Platform::Array; using Platform::Object; using namespace ortc; namespace Org { namespace Ortc { ZS_DECLARE_TYPEDEF_PTR(Internal::Helper, UseHelper) namespace Internal { #pragma region RTCSrtpSdesTransport conversions RTCSrtpSdesCryptoParameters^ ToCx(const ISRTPSDESTransportTypes::CryptoParameters &input) { auto result = ref new RTCSrtpSdesCryptoParameters(); result->Tag = SafeInt<decltype(result->Tag)>(input.mTag); result->CryptoSuite = Helper::ToCx(input.mCryptoSuite); result->KeyParams = ref new Vector<RTCSrtpKeyParam^>(); for (auto iter = input.mKeyParams.begin(); iter != input.mKeyParams.end(); ++iter) { auto keyParam = (*iter); result->KeyParams->Append(ToCx(keyParam)); } result->SessionParams = ref new Vector<Platform::String^>(); for (auto iter = input.mSessionParams.begin(); iter != input.mSessionParams.end(); ++iter) { auto sessionParam = (*iter); result->SessionParams->Append(Helper::ToCx(sessionParam)); } return result; } RTCSrtpSdesCryptoParameters^ ToCx(ISRTPSDESTransportTypes::CryptoParametersPtr input) { if (!input) return nullptr; return ToCx(*input); } ISRTPSDESTransportTypes::CryptoParametersPtr FromCx(RTCSrtpSdesCryptoParameters^ input) { if (nullptr == input) return ISRTPSDESTransportTypes::CryptoParametersPtr(); auto result = make_shared<ISRTPSDESTransportTypes::CryptoParameters>(); result->mTag = SafeInt<decltype(result->mTag)>(input->Tag); result->mCryptoSuite = Helper::FromCx(input->CryptoSuite); if (nullptr != input->KeyParams) { for (auto params : input->KeyParams) { auto convertedParam = FromCx(params); if (convertedParam) { result->mKeyParams.push_back(*convertedParam); } } } if (nullptr != input->SessionParams) { for (auto params : input->SessionParams) { auto convertedParam = Helper::FromCx(params); result->mSessionParams.push_back(convertedParam); } } return result; } RTCSrtpSdesParameters^ ToCx(const ISRTPSDESTransportTypes::Parameters &input) { auto result = ref new RTCSrtpSdesParameters(); for (auto iter = input.mCryptoParams.begin(); iter != input.mCryptoParams.end(); ++iter) { auto param = (*iter); result->CryptoParams->Append(ToCx(param)); } return result; } RTCSrtpSdesParameters^ ToCx(ISRTPSDESTransportTypes::ParametersPtr input) { if (!input) return nullptr; return ToCx(*input); } ISRTPSDESTransportTypes::ParametersPtr FromCx(RTCSrtpSdesParameters^ input) { if (nullptr == input) return ISRTPSDESTransportTypes::ParametersPtr(); auto result = make_shared<ISRTPSDESTransportTypes::Parameters>(); if (nullptr != input->CryptoParams) { for (auto params : input->CryptoParams) { auto convertedParam = FromCx(params); if (convertedParam) { result->mCryptoParams.push_back(*convertedParam); } } } return result; } RTCSrtpKeyParam^ ToCx(const ISRTPSDESTransportTypes::KeyParameters &input) { auto result = ref new RTCSrtpKeyParam(); result->KeyMethod = Helper::ToCx(input.mKeyMethod); result->KeySalt = Helper::ToCx(input.mKeySalt); result->Lifetime = Helper::ToCx(input.mLifetime); result->MkiValue = Helper::ToCx(input.mMKIValue); result->MkiLength = SafeInt<decltype(result->MkiLength)>(input.mMKILength); return result; } RTCSrtpKeyParam^ ToCx(ISRTPSDESTransportTypes::KeyParametersPtr input) { if (!input) return nullptr; return ToCx(*input); } ISRTPSDESTransportTypes::KeyParametersPtr FromCx(RTCSrtpKeyParam^ input) { if (nullptr == input) return ISRTPSDESTransportTypes::KeyParametersPtr(); auto result = make_shared<ISRTPSDESTransportTypes::KeyParameters>(); result->mKeyMethod = Helper::FromCx(input->KeyMethod); result->mKeySalt = Helper::FromCx(input->KeySalt); result->mMKIValue = Helper::FromCx(input->MkiValue); result->mMKILength = SafeInt<decltype(result->mMKILength)>(input->MkiLength); return result; } #pragma endregion #pragma region RTCSrtpSdesTransport delegates class RTCSrtpSdesTransportDelegate : public ISRTPSDESTransportDelegate { public: RTCSrtpSdesTransportDelegate(RTCSrtpSdesTransport^ owner) { _owner = owner; } virtual void onSRTPSDESTransportLifetimeRemaining( ISRTPSDESTransportPtr transport, ULONG leastLifetimeRemainingPercentageForAllKeys, ULONG overallLifetimeRemainingPercentage ) { auto evt = ref new RTCSrtpSdesTransportLifetimeRemainingEvent(); evt->_leastLifetimeRemainingPercentageForAllKeys = SafeInt<decltype(evt->_leastLifetimeRemainingPercentageForAllKeys)>(leastLifetimeRemainingPercentageForAllKeys); evt->_overallLifetimeRemainingPercentage = SafeInt<decltype(evt->_overallLifetimeRemainingPercentage)>(overallLifetimeRemainingPercentage); _owner->OnLifetimeRemaining(evt); } virtual void onSRTPSDESTransportError( ISRTPSDESTransportPtr transport, ErrorAnyPtr error ) { auto evt = ref new ErrorEvent(Error::CreateIfGeneric(error)); _owner->OnError(evt); } private: RTCSrtpSdesTransport^ _owner; }; #pragma endregion } // namespace internal #pragma region RTCSrtpSdesTransport RTCSrtpSdesTransport::RTCSrtpSdesTransport(ISRTPSDESTransportPtr transport) : _nativeDelegatePointer(make_shared<Internal::RTCSrtpSdesTransportDelegate>(this)), _nativePointer(transport) { if (_nativePointer) { _nativeSubscriptionPointer = _nativePointer->subscribe(_nativeDelegatePointer); } } RTCSrtpSdesTransport::RTCSrtpSdesTransport(RTCIceTransport^ transport, RTCSrtpSdesCryptoParameters^ encryptParameters, RTCSrtpSdesCryptoParameters^ decryptParameters) : _nativeDelegatePointer(make_shared<Internal::RTCSrtpSdesTransportDelegate>(this)) { ORG_ORTC_THROW_INVALID_PARAMETERS_IF(nullptr == transport) ORG_ORTC_THROW_INVALID_PARAMETERS_IF(nullptr == encryptParameters) ORG_ORTC_THROW_INVALID_PARAMETERS_IF(nullptr == decryptParameters) auto nativeTransport = RTCIceTransport::Convert(transport); try { _nativePointer = ISRTPSDESTransport::create(_nativeDelegatePointer, nativeTransport, *Internal::FromCx(encryptParameters), *Internal::FromCx(decryptParameters)); } catch (const InvalidParameters &) { ORG_ORTC_THROW_INVALID_PARAMETERS() } catch (const InvalidStateError &e) { ORG_ORTC_THROW_INVALID_STATE(UseHelper::ToCx(e.what())) } } RTCSrtpSdesParameters^ RTCSrtpSdesTransport::GetLocalParameters() { auto params = ISRTPSDESTransport::getLocalParameters(); return Internal::ToCx(params); } #pragma endregion } // namespace ortc } // namespace org
33.403433
173
0.663369
ortclib
0f79271a627c0c2c0a828c65b24c0067a4b1d31f
643
cpp
C++
test/cuda/cuda_device_guard.cpp
ipapadop/accxx
29e771f75c4e916b1c5eca6c3d636d2b2ee3f631
[ "MIT" ]
null
null
null
test/cuda/cuda_device_guard.cpp
ipapadop/accxx
29e771f75c4e916b1c5eca6c3d636d2b2ee3f631
[ "MIT" ]
null
null
null
test/cuda/cuda_device_guard.cpp
ipapadop/accxx
29e771f75c4e916b1c5eca6c3d636d2b2ee3f631
[ "MIT" ]
null
null
null
/* * Copyright (c) 2019-2020 Yiannis Papadopoulos * * Distributed under the terms of the MIT License. * * (See accompanying file LICENSE or copy at http://opensource.org/licenses/MIT) */ #include <catch2/catch.hpp> #include <cuda_runtime_api.h> #include "accxx/cuda/call.hpp" #include "accxx/cuda/cuda_device_guard.hpp" TEST_CASE("CUDA set device", "[cuda-device-guard-success]") { int devices{-1}; ACCXX_CUDA_CALL(cudaGetDeviceCount(&devices)); for (int i = 0; i < devices; ++i) { accxx::cuda_device_guard g{i}; int device_id{-1}; ACCXX_CUDA_CALL(cudaGetDevice(&device_id)); REQUIRE(i == device_id); } }
21.433333
80
0.692068
ipapadop