text
string
size
int64
token_count
int64
#include <ros/ros.h> #include <message_filters/subscriber.h> #include <message_filters/synchronizer.h> #include <message_filters/sync_policies/approximate_time.h> #include <dji_sdk/GlobalPosition.h> #include <dji_sdk/LocalPosition.h> #include <nav_msgs/Odometry.h> #include <eigen3/Eigen/Dense> #include "transform.h" dji_sdk::GlobalPosition global_pos_ref; dji_sdk::LocalPosition local_pos_ref; bool first_pos_rcvd = false; ros::Publisher odom_norm_pub, odom_norm_ENU_pub; void callback(const dji_sdk::GlobalPositionConstPtr& global_pos, const nav_msgs::OdometryConstPtr& odometry) { if(!first_pos_rcvd) { global_pos_ref = *global_pos; first_pos_rcvd = true; } nav_msgs::Odometry odom_norm = *odometry; local_pos_ref = gps_convert_ned(*global_pos, global_pos_ref); odom_norm.pose.pose.position.x = local_pos_ref.x; odom_norm.pose.pose.position.y = local_pos_ref.y; odom_norm.pose.pose.position.z = -local_pos_ref.z; odom_norm.twist.twist.linear.z *= -1; odom_norm_pub.publish(odom_norm); // god dammit dji nav_msgs::Odometry odom_norm_ENU = *odometry; // The code above was for NED now convert to ENU Eigen::Vector3d position_ENU = ned2enu(Eigen::Vector3d(local_pos_ref.x, local_pos_ref.y, -local_pos_ref.z)); Eigen::Quaterniond orientation_ENU = ned2enu(Eigen::Quaterniond( odom_norm.pose.pose.orientation.w, odom_norm.pose.pose.orientation.x, odom_norm.pose.pose.orientation.y, odom_norm.pose.pose.orientation.z)); // wtf is this NEU? NED? Eigen::Vector3d velocity_ENU = ned2enu(Eigen::Vector3d( odom_norm.twist.twist.linear.x, odom_norm.twist.twist.linear.y, -odom_norm.twist.twist.linear.z)); odom_norm_ENU.pose.pose.position.x = position_ENU(0); odom_norm_ENU.pose.pose.position.y = position_ENU(1); odom_norm_ENU.pose.pose.position.z = position_ENU(2); odom_norm_ENU.pose.pose.orientation.w = orientation_ENU.w(); odom_norm_ENU.pose.pose.orientation.x = orientation_ENU.x(); odom_norm_ENU.pose.pose.orientation.y = orientation_ENU.y(); odom_norm_ENU.pose.pose.orientation.z = orientation_ENU.z(); odom_norm_ENU.twist.twist.linear.x = velocity_ENU(0); odom_norm_ENU.twist.twist.linear.y = velocity_ENU(1); odom_norm_ENU.twist.twist.linear.z = velocity_ENU(2); odom_norm_ENU_pub.publish(odom_norm_ENU); } int main(int argc, char** argv) { ros::init(argc, argv, "pos_normalizer"); ros::NodeHandle nh; odom_norm_pub = nh.advertise<nav_msgs::Odometry> ("/dji_sdk/odometry_normalized_NED", 10); odom_norm_ENU_pub = nh.advertise<nav_msgs::Odometry> ("/dji_sdk/odometry_normalized_ENU", 10); message_filters::Subscriber<dji_sdk::GlobalPosition> global_sub(nh, "/dji_sdk/global_position", 10); message_filters::Subscriber<nav_msgs::Odometry> odom_sub (nh, "/dji_sdk/odometry", 10); typedef message_filters::sync_policies::ApproximateTime <dji_sdk::GlobalPosition, nav_msgs::Odometry> MySyncPolicy; message_filters::Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), global_sub, odom_sub); sync.registerCallback(boost::bind(&callback, _1, _2)); ros::spin(); return 0; }
3,381
1,312
/* The MIT License Copyright (c) 2015-2017 Albert Murienne 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 "network_manager.h" #include "interfaces/network_interface.h" #include "interfaces/network_file_handler_interface.h" #include "common/network_exception.h" #include "common/samples_manager.h" #include "common/logger.h" #include <chrono> #include <iostream> //#define TRAIN_CHRONO namespace neurocl { class scoped_training { public: scoped_training( std::shared_ptr<network_interface> net ) : m_net( net ) { m_net->set_training( true ); } virtual ~scoped_training() { m_net->set_training( false ); } private: std::shared_ptr<network_interface> m_net; }; void network_manager::_assert_loaded() { if ( !m_network_loaded ) throw network_exception( "no network loaded!" ); } void network_manager::set_training( bool training, key_training ) { m_net->set_training( training ); } void network_manager::load_network( const std::string& topology_path, const std::string& weights_path ) { m_net_file_handler->load_network_topology( topology_path ); m_net_file_handler->load_network_weights( weights_path ); m_network_loaded = true; LOGGER(info) << "network_manager::load_network - network loaded" << std::endl; } void network_manager::save_network() { _assert_loaded(); m_net_file_handler->save_network_weights(); } void network_manager::batch_train( const samples_manager& smp_manager, const size_t& epoch_size, const size_t& batch_size, t_progress_fct progress_fct ) { _assert_loaded(); scoped_training _scoped_training( m_net ); std::shared_ptr<samples_augmenter> smp_augmenter;// = smp_manager.get_augmenter(); size_t progress_size = 0; const size_t pbm_size = epoch_size * smp_manager.samples_size(); for ( size_t i=0; i<epoch_size; i++ ) { while ( true ) { std::vector<neurocl::sample> samples = smp_manager.get_next_batch( batch_size ); // end of training set management if ( samples.empty() ) break; prepare_training_epoch(); _train_batch( samples, smp_augmenter ); finalize_training_epoch(); progress_size += samples.size(); int progress = ( ( 100 * progress_size ) / pbm_size ); if ( progress_fct ) progress_fct( progress ); std::cout << "\rnetwork_manager::batch_train - progress: " << progress << "% loss: " << m_net->loss(); } std::cout << "\r"; LOGGER(info) << "network_manager::batch_train - EPOCH " << (i+1) << "/" << epoch_size << " loss: " << m_net->loss() << std::endl; smp_manager.rewind(); smp_manager.shuffle(); } std::cout << std::endl; save_network(); } void network_manager::prepare_training_epoch() { m_net->clear_gradients(); } void network_manager::finalize_training_epoch() { m_net->gradient_descent(); } void network_manager::train( const sample& s, key_training ) { _assert_loaded(); _train_single( s ); } void network_manager::_train_batch( const std::vector<sample>& training_set, const std::shared_ptr<samples_augmenter>& smp_augmenter ) { _assert_loaded(); size_t index = 0; for( const auto& s : training_set ) { //LOGGER(info) << "network_manager::_train_batch - training sample " << (index+1) << "/" << training_set.size() << std::endl; if ( !smp_augmenter ) { _train_single( s ); } else { //sample _s = smp_augmenter->translate( s, samples_augmenter::rand_shift(), samples_augmenter::rand_shift() ); sample _s = smp_augmenter->rotate( s, samples_augmenter::rand_shift() ); _train_single( _s ); } ++index; } } void network_manager::_train_single( const sample& s ) { #ifdef TRAIN_CHRONO namespace sc = std::chrono; sc::system_clock::time_point start = sc::system_clock::now(); sc::milliseconds duration; #endif // set input/output m_net->set_input( s.isample_size, s.isample ); m_net->set_output( s.osample_size, s.osample ); // forward/backward propagation m_net->feed_forward(); m_net->back_propagate(); #ifdef TRAIN_CHRONO duration = sc::duration_cast<sc::milliseconds>( sc::system_clock::now() - start ); LOGGER(info) << "network_manager::_train_single - training successfull in " << duration.count() << "ms"<< std::endl; #endif } void network_manager::compute_augmented_output( sample& s, const std::shared_ptr<samples_augmenter>& smp_augmenter ) { // ONLY ROTATION AUGMENTATION IS IMPLEMENTED YET std::vector<int> rotations{ -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 }; std::vector<output_ptr> outputs; for ( auto& rot : rotations ) { sample _s = smp_augmenter->rotate( s, rot ); m_net->set_input( _s.isample_size, _s.isample ); m_net->feed_forward(); outputs.emplace_back( m_net->output() ); //output_layer += m_net->output(); } // TODO-CNN : not very proud of the efficiency of this code section... // still it is temporary as computing a mean image alos makes sense! int i = 0; int l = 0; float max = std::numeric_limits<float>::min(); for ( const auto& output : outputs ) { float _tmp_max = output.max_comp_val(); LOGGER(info) << "network_manager::compute_augmented_output - " << _tmp_max << " " << output.max_comp_idx() << std::endl; if ( _tmp_max > max ) { l = i; max = _tmp_max; } i++; } std::copy( outputs[l].outputs.get(), outputs[l].outputs.get() + outputs[l].num_outputs, const_cast<float*>( s.osample ) ); } void network_manager::compute_output( sample& s ) { _assert_loaded(); m_net->set_input( s.isample_size, s.isample ); m_net->feed_forward(); output_ptr output_layer = m_net->output(); std::copy( output_layer.outputs.get(), output_layer.outputs.get() + output_layer.num_outputs, const_cast<float*>( s.osample ) ); } void network_manager::compute_output( std::vector<sample>& s ) { _assert_loaded(); // NOT IMPLEMENTED YET //m_net->batch_feed_forward( std::vector<input_ptr>&, std::vector<output_ptr>& ); } void network_manager::gradient_check( const sample& s ) { _assert_loaded(); m_net->set_input( s.isample_size, s.isample ); m_net->set_output( s.osample_size, s.osample ); output_ptr out_ref( s.osample_size ); std::copy( s.osample, s.osample + s.osample_size, out_ref.outputs.get() ); m_net->gradient_check( out_ref ); } void network_manager::dump_weights() { _assert_loaded(); std::cout << m_net->dump_weights(); } void network_manager::dump_bias() { _assert_loaded(); std::cout << m_net->dump_bias(); } void network_manager::dump_activations() { _assert_loaded(); std::cout << m_net->dump_activations(); } } /*namespace neurocl*/
8,085
2,780
#include "timereference.h" #include <ctime> #include "core/tickpoke.h" #include "globalcontext.h" #define INTERVAL 50 static int currentyear = 0; static int currentmonth = 0; static int currentday = 0; TimeReference::TimeReference() { global->getTickPoke()->startPoke(this, "TimeReference", INTERVAL, 0); } void TimeReference::tick(int) { timeticker += INTERVAL; } unsigned long long TimeReference::timeReference() const { return timeticker; } unsigned long long TimeReference::timePassedSince(unsigned long long timestamp) const { if (timestamp > timeticker) { return 0 - timestamp + timeticker; } return timeticker - timestamp; } void TimeReference::updateTime() { time_t rawtime; time(&rawtime); struct tm timedata; localtime_r(&rawtime, &timedata); currentyear = timedata.tm_year + 1900; currentmonth = timedata.tm_mon + 1; currentday = timedata.tm_mday; } int TimeReference::currentYear() { return currentyear; } int TimeReference::currentMonth() { return currentmonth; } int TimeReference::currentDay() { return currentday; }
1,080
372
#include<cassert> int main() { try { int x = 5; int *py = &x; throw py; } catch(int*) { } catch(void*) { assert(0); } return 0; }
155
74
#include <string> #include <iostream> #include <sstream> #include "Avapi/AvapiConnection.hpp" #include "Avapi/TECHNICAL_INDICATOR/MIDPOINT.hpp" using namespace std; using namespace Avapi; int main() { string lastHttpRequest = ""; AvapiConnection* avapi_connection; try { avapi_connection = AvapiConnection::getInstance(); avapi_connection->set_ApiKey("Your Alpha Vantage API Key !!!!"); } catch(AvapiConnectionError& e) { cout << e.get_error() << endl; return EXIT_FAILURE; } auto& QueryObject = avapi_connection->GetQueryObject_MIDPOINT(); auto Response = QueryObject.Query( "MSFT" ,Const_MIDPOINT_interval::n_60min ,"10" ,Const_MIDPOINT_series_type::close); cout << endl << "******** RAW DATA MIDPOINT ********"<< endl; cout << Response.get_RawData() << endl << endl; cout << "******** STRUCTURED DATA MIDPOINT ********"<< endl; if(Response.get_Data().isError()) { cerr << Response.get_Data().get_ErrorMessage() << endl; } else { auto& MetaData = Response.get_Data().get_MetaData(); auto& TechnicalIndicator = Response.get_Data().get_TechnicalIndicator(); cout << "========================" << endl; cout << "Symbol: " << MetaData.get_Symbol() << endl; cout << "Indicator: " << MetaData.get_Indicator() << endl; cout << "LastRefreshed: " << MetaData.get_LastRefreshed() << endl; cout << "Interval: " << MetaData.get_Interval() << endl; cout << "TimePeriod: " << MetaData.get_TimePeriod() << endl; cout << "SeriesType: " << MetaData.get_SeriesType() << endl; cout << "TimeZone: " << MetaData.get_TimeZone() << endl; cout << "========================" << endl; cout << "========================" << endl; for(auto& element : TechnicalIndicator) { cout << "MIDPOINT: " << element.get_MIDPOINT() << endl; cout << "DateTime: " << element.get_DateTime() << endl; cout << "========================" << endl; } } return EXIT_SUCCESS; }
2,192
698
// decl.C99\Error_class_forward_def_const_volatile9.hpp // using singly defined class // (C)2010 Kenneth Boyd, license: MIT.txt class good_test; const class good_test volatile; class good_test { int x_factor; };
227
90
/* * MapboxVectorTileParser_jni.cpp * WhirlyGlobeLib * * Created by Steve Gifford on 5/25/16. * Copyright 2011-2016 mousebird consulting * * 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. * */ #import <jni.h> #import "Maply_jni.h" #import "Maply_utils_jni.h" #import "com_mousebird_maply_MapboxVectorTileParser.h" #import "WhirlyGlobe.h" using namespace Eigen; using namespace WhirlyKit; using namespace Maply; JNIEXPORT void JNICALL Java_com_mousebird_maply_MapboxVectorTileParser_nativeInit (JNIEnv *env, jclass cls) { MapboxVectorTileParserClassInfo::getClassInfo(env,cls); } JNIEXPORT void JNICALL Java_com_mousebird_maply_MapboxVectorTileParser_initialise (JNIEnv *env, jobject obj) { try { MapboxVectorTileParserClassInfo *classInfo = MapboxVectorTileParserClassInfo::getClassInfo(); MapboxVectorTileParser *inst = new MapboxVectorTileParser(); classInfo->setHandle(env,obj,inst); } catch (...) { __android_log_print(ANDROID_LOG_VERBOSE, "Maply", "Crash in MapboxVectorTileParser::initialise()"); } } static std::mutex disposeMutex; JNIEXPORT void JNICALL Java_com_mousebird_maply_MapboxVectorTileParser_dispose (JNIEnv *env, jobject obj) { try { MapboxVectorTileParserClassInfo *classInfo = MapboxVectorTileParserClassInfo::getClassInfo(); { std::lock_guard<std::mutex> lock(disposeMutex); MapboxVectorTileParser *inst = classInfo->getObject(env,obj); if (!inst) return; delete inst; classInfo->clearHandle(env,obj); } } catch (...) { __android_log_print(ANDROID_LOG_VERBOSE, "Maply", "Crash in MapboxVectorTileParser::dispose()"); } } JNIEXPORT jobjectArray JNICALL Java_com_mousebird_maply_MapboxVectorTileParser_parseDataNative (JNIEnv *env, jobject obj, jbyteArray data, jdouble minX, jdouble minY, jdouble maxX, jdouble maxY) { try { MapboxVectorTileParserClassInfo *classInfo = MapboxVectorTileParserClassInfo::getClassInfo(); MapboxVectorTileParser *inst = classInfo->getObject(env,obj); if (!inst || !data) return NULL; Mbr mbr; mbr.addPoint(Point2f(minX,minY)); mbr.addPoint(Point2f(maxX,maxY)); // Parse vector tile and create vector objects jbyte *bytes = env->GetByteArrayElements(data,NULL); RawDataWrapper rawData(bytes,env->GetArrayLength(data),false); std::vector<VectorObject *> vecObjs; bool ret = inst->parseVectorTile(&rawData,vecObjs,mbr); env->ReleaseByteArrayElements(data,bytes, 0); if (vecObjs.empty()) { return NULL; } else { VectorObjectClassInfo *vecClassInfo = VectorObjectClassInfo::getClassInfo(); if (!vecClassInfo) vecClassInfo = VectorObjectClassInfo::getClassInfo(env,"com/mousebird/maply/VectorObject"); jobjectArray retArr = env->NewObjectArray(vecObjs.size(), vecClassInfo->getClass(), NULL); int which = 0; for (VectorObject *vecObj : vecObjs) { jobject vecObjObj = MakeVectorObject(env,vecObj); env->SetObjectArrayElement( retArr, which, vecObjObj); env->DeleteLocalRef( vecObjObj); which++; } return retArr; } } catch (...) { __android_log_print(ANDROID_LOG_VERBOSE, "Maply", "Crash in MapboxVectorTileParser::parseDataNative()"); } return NULL; }
4,138
1,324
/*++ Copyright (c) 2006 Microsoft Corporation Module Name: ex.cpp Abstract: <abstract> Author: Leonardo de Moura (leonardo) 2011-04-28 Revision History: --*/ #include<iostream> #include "util/z3_exception.h" class ex { public: virtual ~ex() {} virtual char const * msg() const = 0; }; class ex1 : public ex { char const * m_msg; public: ex1(char const * m):m_msg(m) {} char const * msg() const override { return m_msg; } }; class ex2 : public ex { std::string m_msg; public: ex2(char const * m):m_msg(m) {} char const * msg() const override { return m_msg.c_str(); } }; static void th() { throw ex2("testing exception"); } static void tst1() { try { th(); } catch (ex & e) { std::cerr << e.msg() << "\n"; } } static void tst2() { try { throw default_exception(default_exception::fmt(), "Format %d %s", 12, "twelve"); } catch (z3_exception& ex) { std::cerr << ex.msg() << "\n"; } } void tst_ex() { tst1(); tst2(); }
1,050
407
#include <bits/stdc++.h> using namespace std; #pragma comment(linker,"/stack:1024000000,1024000000") #define db(x) cout<<(x)<<endl #define pf(x) push_front(x) #define pb(x) push_back(x) #define mp(x,y) make_pair(x,y) #define ms(x,y) memset(x,y,sizeof x) typedef long long LL; const double pi=acos(-1),eps=1e-9; const LL inf=0x3f3f3f3f,mod=1e9+7,maxn=512345; struct node{ char s[5]; int x; }p[maxn],ans[12]; int n,t,a,b=1023,x=1023,y,z; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i=0;i<n;i++){ cin>>p[i].s>>p[i].x; if(p[i].s[0]=='&') a&=p[i].x,b&=p[i].x; else if(p[i].s[0]=='|') a|=p[i].x,b|=p[i].x; else a^=p[i].x,b^=p[i].x; } for(int i=0;i<10;i++) if(((a>>i)&1)&&!((b>>i)&1)) z^=1<<i; else if(((a>>i)&1)&&((b>>i)&1)) y|=1<<i; else if(!((a>>i)&1)&&!((b>>i)&1)) x&=~(1<<i); if(x<1023) ans[t].s[0]='&',ans[t++].x=x; if(y) ans[t].s[0]='|',ans[t++].x=y; if(z) ans[t].s[0]='^',ans[t++].x=z; db(t); for(int i=0;i<t;i++) printf("%s %d\n",ans[i].s,ans[i].x); return 0; }
1,038
668
/*! ****************************************************************************** * * \file * * \brief Header file providing RAJA sort declarations. * ****************************************************************************** */ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// // Copyright (c) 2016-21, Lawrence Livermore National Security, LLC // and RAJA project contributors. See the RAJA/COPYRIGHT file for details. // // SPDX-License-Identifier: (BSD-3-Clause) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// #ifndef RAJA_sort_loop_HPP #define RAJA_sort_loop_HPP #include "RAJA/config.hpp" #include <algorithm> #include <functional> #include <iterator> #include "RAJA/util/macros.hpp" #include "RAJA/util/concepts.hpp" #include "RAJA/util/zip.hpp" #include "RAJA/util/sort.hpp" #include "RAJA/policy/loop/policy.hpp" namespace RAJA { namespace impl { namespace sort { namespace detail { /*! \brief Functional that performs an unstable sort with the given arguments, uses RAJA::intro_sort */ struct UnstableSorter { template < typename... Args > RAJA_INLINE void operator()(Args&&... args) const { RAJA::detail::intro_sort(std::forward<Args>(args)...); } }; /*! \brief Functional that performs a stable sort with the given arguments, calls RAJA::merge_sort */ struct StableSorter { template < typename... Args > RAJA_INLINE void operator()(Args&&... args) const { RAJA::detail::merge_sort(std::forward<Args>(args)...); } }; } // namespace detail /*! \brief sort given range using comparison function */ template <typename ExecPolicy, typename Iter, typename Compare> concepts::enable_if_t<resources::EventProxy<resources::Host>, type_traits::is_loop_policy<ExecPolicy>> unstable( resources::Host host_res, const ExecPolicy&, Iter begin, Iter end, Compare comp) { detail::UnstableSorter{}(begin, end, comp); return resources::EventProxy<resources::Host>(host_res); } /*! \brief stable sort given range using comparison function */ template <typename ExecPolicy, typename Iter, typename Compare> concepts::enable_if_t<resources::EventProxy<resources::Host>, type_traits::is_loop_policy<ExecPolicy>> stable( resources::Host host_res, const ExecPolicy&, Iter begin, Iter end, Compare comp) { detail::StableSorter{}(begin, end, comp); return resources::EventProxy<resources::Host>(host_res); } /*! \brief sort given range of pairs using comparison function on keys */ template <typename ExecPolicy, typename KeyIter, typename ValIter, typename Compare> concepts::enable_if_t<resources::EventProxy<resources::Host>, type_traits::is_loop_policy<ExecPolicy>> unstable_pairs( resources::Host host_res, const ExecPolicy&, KeyIter keys_begin, KeyIter keys_end, ValIter vals_begin, Compare comp) { auto begin = RAJA::zip(keys_begin, vals_begin); auto end = RAJA::zip(keys_end, vals_begin+(keys_end-keys_begin)); using zip_ref = RAJA::detail::IterRef<camp::decay<decltype(begin)>>; detail::UnstableSorter{}(begin, end, RAJA::compare_first<zip_ref>(comp)); return resources::EventProxy<resources::Host>(host_res); } /*! \brief stable sort given range of pairs using comparison function on keys */ template <typename ExecPolicy, typename KeyIter, typename ValIter, typename Compare> concepts::enable_if_t<resources::EventProxy<resources::Host>, type_traits::is_loop_policy<ExecPolicy>> stable_pairs( resources::Host host_res, const ExecPolicy&, KeyIter keys_begin, KeyIter keys_end, ValIter vals_begin, Compare comp) { auto begin = RAJA::zip(keys_begin, vals_begin); auto end = RAJA::zip(keys_end, vals_begin+(keys_end-keys_begin)); using zip_ref = RAJA::detail::IterRef<camp::decay<decltype(begin)>>; detail::StableSorter{}(begin, end, RAJA::compare_first<zip_ref>(comp)); return resources::EventProxy<resources::Host>(host_res); } } // namespace sort } // namespace impl } // namespace RAJA #endif
4,183
1,353
#include "player.h" #include <chrono> #include <iostream> #include <algorithm> extern "C" { #include <libavutil/time.h> } using std::string; using std::unique_ptr; using std::function; using std::thread; using std::chrono::milliseconds; using std::this_thread::sleep_for; using std::exception; using std::cerr; using std::endl; using std::runtime_error; using std::max; Player::Player(const string &file_name) : container_(new Container(file_name)), display_(new Display(container_->get_width(), container_->get_height())), timer_(new Timer), packet_queue_(new PacketQueue(queue_size_)), frame_queue_(new FrameQueue(queue_size_)) { stages_.push_back(thread(&Player::demultiplex, this)); stages_.push_back(thread(&Player::decode_video, this)); video(); } Player::~Player() { frame_queue_->quit(); packet_queue_->quit(); for (auto &stage : stages_) { stage.join(); } } void Player::demultiplex() { try { for (;;) { // Create AVPacket unique_ptr<AVPacket, function<void(AVPacket*)>> packet( new AVPacket, [](AVPacket* p){ av_free_packet(p); delete p; }); av_init_packet(packet.get()); packet->data = nullptr; // Read frame into AVPacket if (!container_->read_frame(*packet)) { packet_queue_->finished(); break; } // Move into queue if first video stream if (packet->stream_index == container_->get_video_stream()) { if (!packet_queue_->push(move(packet))) { break; } } } } catch (exception &e) { cerr << "Demuxing error: " << e.what() << endl; exit(1); } } void Player::decode_video() { const AVRational microseconds = {1, 1000000}; try { for (;;) { // Create AVFrame and AVQueue unique_ptr<AVFrame, function<void(AVFrame*)>> frame_decoded( av_frame_alloc(), [](AVFrame* f){ av_frame_free(&f); }); unique_ptr<AVPacket, function<void(AVPacket*)>> packet( nullptr, [](AVPacket* p){ av_free_packet(p); delete p; }); // Read packet from queue if (!packet_queue_->pop(packet)) { frame_queue_->finished(); break; } // Decode packet int finished_frame; container_->decode_frame( frame_decoded.get(), finished_frame, packet.get()); // If a whole frame has been decoded, // adjust time stamps and add to queue if (finished_frame) { frame_decoded->pts = av_rescale_q( frame_decoded->pkt_dts, container_->get_container_time_base(), microseconds); unique_ptr<AVFrame, function<void(AVFrame*)>> frame_converted( av_frame_alloc(), [](AVFrame* f){ avpicture_free( reinterpret_cast<AVPicture*>(f)); av_frame_free(&f); }); if (av_frame_copy_props(frame_converted.get(), frame_decoded.get()) < 0) { throw runtime_error("Copying frame properties"); } if (avpicture_alloc( reinterpret_cast<AVPicture*>(frame_converted.get()), container_->get_pixel_format(), container_->get_width(), container_->get_height()) < 0) { throw runtime_error("Allocating picture"); } container_->convert_frame( frame_decoded.get(), frame_converted.get()); if (!frame_queue_->push(move(frame_converted))) { break; } } } } catch (exception &e) { cerr << "Decoding error: " << e.what() << endl; exit(1); } } void Player::video() { try { int64_t last_pts = 0; for (uint64_t frame_number = 0;; ++frame_number) { display_->input(); if (display_->get_quit()) { break; } else if (display_->get_play()) { unique_ptr<AVFrame, function<void(AVFrame*)>> frame( nullptr, [](AVFrame* f){ av_frame_free(&f); }); if (!frame_queue_->pop(frame)) { break; } if (frame_number) { int64_t frame_delay = frame->pts - last_pts; last_pts = frame->pts; timer_->wait(frame_delay); } else { last_pts = frame->pts; timer_->update(); } display_->refresh(*frame); } else { milliseconds sleep(10); sleep_for(sleep); timer_->update(); } } } catch (exception &e) { cerr << "Display error: " << e.what() << endl; exit(1); } }
4,061
1,748
/* * ImageBackground.cpp * * Created on: 08.09.2014 * Author: baudenri */ #include "PolygonBackground.h" #include <World/Scene.h> #include <OgreMaterialManager.h> #include <OgrePass.h> #include <OgreRenderQueue.h> #include <OgreAxisAlignedBox.h> #include <OgreSceneNode.h> #include <OgreTechnique.h> #include <OgreLogManager.h> using namespace X3D; const std::string PolygonBackground::_sceneNodeName = "X3D_PolygonBackground_SceneNode"; void PolygonBackground::initialise(World& world) { if (_init) { return; } if (not _appearance) { // If no appearance present, ImageBackground cann't be initialised. return; } // Create Appearance for Polygon background _appearance->initialise(world); _appearance->create(); // Create background rectangle covering the whole screen _rect.reset(new Ogre::Rectangle2D(true)); _rect->setCorners(-1, 1, 1, -1); _rect->setMaterial(_appearance->getOgreMaterial()); // Render the background before everything else _rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); // Render everything even if background is closer to camera than other objects _appearance->pass()->setDepthCheckEnabled(false); _appearance->pass()->setDepthWriteEnabled(false); // Apply texCoordinates if (_appearance->getTexture()) { // Set Lighting disabled only for Texture Background // Otherwise the pass will not be rendered which results in a white background _appearance->pass()->setLightingEnabled(false); if (_texCoords.size()==4) { _rect->setUVs(Ogre::Vector2(_texCoords[3].x,_texCoords[3].y), Ogre::Vector2(_texCoords[0].x,_texCoords[0].y), Ogre::Vector2(_texCoords[2].x,_texCoords[2].y), Ogre::Vector2(_texCoords[1].x,_texCoords[1].y) ); } else { if (not _texCoords.empty()) { Ogre::LogManager::getSingleton().logMessage("PolygonBackground: Texture Coordinates have wrong size", Ogre::LML_NORMAL); } _rect->setUVs(Ogre::Vector2(0,1),Ogre::Vector2(0,0), Ogre::Vector2(1,1), Ogre::Vector2(1,0)); } } // Use infinite AAB to always stay visible. Ogre::AxisAlignedBox aabInf; aabInf.setInfinite(); _rect->setBoundingBox(aabInf); // Attach background to the scene _root = world.sceneManager()->getRootSceneNode(); BindableNode<PolygonBackground>::initialise(world); _init = true; } void PolygonBackground::texCoords(const std::vector<Ogre::Vector3>& textureCoords) { _texCoords = textureCoords; } void PolygonBackground::setAppearance(const std::shared_ptr<Appearance>& appearance) { _appearance = appearance; } void PolygonBackground::onBound(Scene& scene) { if (_root) _root->attachObject(_rect.get()); } void PolygonBackground::onUnbound(Scene& scene) { if (_root) _root->detachObject(_rect.get()); }
2,730
999
/********************************************************************** * Copyright (c) 2008-2014, Alliance for Sustainable Energy. * All rights reserved. * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA **********************************************************************/ #include <gtest/gtest.h> #include <utilities/units/test/UnitsFixture.hpp> #include <utilities/units/BTUUnit.hpp> #include <utilities/units/Scale.hpp> #include <utilities/core/Exception.hpp> using openstudio::Unit; using openstudio::UnitSystem; using openstudio::BTUExpnt; using openstudio::BTUUnit; using openstudio::Exception; using openstudio::createBTULength; using openstudio::createBTUTime; using openstudio::createBTUTemperature; using openstudio::createBTUPeople; using openstudio::createBTUEnergy; using openstudio::createBTUPower; TEST_F(UnitsFixture,BTUUnit_Constructors) { LOG(Debug,"BTUUnit_Constructors"); BTUUnit l1(BTUExpnt(0,1)); BTUUnit P1(BTUExpnt(1,0,-1,0),-3); // mBtu/h BTUUnit E1("k",BTUExpnt(1)); // kBtu EXPECT_EQ(0,l1.baseUnitExponent("Btu")); EXPECT_EQ(1,l1.baseUnitExponent("ft")); l1.setBaseUnitExponent("R",-1); EXPECT_EQ(-1,l1.baseUnitExponent("R")); EXPECT_THROW(l1.setBaseUnitExponent("m",1),Exception); EXPECT_EQ("Btu/h",P1.standardString(false)); EXPECT_EQ("mBtu/h",P1.standardString()); EXPECT_EQ(UnitSystem::BTU,P1.system().value()); EXPECT_EQ(0,P1.baseUnitExponent("R")); BTUUnit P2(P1); EXPECT_EQ(UnitSystem::BTU,P2.system().value()); EXPECT_EQ("",E1.prettyString()); EXPECT_EQ("kBtu",E1.standardString()); EXPECT_EQ(0,E1.baseUnitExponent("ft")); } TEST_F(UnitsFixture,BTUUnit_ArithmeticOperators) { LOG(Debug,"BTUUnit_ArithmeticOperators"); // /= BTUUnit P1(BTUExpnt(1)); BTUUnit t1(BTUExpnt(0,0,1)); P1 /= t1; EXPECT_EQ("Btu/h",P1.standardString(false)); EXPECT_EQ(1,P1.baseUnitExponent("Btu")); EXPECT_EQ(-1,P1.baseUnitExponent("h")); EXPECT_EQ(0,P1.baseUnitExponent("ft")); EXPECT_EQ(0,P1.baseUnitExponent("m")); // * Unit E1 = P1 * t1; EXPECT_TRUE(E1.system() == UnitSystem::BTU); EXPECT_EQ("Btu",E1.standardString(false)); EXPECT_EQ("",E1.prettyString()); // / Unit u = P1/E1; u /= t1; EXPECT_TRUE(u.system() == UnitSystem::BTU); EXPECT_EQ("1/h^2",u.standardString(false)); EXPECT_EQ(-2,u.baseUnitExponent("h")); EXPECT_EQ(0,u.baseUnitExponent("Btu")); // pow u.pow(-1,2); EXPECT_EQ("h",u.standardString(false)); EXPECT_EQ(1,u.baseUnitExponent("h")); } TEST_F(UnitsFixture,BTUUnit_CreateFunctions) { BTUUnit u; u = createBTULength(); EXPECT_EQ(1,u.baseUnitExponent("ft")); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("ft",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u = createBTUTime(); EXPECT_EQ(1,u.baseUnitExponent("h")); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("h",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u = createBTUTemperature(); EXPECT_EQ(1,u.baseUnitExponent("R")); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("R",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u = createBTUPeople(); EXPECT_EQ(1,u.baseUnitExponent("people")); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("people",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u.pow(-1); EXPECT_EQ("1/person",u.standardString(false)); u = createBTUEnergy(); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("Btu",u.standardString(false)); EXPECT_EQ("",u.prettyString()); u = createBTUPower(); EXPECT_EQ(0,u.scale().exponent); EXPECT_EQ("Btu/h",u.standardString(false)); EXPECT_EQ("",u.prettyString()); }
4,453
1,881
#include <iostream> #include <cmath> using namespace std; int main() { int nNum; int nSize; cin >> nNum; nSize = (nNum <= 0) ? (abs(nNum) + 2) : nNum; cout << nSize*(1+nNum)/2 << endl; return 0; }
209
100
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "quiche/spdy/core/spdy_pinnable_buffer_piece.h" #include <new> namespace spdy { SpdyPinnableBufferPiece::SpdyPinnableBufferPiece() : buffer_(nullptr), length_(0) {} SpdyPinnableBufferPiece::~SpdyPinnableBufferPiece() = default; void SpdyPinnableBufferPiece::Pin() { if (!storage_ && buffer_ != nullptr && length_ != 0) { storage_.reset(new char[length_]); std::copy(buffer_, buffer_ + length_, storage_.get()); buffer_ = storage_.get(); } } void SpdyPinnableBufferPiece::Swap(SpdyPinnableBufferPiece* other) { size_t length = length_; length_ = other->length_; other->length_ = length; const char* buffer = buffer_; buffer_ = other->buffer_; other->buffer_ = buffer; storage_.swap(other->storage_); } } // namespace spdy
940
339
#ifndef __MOCKITOPP_HPP__ #define __MOCKITOPP_HPP__ #include "exceptions.hpp" #include "matchers.hpp" #include "mock_object.hpp" #endif //__MOCKITOPP_HPP__
158
73
#include "system_details_to_json_converter.h" #include <ArduinoJson.h> namespace CDEM { String SystemDetailsToJsonConverter::to_json_string(String ip, String mac, String libVersion, String pcbVersion) { StaticJsonDocument<128> json; json["ip"] = ip; json["mac"] = mac; json["lib-version"] = libVersion; json["pcb-version"] = pcbVersion; String result = ""; serializeJson(json, result); return result; } };
446
151
#include "testing/testing.hpp" #include "routing/base/astar_algorithm.hpp" #include "routing/edge_estimator.hpp" #include "routing/index_graph.hpp" #include "routing/index_graph_serialization.hpp" #include "routing/index_graph_starter.hpp" #include "routing/vehicle_mask.hpp" #include "routing/routing_tests/index_graph_tools.hpp" #include "routing_common/car_model.hpp" #include "geometry/point2d.hpp" #include "coding/reader.hpp" #include "coding/writer.hpp" #include "base/assert.hpp" #include "base/math.hpp" #include "std/algorithm.hpp" #include "std/cstdint.hpp" #include "std/unique_ptr.hpp" #include "std/unordered_map.hpp" #include "std/vector.hpp" using namespace std; namespace { using namespace routing; using namespace routing_test; using Edge = TestIndexGraphTopology::Edge; void TestRoute(IndexGraphStarter::FakeVertex const & start, IndexGraphStarter::FakeVertex const & finish, size_t expectedLength, vector<Segment> const * expectedRoute, WorldGraph & graph) { IndexGraphStarter starter(start, finish, graph); vector<Segment> route; double timeSec; auto const resultCode = CalculateRoute(starter, route, timeSec); TEST_EQUAL(resultCode, AStarAlgorithm<IndexGraphStarter>::Result::OK, ()); TEST_GREATER(route.size(), 2, ()); // Erase fake points. route.erase(route.begin()); route.pop_back(); TEST_EQUAL(route.size(), expectedLength, ("route =", route)); if (expectedRoute) TEST_EQUAL(route, *expectedRoute, ()); } void TestEdges(IndexGraph & graph, Segment const & segment, vector<Segment> const & expectedTargets, bool isOutgoing) { ASSERT(segment.IsForward() || !graph.GetGeometry().GetRoad(segment.GetFeatureId()).IsOneWay(), ()); vector<SegmentEdge> edges; graph.GetEdgeList(segment, isOutgoing, edges); vector<Segment> targets; for (SegmentEdge const & edge : edges) targets.push_back(edge.GetTarget()); sort(targets.begin(), targets.end()); vector<Segment> sortedExpectedTargets(expectedTargets); sort(sortedExpectedTargets.begin(), sortedExpectedTargets.end()); TEST_EQUAL(targets, sortedExpectedTargets, ()); } void TestOutgoingEdges(IndexGraph & graph, Segment const & segment, vector<Segment> const & expectedTargets) { TestEdges(graph, segment, expectedTargets, true /* isOutgoing */); } void TestIngoingEdges(IndexGraph & graph, Segment const & segment, vector<Segment> const & expectedTargets) { TestEdges(graph, segment, expectedTargets, false /* isOutgoing */); } uint32_t AbsDelta(uint32_t v0, uint32_t v1) { return v0 > v1 ? v0 - v1 : v1 - v0; } } // namespace namespace routing_test { // R4 (one way down) // // R1 J2--------J3 -1 // ^ v // ^ v // R0 *---J0----*---J1----* 0 // ^ v // ^ v // R2 J4--------J5 1 // // R3 (one way up) y // // x: 0 1 2 3 4 // UNIT_TEST(EdgesTest) { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad( 0 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}, {3.0, 0.0}, {4.0, 0.0}})); loader->AddRoad(1 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{1.0, -1.0}, {3.0, -1.0}})); loader->AddRoad(2 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{1.0, -1.0}, {3.0, -1.0}})); loader->AddRoad(3 /* featureId */, true, 1.0 /* speed */, RoadGeometry::Points({{1.0, 1.0}, {1.0, 0.0}, {1.0, -1.0}})); loader->AddRoad(4 /* featureId */, true, 1.0 /* speed */, RoadGeometry::Points({{3.0, -1.0}, {3.0, 0.0}, {3.0, 1.0}})); traffic::TrafficCache const trafficCache; IndexGraph graph(move(loader), CreateEstimatorForCar(trafficCache)); vector<Joint> joints; joints.emplace_back(MakeJoint({{0, 1}, {3, 1}})); // J0 joints.emplace_back(MakeJoint({{0, 3}, {4, 1}})); // J1 joints.emplace_back(MakeJoint({{1, 0}, {3, 2}})); // J2 joints.emplace_back(MakeJoint({{1, 1}, {4, 0}})); // J3 joints.emplace_back(MakeJoint({{2, 0}, {3, 0}})); // J4 joints.emplace_back(MakeJoint({{2, 1}, {4, 2}})); // J5 graph.Import(joints); TestOutgoingEdges( graph, {kTestNumMwmId, 0 /* featureId */, 0 /* segmentIdx */, true /* forward */}, {{kTestNumMwmId, 0, 0, false}, {kTestNumMwmId, 0, 1, true}, {kTestNumMwmId, 3, 1, true}}); TestIngoingEdges(graph, {kTestNumMwmId, 0, 0, true}, {{kTestNumMwmId, 0, 0, false}}); TestOutgoingEdges(graph, {kTestNumMwmId, 0, 0, false}, {{kTestNumMwmId, 0, 0, true}}); TestIngoingEdges( graph, {kTestNumMwmId, 0, 0, false}, {{kTestNumMwmId, 0, 0, true}, {kTestNumMwmId, 0, 1, false}, {kTestNumMwmId, 3, 0, true}}); TestOutgoingEdges( graph, {kTestNumMwmId, 0, 2, true}, {{kTestNumMwmId, 0, 2, false}, {kTestNumMwmId, 0, 3, true}, {kTestNumMwmId, 4, 1, true}}); TestIngoingEdges(graph, {kTestNumMwmId, 0, 2, true}, {{kTestNumMwmId, 0, 1, true}}); TestOutgoingEdges(graph, {kTestNumMwmId, 0, 2, false}, {{kTestNumMwmId, 0, 1, false}}); TestIngoingEdges( graph, {kTestNumMwmId, 0, 2, false}, {{kTestNumMwmId, 0, 2, true}, {kTestNumMwmId, 0, 3, false}, {kTestNumMwmId, 4, 0, true}}); TestOutgoingEdges( graph, {kTestNumMwmId, 3, 0, true}, {{kTestNumMwmId, 3, 1, true}, {kTestNumMwmId, 0, 0, false}, {kTestNumMwmId, 0, 1, true}}); TestIngoingEdges(graph, {kTestNumMwmId, 3, 0, true}, {{kTestNumMwmId, 2, 0, false}}); TestOutgoingEdges(graph, {kTestNumMwmId, 4, 1, true}, {{kTestNumMwmId, 2, 0, false}}); TestIngoingEdges( graph, {kTestNumMwmId, 4, 1, true}, {{kTestNumMwmId, 4, 0, true}, {kTestNumMwmId, 0, 2, true}, {kTestNumMwmId, 0, 3, false}}); } // Roads R1: // // -2 // -1 // R0 -2 -1 0 1 2 // 1 // 2 // UNIT_TEST(FindPathCross) { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad( 0 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{-2.0, 0.0}, {-1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {2.0, 0.0}})); loader->AddRoad( 1 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{0.0, -2.0}, {0.0, -1.0}, {0.0, 0.0}, {0.0, 1.0}, {0.0, 2.0}})); traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); unique_ptr<WorldGraph> worldGraph = BuildWorldGraph(move(loader), estimator, {MakeJoint({{0, 2}, {1, 2}})}); vector<IndexGraphStarter::FakeVertex> endPoints; for (uint32_t i = 0; i < 4; ++i) { endPoints.emplace_back(kTestNumMwmId, 0, i, m2::PointD(-1.5 + i, 0.0)); endPoints.emplace_back(kTestNumMwmId, 1, i, m2::PointD(0.0, -1.5 + i)); } for (auto const & start : endPoints) { for (auto const & finish : endPoints) { uint32_t expectedLength = 0; if (start.GetFeatureId() == finish.GetFeatureId()) { expectedLength = AbsDelta(start.GetSegmentIdxForTesting(), finish.GetSegmentIdxForTesting()) + 1; } else { if (start.GetSegmentIdxForTesting() < 2) expectedLength += 2 - start.GetSegmentIdxForTesting(); else expectedLength += start.GetSegmentIdxForTesting() - 1; if (finish.GetSegmentIdxForTesting() < 2) expectedLength += 2 - finish.GetSegmentIdxForTesting(); else expectedLength += finish.GetSegmentIdxForTesting() - 1; } TestRoute(start, finish, expectedLength, nullptr, *worldGraph); } } } // Roads R4 R5 R6 R7 // // R0 0 - * - * - * // | | | | // R1 * - 1 - * - * // | | | | // R2 * - * - 2 - * // | | | | // R3 * - * - * - 3 // UNIT_TEST(FindPathManhattan) { uint32_t constexpr kCitySize = 4; unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); for (uint32_t i = 0; i < kCitySize; ++i) { RoadGeometry::Points street; RoadGeometry::Points avenue; for (uint32_t j = 0; j < kCitySize; ++j) { street.emplace_back(static_cast<double>(j), static_cast<double>(i)); avenue.emplace_back(static_cast<double>(i), static_cast<double>(j)); } loader->AddRoad(i, false, 1.0 /* speed */, street); loader->AddRoad(i + kCitySize, false, 1.0 /* speed */, avenue); } traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); vector<Joint> joints; for (uint32_t i = 0; i < kCitySize; ++i) { for (uint32_t j = 0; j < kCitySize; ++j) joints.emplace_back(MakeJoint({{i, j}, {j + kCitySize, i}})); } unique_ptr<WorldGraph> worldGraph = BuildWorldGraph(move(loader), estimator, joints); vector<IndexGraphStarter::FakeVertex> endPoints; for (uint32_t featureId = 0; featureId < kCitySize; ++featureId) { for (uint32_t segmentId = 0; segmentId < kCitySize - 1; ++segmentId) { endPoints.emplace_back(kTestNumMwmId, featureId, segmentId, m2::PointD(0.5 + segmentId, featureId)); endPoints.emplace_back(kTestNumMwmId, featureId + kCitySize, segmentId, m2::PointD(featureId, 0.5 + segmentId)); } } for (auto const & start : endPoints) { for (auto const & finish : endPoints) { uint32_t expectedLength = 0; auto const startFeatureOffset = start.GetFeatureId() < kCitySize ? start.GetFeatureId() : start.GetFeatureId() - kCitySize; auto const finishFeatureOffset = finish.GetFeatureId() < kCitySize ? finish.GetFeatureId() : finish.GetFeatureId() - kCitySize; if (start.GetFeatureId() < kCitySize == finish.GetFeatureId() < kCitySize) { uint32_t segDelta = AbsDelta(start.GetSegmentIdxForTesting(), finish.GetSegmentIdxForTesting()); if (segDelta == 0 && start.GetFeatureId() != finish.GetFeatureId()) segDelta = 1; expectedLength += segDelta; expectedLength += AbsDelta(startFeatureOffset, finishFeatureOffset) + 1; } else { if (start.GetSegmentIdxForTesting() < finishFeatureOffset) expectedLength += finishFeatureOffset - start.GetSegmentIdxForTesting(); else expectedLength += start.GetSegmentIdxForTesting() - finishFeatureOffset + 1; if (finish.GetSegmentIdxForTesting() < startFeatureOffset) expectedLength += startFeatureOffset - finish.GetSegmentIdxForTesting(); else expectedLength += finish.GetSegmentIdxForTesting() - startFeatureOffset + 1; } TestRoute(start, finish, expectedLength, nullptr, *worldGraph); } } } // Roads y: // // fast road R0 * - * - * -1 // / \ // slow road R1 * - - * - - * - - * - - * 0 // J0 J1 // // x: 0 1 2 3 4 5 6 // UNIT_TEST(RoadSpeed) { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad( 0 /* featureId */, false, 10.0 /* speed */, RoadGeometry::Points({{1.0, 0.0}, {2.0, -1.0}, {3.0, -1.0}, {4.0, -1.0}, {5.0, 0.0}})); loader->AddRoad( 1 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{0.0, 0.0}, {1.0, 0.0}, {3.0, 0.0}, {5.0, 0.0}, {6.0, 0.0}})); traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); vector<Joint> joints; joints.emplace_back(MakeJoint({{0, 0}, {1, 1}})); // J0 joints.emplace_back(MakeJoint({{0, 4}, {1, 3}})); // J1 unique_ptr<WorldGraph> worldGraph = BuildWorldGraph(move(loader), estimator, joints); IndexGraphStarter::FakeVertex const start(kTestNumMwmId, 1, 0, m2::PointD(0.5, 0)); IndexGraphStarter::FakeVertex const finish(kTestNumMwmId, 1, 3, m2::PointD(5.5, 0)); vector<Segment> const expectedRoute({{kTestNumMwmId, 1, 0, true}, {kTestNumMwmId, 0, 0, true}, {kTestNumMwmId, 0, 1, true}, {kTestNumMwmId, 0, 2, true}, {kTestNumMwmId, 0, 3, true}, {kTestNumMwmId, 1, 3, true}}); TestRoute(start, finish, 6, &expectedRoute, *worldGraph); } // Roads y: // // R0 * - - - - - - - - * 0 // ^ ^ // start finish // // x: 0 1 2 3 // UNIT_TEST(OneSegmentWay) { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad(0 /* featureId */, false, 1.0 /* speed */, RoadGeometry::Points({{0.0, 0.0}, {3.0, 0.0}})); traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); unique_ptr<WorldGraph> worldGraph = BuildWorldGraph(move(loader), estimator, vector<Joint>()); IndexGraphStarter::FakeVertex const start(kTestNumMwmId, 0, 0, m2::PointD(1, 0)); IndexGraphStarter::FakeVertex const finish(kTestNumMwmId, 0, 0, m2::PointD(2, 0)); vector<Segment> const expectedRoute({{kTestNumMwmId, 0, 0, true}}); TestRoute(start, finish, 1 /* expectedLength */, &expectedRoute, *worldGraph); } // // Road R0 (ped) R1 (car) R2 (car) // 0----------1 * 0----------1 * 0----------1 // Joints J0 J1 // UNIT_TEST(SerializeSimpleGraph) { vector<uint8_t> buffer; { IndexGraph graph; vector<Joint> joints = { MakeJoint({{0, 1}, {1, 0}}), MakeJoint({{1, 1}, {2, 0}}), }; graph.Import(joints); unordered_map<uint32_t, VehicleMask> masks; masks[0] = kPedestrianMask; masks[1] = kCarMask; masks[2] = kCarMask; MemWriter<vector<uint8_t>> writer(buffer); IndexGraphSerializer::Serialize(graph, masks, writer); } { IndexGraph graph; MemReader reader(buffer.data(), buffer.size()); ReaderSource<MemReader> source(reader); IndexGraphSerializer::Deserialize(graph, source, kAllVehiclesMask); TEST_EQUAL(graph.GetNumRoads(), 3, ()); TEST_EQUAL(graph.GetNumJoints(), 2, ()); TEST_EQUAL(graph.GetNumPoints(), 4, ()); TEST_EQUAL(graph.GetJointId({0, 0}), Joint::kInvalidId, ()); TEST_EQUAL(graph.GetJointId({0, 1}), 1, ()); TEST_EQUAL(graph.GetJointId({1, 0}), 1, ()); TEST_EQUAL(graph.GetJointId({1, 1}), 0, ()); TEST_EQUAL(graph.GetJointId({2, 0}), 0, ()); TEST_EQUAL(graph.GetJointId({2, 1}), Joint::kInvalidId, ()); } { IndexGraph graph; MemReader reader(buffer.data(), buffer.size()); ReaderSource<MemReader> source(reader); IndexGraphSerializer::Deserialize(graph, source, kCarMask); TEST_EQUAL(graph.GetNumRoads(), 2, ()); TEST_EQUAL(graph.GetNumJoints(), 1, ()); TEST_EQUAL(graph.GetNumPoints(), 2, ()); TEST_EQUAL(graph.GetJointId({0, 0}), Joint::kInvalidId, ()); TEST_EQUAL(graph.GetJointId({0, 1}), Joint::kInvalidId, ()); TEST_EQUAL(graph.GetJointId({1, 0}), Joint::kInvalidId, ()); TEST_EQUAL(graph.GetJointId({1, 1}), 0, ()); TEST_EQUAL(graph.GetJointId({2, 0}), 0, ()); TEST_EQUAL(graph.GetJointId({2, 1}), Joint::kInvalidId, ()); } } // Finish // 0.0004 * // ^ // | // F2 // | // | // 0.0003 6*---------*5 // | | // | | // | | // | | // | | // 0.0002 7* *4 // | | // | | // 0.00015 8* F0 *3 // \ / // \ / 1 0 // 0.0001 9*---F0-*----* // 2 ^ // | // F1 // | // | // 0 * Start // 0 0.0001 0.0002 // F0 is a two-way feature with a loop and F1 and F2 are an one-way one-segment features. unique_ptr<WorldGraph> BuildLoopGraph() { unique_ptr<TestGeometryLoader> loader = make_unique<TestGeometryLoader>(); loader->AddRoad(0 /* feature id */, false /* one way */, 100.0 /* speed */, RoadGeometry::Points({{0.0002, 0.0001}, {0.00015, 0.0001}, {0.0001, 0.0001}, {0.00015, 0.00015}, {0.00015, 0.0002}, {0.00015, 0.0003}, {0.00005, 0.0003}, {0.00005, 0.0002}, {0.00005, 0.00015}, {0.0001, 0.0001}})); loader->AddRoad(1 /* feature id */, true /* one way */, 100.0 /* speed */, RoadGeometry::Points({{0.0002, 0.0}, {0.0002, 0.0001}})); loader->AddRoad(2 /* feature id */, true /* one way */, 100.0 /* speed */, RoadGeometry::Points({{0.00005, 0.0003}, {0.00005, 0.0004}})); vector<Joint> const joints = { MakeJoint({{0 /* feature id */, 2 /* point id */}, {0, 9}}), /* joint at point (0.0002, 0) */ MakeJoint({{1, 1}, {0, 0}}), /* joint at point (0.0002, 0.0001) */ MakeJoint({{0, 6}, {2, 0}}), /* joint at point (0.00005, 0.0003) */ MakeJoint({{2, 1}}), /* joint at point (0.00005, 0.0004) */ }; traffic::TrafficCache const trafficCache; shared_ptr<EdgeEstimator> estimator = CreateEstimatorForCar(trafficCache); return BuildWorldGraph(move(loader), estimator, joints); } // This test checks that the route from Start to Finish doesn't make an extra loop in F0. // If it was so the route time had been much more. UNIT_CLASS_TEST(RestrictionTest, LoopGraph) { Init(BuildLoopGraph()); SetStarter(routing::IndexGraphStarter::FakeVertex(kTestNumMwmId, 1, 0 /* seg id */, m2::PointD(0.0002, 0)) /* start */, routing::IndexGraphStarter::FakeVertex(kTestNumMwmId, 2, 0 /* seg id */, m2::PointD(0.00005, 0.0004)) /* finish */); vector<Segment> const expectedRoute = {{kTestNumMwmId, 1, 0, true}, {kTestNumMwmId, 0, 0, true}, {kTestNumMwmId, 0, 1, true}, {kTestNumMwmId, 0, 8, false}, {kTestNumMwmId, 0, 7, false}, {kTestNumMwmId, 0, 6, false}, {kTestNumMwmId, 2, 0, true}}; TestRoute(m_starter->GetStartVertex(), m_starter->GetFinishVertex(), 7, &expectedRoute, m_starter->GetGraph()); } UNIT_TEST(IndexGraph_OnlyTopology_1) { // Add edges to the graph in the following format: (from, to, weight). uint32_t const numVertices = 5; TestIndexGraphTopology graph(numVertices); graph.AddDirectedEdge(0, 1, 1.0); graph.AddDirectedEdge(0, 2, 2.0); graph.AddDirectedEdge(1, 3, 1.0); graph.AddDirectedEdge(2, 3, 2.0); double const expectedWeight = 2.0; vector<Edge> const expectedEdges = {{0, 1}, {1, 3}}; TestTopologyGraph(graph, 0, 3, true /* pathFound */, expectedWeight, expectedEdges); TestTopologyGraph(graph, 0, 4, false /* pathFound */, 0.0, {}); } UNIT_TEST(IndexGraph_OnlyTopology_2) { uint32_t const numVertices = 1; TestIndexGraphTopology graph(numVertices); graph.AddDirectedEdge(0, 0, 100.0); double const expectedWeight = 0.0; vector<Edge> const expectedEdges = {}; TestTopologyGraph(graph, 0, 0, true /* pathFound */, expectedWeight, expectedEdges); } UNIT_TEST(IndexGraph_OnlyTopology_3) { uint32_t const numVertices = 2; TestIndexGraphTopology graph(numVertices); graph.AddDirectedEdge(0, 1, 1.0); graph.AddDirectedEdge(1, 0, 1.0); double const expectedWeight = 1.0; vector<Edge> const expectedEdges = {{0, 1}}; TestTopologyGraph(graph, 0, 1, true /* pathFound */, expectedWeight, expectedEdges); } } // namespace routing_test
20,448
7,881
#include "gameState.h" #include <stdio.h> /* o gameState de cada fase possui um cen�rio, um conjunto de alienigenas(inimigos), um conjunto de objetos (stuff) que podem ser lan�ados pelos inimigos ou pela nave principal a nave principal ** ao passar a token init_cg pode ser pelo loadGame ou NewGame ------ <init_cg> ------------------- |Menu| *----------------> | CG Antes Jogo | ------ ------------------- ^ * ^ | <init_play>| |<init_cg> | v | | ------- <pause> ------ | |-* |Pause| <-----------> |Jogo| | | ------- ------ | | * <stage_clear> * * | | | | | | | -----------------------------| | | | | <to_menu>| |---------- | | | v | | | ----------------- | | |-----* | fase completa | *-------| | ----------------- | | | | | | <bad_stage>| | | v | | ------------------- | |---------* | fase incompleta | *-- ------------------- */ //------------------------------------------------------------------------------ const char* gamestateToStr(GAMESTATE_STATES_ENUM state) { switch (state) { case GS_MENU:return "menu"; case GS_CG_BEFORE_PLAY:return "cg_before_play"; case GS_PLAY:return "play"; case GS_PAUSE:return "pause"; case GS_STAGE_COMPLETE:return "stage complete"; case GS_STAGE_INCOMPLETE:return "stage incomplete"; case GS_CONGRATULATIONS: return "congratulations"; } return "unknown state"; } //------------------------------------------------------------------------------ GameState::GameState(SpaceInvader *si) : menu(si), cgReproducer(si), playState(si), pauseState(si) { globalGamestate = GS_MENU; this->spaceInvader = si; } //------------------------------------------------------------------------------ void GameState::resizeWindow(int w, int h) { /* deve atualizar todos os componentes internos */ playState.resizeWindow(w, h); pauseState.resizeWindow(w, h); cgReproducer.resizeWindow(w, h); } //------------------------------------------------------------------------------ /* tem efeito no estado: PLAY */ //void GameState::setNaveMovingInput(MovingParserInput movingInput){ // if (globalGamestate != GS_PLAY) return; // playState.gamePlay.getNavePrincipal()->setInput(movingInput); // navePrincipal.setInput(movingInput); //} //------------------------------------------------------------------------------ /* tem efeito no estado: PLAY */ //void GameState::setNaveShootingInput(ShootingParserInput shootInput){ // if (globalGamestate != GS_PLAY) return; // playState.gamePlay.getNavePrincipal()->setShootInput(shootInput); // navePrincipal.setShootInput(shootInput); //} //------------------------------------------------------------------------------ /* tem efeito no estado: PLAY */ //void GameState::setNaveLifeInput(LifeParserInput lifeInput){ // if (globalGamestate != GS_PLAY) return; // navePrincipal.setLifeInput(lifeInput); //} //------------------------------------------------------------------------------ /* retorna true se for para sair do jogo tem efeito somente no estado: MENU */ bool GameState::setMenuInput(MENU_TOKENS menuInput) { if (globalGamestate != GS_MENU) return false; if (menu.inputMenu(menuInput)) { //OK switch (menu.getMenuState()) { case MS_NEW_GAME: //reset playState code spaceInvader->resources->setMusic(1); globalGamestate = GS_CG_BEFORE_PLAY; cgReproducer.setScoreLeve(0, 1); playState.resetPlayState(); return false; case MS_LOAD_GAME: //load playState code // globalGamestate = GS_CG_BEFORE_PLAY; return false; case MS_EXIT_GAME: return true; default: break; } } return false; } //------------------------------------------------------------------------------ /* tem efeito no estado: CG_BEFORE_PLAY */ bool GameState::cgReproducerIsTerminatedCheck() { if (globalGamestate != GS_CG_BEFORE_PLAY) return false; if (cgReproducer.cgReproducerIsTerminated()) { spaceInvader->resources->setMusic(2); globalGamestate = GS_PLAY; playState.createPlaystate(); return true; } return false; } //------------------------------------------------------------------------------ /* tem efeito no estado: PLAY PAUSE */ void GameState::postPauseToken() { // if (globalGamestate != GS_PLAY && globalGamestate != GS_PAUSE) return; parseGS(GS_pause); } //------------------------------------------------------------------------------ /* tem efeito no estado: PAUSE STAGE_COMPLETE STAGE_INCOMPLETE */ void GameState::postToMenuToken() { // if (globalGamestate != GS_PAUSE && // globalGamestate != GS_STAGE_COMPLETE && // globalGamestate != GS_STAGE_INCOMPLETE ) return; parseGS(GS_to_menu); } //------------------------------------------------------------------------------ /* m�todo que � chamado sempre que � para se fazer o calculo de um movimento no jogo */ void GameState::simulationTick() { switch (globalGamestate) { case GS_MENU: return; case GS_CG_BEFORE_PLAY: return; case GS_PLAY: playState.simulationTick(); if (playState.scene.isLevelComplete()) { spaceInvader->resources->setMusic(1); parseGS(GS_stage_clear); } // navePrincipal.simulationTick(); return; case GS_PAUSE: return; case GS_STAGE_COMPLETE: return; case GS_STAGE_INCOMPLETE: return; default: break; } } //------------------------------------------------------------------------------ void GameState::printState() { printf("GAME STATE\n"); printf(" globalGamestate = %s\n", gamestateToStr(globalGamestate)); printf("\n"); switch (globalGamestate) { case GS_MENU: menu.printState(); return; case GS_CG_BEFORE_PLAY: cgReproducer.printState(); return; case GS_PLAY: playState.printState(); //navePrincipal.printState(); return; case GS_PAUSE: return; case GS_STAGE_COMPLETE: return; case GS_STAGE_INCOMPLETE: return; default: break; } } //------------------------------------------------------------------------------ void GameState::render(float deltaTime, const vec2& screenCenter) { switch (globalGamestate) { case GS_MENU: menu.render(deltaTime); return; case GS_CG_BEFORE_PLAY: cgReproducer.render(deltaTime, screenCenter); // menu.render(time); return; case GS_PLAY: playState.render(deltaTime, screenCenter*2.0f); // navePrincipal.render(); return; case GS_PAUSE: pauseState.render(deltaTime, screenCenter); return; case GS_STAGE_COMPLETE: return; case GS_STAGE_INCOMPLETE: return; case GS_CONGRATULATIONS: playState.scene.renderCongratulations(screenCenter, deltaTime); return; } } //------------------------------------------------------------------------------ void GameState::parseGS(GAMESTATE_TOKENS_ENUM token) { switch (globalGamestate) { //menu case GS_MENU: switch (token) { case GS_init_cg: spaceInvader->resources->setMusic(1); playState.scene.clear(); cgReproducer.setScoreLeve(0, 1); globalGamestate = GS_CG_BEFORE_PLAY; return; default: break; } return; //cg_before_play case GS_CG_BEFORE_PLAY: switch (token) { case GS_init_play: spaceInvader->resources->setMusic(2); globalGamestate = GS_PLAY; return; default: break; } return; //play case GS_PLAY: switch (token) { case GS_pause: globalGamestate = GS_PAUSE; return; case GS_stage_clear: if (playState.resetPlayStateToNextLevel()) { //zero o jogo globalGamestate = GS_CONGRATULATIONS; return; } cgReproducer.setScoreLeve(playState.scene.score, playState.level); globalGamestate = GS_CG_BEFORE_PLAY;//GS_STAGE_COMPLETE; return; case GS_bad_stage: globalGamestate = GS_STAGE_INCOMPLETE; return; default: break; } return; //pause case GS_PAUSE: switch (token) { case GS_init_cg: spaceInvader->resources->setMusic(1); globalGamestate = GS_CG_BEFORE_PLAY; return; case GS_pause: globalGamestate = GS_PLAY; return; case GS_to_menu: spaceInvader->resources->setMusic(0); globalGamestate = GS_MENU; return; default: break; } return; //stage complete case GS_STAGE_COMPLETE: switch (token) { case GS_init_cg: spaceInvader->resources->setMusic(1); globalGamestate = GS_CG_BEFORE_PLAY; return; case GS_to_menu: spaceInvader->resources->setMusic(0); globalGamestate = GS_MENU; return; default: break; } return; //stage incomplete case GS_STAGE_INCOMPLETE: switch (token) { case GS_init_cg: spaceInvader->resources->setMusic(1); globalGamestate = GS_CG_BEFORE_PLAY; return; case GS_to_menu: spaceInvader->resources->setMusic(0); globalGamestate = GS_MENU; return; default: break; } return; default: break; } } //------------------------------------------------------------------------------ void GameState::shoot() { if (globalGamestate != GS_PLAY) return; playState.shoot(); } //------------------------------------------------------------------------------ void GameState::moveSpaceShip(float velocity) { if (globalGamestate != GS_PLAY) return; playState.moveSpaceShip(velocity); } //------------------------------------------------------------------------------ void GameState::enterPress() { if (globalGamestate == GS_PLAY) { if (!playState.scene.activateSpaceShip()) { spaceInvader->resources->setMusic(0); globalGamestate = GS_MENU; } } else if (globalGamestate == GS_CONGRATULATIONS) { spaceInvader->resources->setMusic(0); globalGamestate = GS_MENU; } } //------------------------------------------------------------------------------
11,564
3,468
// Copyright (C) 2020-2021 Jonathan Müller <jonathanmueller.dev@gmail.com> // This file is subject to the license terms in the LICENSE file // found in the top-level directory of this distribution. #ifndef LEXY_INPUT_RANGE_INPUT_HPP_INCLUDED #define LEXY_INPUT_RANGE_INPUT_HPP_INCLUDED #include <lexy/error.hpp> #include <lexy/input/base.hpp> #include <lexy/lexeme.hpp> namespace lexy { template <typename Encoding, typename Iterator, typename Sentinel = Iterator> class range_input { public: using encoding = Encoding; using char_type = typename encoding::char_type; using iterator = Iterator; //=== constructors ===// constexpr range_input() noexcept : _begin(), _end() {} constexpr range_input(Iterator begin, Sentinel end) noexcept : _begin(begin), _end(end) {} //=== access ===// constexpr iterator begin() const noexcept { return _begin; } constexpr iterator end() const noexcept { return _end; } //=== reader ===// constexpr auto reader() const& noexcept { return _detail::range_reader<Encoding, Iterator, Sentinel>(_begin, _end); } private: Iterator _begin; LEXY_EMPTY_MEMBER Sentinel _end; }; template <typename Iterator, typename Sentinel> range_input(Iterator begin, Sentinel end) -> range_input<deduce_encoding<std::decay_t<decltype(*begin)>>, Iterator, Sentinel>; } // namespace lexy #endif // LEXY_INPUT_RANGE_INPUT_HPP_INCLUDED
1,479
510
/* * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com> */ #pragma once #include <climits> #include <cstddef> #include <cmath> #include <uavcan/build_config.hpp> #ifndef UAVCAN_CPP_VERSION # error UAVCAN_CPP_VERSION #endif #if UAVCAN_CPP_VERSION < UAVCAN_CPP11 # include <float.h> // cfloat may not be available #else # include <cfloat> // C++11 mode assumes that all standard headers are available #endif namespace uavcan { /** * Usage: * StaticAssert<expression>::check(); */ template <bool Value> struct UAVCAN_EXPORT StaticAssert; template <> struct UAVCAN_EXPORT StaticAssert<true> { static void check() { } }; /** * Usage: * ShowIntegerAsError<integer_expression>::foobar(); */ template <long N> struct ShowIntegerAsError; /** * Prevents copying when inherited */ class UAVCAN_EXPORT Noncopyable { Noncopyable(const Noncopyable&); Noncopyable& operator=(const Noncopyable&); protected: Noncopyable() { } ~Noncopyable() { } }; /** * Compile time conditions */ template <bool B, typename T = void> struct UAVCAN_EXPORT EnableIf { }; template <typename T> struct UAVCAN_EXPORT EnableIf<true, T> { typedef T Type; }; /** * Lightweight type categorization. */ template <typename T, typename R = void> struct UAVCAN_EXPORT EnableIfType { typedef R Type; }; /** * Compile-time type selection (Alexandrescu) */ template <bool Condition, typename TrueType, typename FalseType> struct UAVCAN_EXPORT Select; template <typename TrueType, typename FalseType> struct UAVCAN_EXPORT Select<true, TrueType, FalseType> { typedef TrueType Result; }; template <typename TrueType, typename FalseType> struct UAVCAN_EXPORT Select<false, TrueType, FalseType> { typedef FalseType Result; }; /** * Value types */ template <bool> struct UAVCAN_EXPORT BooleanType { }; typedef BooleanType<true> TrueType; typedef BooleanType<false> FalseType; /** * Relations */ template <typename T1, typename T2> class UAVCAN_EXPORT IsImplicitlyConvertibleFromTo { template <typename U> static U returner(); struct True_ { char x[2]; }; struct False_ { }; static True_ test(const T2 &); static False_ test(...); public: enum { Result = sizeof(True_) == sizeof(IsImplicitlyConvertibleFromTo<T1, T2>::test(returner<T1>())) }; }; /** * try_implicit_cast<>(From) * try_implicit_cast<>(From, To) * @{ */ template <typename From, typename To> struct UAVCAN_EXPORT TryImplicitCastImpl { static To impl(const From& from, const To&, TrueType) { return To(from); } static To impl(const From&, const To& default_, FalseType) { return default_; } }; /** * If possible, performs an implicit cast from the type From to the type To. * If the cast is not possible, returns default_ of type To. */ template <typename To, typename From> UAVCAN_EXPORT To try_implicit_cast(const From& from, const To& default_) { return TryImplicitCastImpl<From, To>::impl(from, default_, BooleanType<IsImplicitlyConvertibleFromTo<From, To>::Result>()); } /** * If possible, performs an implicit cast from the type From to the type To. * If the cast is not possible, returns a default constructed object of the type To. */ template <typename To, typename From> UAVCAN_EXPORT To try_implicit_cast(const From& from) { return TryImplicitCastImpl<From, To>::impl(from, To(), BooleanType<IsImplicitlyConvertibleFromTo<From, To>::Result>()); } /** * @} */ /** * Compile time square root for integers. * Useful for operations on square matrices. */ template <unsigned Value> struct UAVCAN_EXPORT CompileTimeIntSqrt; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<4> { enum { Result = 2 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<9> { enum { Result = 3 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<16> { enum { Result = 4 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<25> { enum { Result = 5 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<36> { enum { Result = 6 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<49> { enum { Result = 7 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<64> { enum { Result = 8 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<81> { enum { Result = 9 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<100> { enum { Result = 10 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<121> { enum { Result = 11 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<144> { enum { Result = 12 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<169> { enum { Result = 13 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<196> { enum { Result = 14 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<225> { enum { Result = 15 }; }; template <> struct UAVCAN_EXPORT CompileTimeIntSqrt<256> { enum { Result = 16 }; }; /** * Replacement for std::copy(..) */ template <typename InputIt, typename OutputIt> UAVCAN_EXPORT OutputIt copy(InputIt first, InputIt last, OutputIt result) { while (first != last) { *result = *first; ++first; ++result; } return result; } /** * Replacement for std::fill(..) */ template <typename ForwardIt, typename T> UAVCAN_EXPORT void fill(ForwardIt first, ForwardIt last, const T& value) { while (first != last) { *first = value; ++first; } } /** * Replacement for std::fill_n(..) */ template<typename OutputIt, typename T> UAVCAN_EXPORT void fill_n(OutputIt first, std::size_t n, const T& value) { while (n--) { *first++ = value; } } /** * Replacement for std::min(..) */ template <typename T> UAVCAN_EXPORT const T& min(const T& a, const T& b) { return (b < a) ? b : a; } /** * Replacement for std::max(..) */ template <typename T> UAVCAN_EXPORT const T& max(const T& a, const T& b) { return (a < b) ? b : a; } /** * Replacement for std::lexicographical_compare(..) */ template<typename InputIt1, typename InputIt2> UAVCAN_EXPORT bool lexicographical_compare(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) { while ((first1 != last1) && (first2 != last2)) { if (*first1 < *first2) { return true; } if (*first2 < *first1) { return false; } ++first1; ++first2; } return (first1 == last1) && (first2 != last2); } /** * Replacement for std::equal(..) */ template<typename InputIt1, typename InputIt2> UAVCAN_EXPORT bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2) { while (first1 != last1) { if (*first1 != *first2) { return false; } ++first1; ++first2; } return true; } /** * Numeric traits, like std::numeric_limits<> */ template <typename T> struct UAVCAN_EXPORT NumericTraits; /// char template <> struct UAVCAN_EXPORT NumericTraits<char> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static char max() { return CHAR_MAX; } static char min() { return CHAR_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<signed char> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static signed char max() { return SCHAR_MAX; } static signed char min() { return SCHAR_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned char> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned char max() { return UCHAR_MAX; } static unsigned char min() { return 0; } }; /// short template <> struct UAVCAN_EXPORT NumericTraits<short> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static short max() { return SHRT_MAX; } static short min() { return SHRT_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned short> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned short max() { return USHRT_MAX; } static unsigned short min() { return 0; } }; /// int template <> struct UAVCAN_EXPORT NumericTraits<int> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static int max() { return INT_MAX; } static int min() { return INT_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned int> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned int max() { return UINT_MAX; } static unsigned int min() { return 0; } }; /// long template <> struct UAVCAN_EXPORT NumericTraits<long> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static long max() { return LONG_MAX; } static long min() { return LONG_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned long> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned long max() { return ULONG_MAX; } static unsigned long min() { return 0; } }; /// long long template <> struct UAVCAN_EXPORT NumericTraits<long long> { enum { IsSigned = 1 }; enum { IsInteger = 1 }; static long long max() { return LLONG_MAX; } static long long min() { return LLONG_MIN; } }; template <> struct UAVCAN_EXPORT NumericTraits<unsigned long long> { enum { IsSigned = 0 }; enum { IsInteger = 1 }; static unsigned long long max() { return ULLONG_MAX; } static unsigned long long min() { return 0; } }; /// float template <> struct UAVCAN_EXPORT NumericTraits<float> { enum { IsSigned = 1 }; enum { IsInteger = 0 }; static float max() { return FLT_MAX; } static float min() { return FLT_MIN; } static float infinity() { return INFINITY; } }; /// double template <> struct UAVCAN_EXPORT NumericTraits<double> { enum { IsSigned = 1 }; enum { IsInteger = 0 }; static double max() { return DBL_MAX; } static double min() { return DBL_MIN; } static double infinity() { return static_cast<double>(INFINITY) * static_cast<double>(INFINITY); } }; /// long double template <> struct UAVCAN_EXPORT NumericTraits<long double> { enum { IsSigned = 1 }; enum { IsInteger = 0 }; static long double max() { return LDBL_MAX; } static long double min() { return LDBL_MIN; } static long double infinity() { return static_cast<long double>(INFINITY) * static_cast<long double>(INFINITY); } }; }
10,278
3,552
#pragma once // This file is generated from the Game's Reflection data #include <cstdint> #include <RED4ext/Common.hpp> #include <RED4ext/Scripting/Natives/Generated/ink/anim/TextInterpolator.hpp> namespace RED4ext { namespace ink::anim { struct TextReplaceInterpolator : ink::anim::TextInterpolator { static constexpr const char* NAME = "inkanimTextReplaceInterpolator"; static constexpr const char* ALIAS = NAME; }; RED4EXT_ASSERT_SIZE(TextReplaceInterpolator, 0x70); } // namespace ink::anim } // namespace RED4ext
531
178
#include <Windows.h> int main(int argc, char *argv[]) { HANDLE hMutex = NULL; do { hMutex = CreateMutex(NULL, FALSE, "Global\\73E21C80-1960-472F-BF0B-3EE7CC7AF17E"); DWORD dwError = GetLastError(); if (ERROR_ALREADY_EXISTS == dwError || ERROR_ACCESS_DENIED == dwError) { break; } // do something here // ... } while (false); if (NULL != hMutex) { CloseHandle(hMutex); } return 0; }
500
205
/* Copyright (c) 2013 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ #include "util/test.h" #include "util/trace.h" using namespace lean; int main() { lean_assert(!is_trace_enabled("name")); enable_trace("name"); lean_assert(is_trace_enabled("name")); disable_trace("name"); lean_assert(!is_trace_enabled("name")); return has_violations() ? 1 : 0; }
470
159
// This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // // Copyright (C) 2018 Intel Corporation #ifndef OPENCV_GAPI_GCOMPUTATION_HPP #define OPENCV_GAPI_GCOMPUTATION_HPP #include <functional> #include "opencv2/gapi/util/util.hpp" #include "opencv2/gapi/gcommon.hpp" #include "opencv2/gapi/gproto.hpp" #include "opencv2/gapi/garg.hpp" #include "opencv2/gapi/gcompiled.hpp" namespace cv { namespace detail { // FIXME: move to algorithm, cover with separate tests // FIXME: replace with O(1) version (both memory and compilation time) template<typename...> struct last_type; template<typename T> struct last_type<T> { using type = T;}; template<typename T, typename... Ts> struct last_type<T, Ts...> { using type = typename last_type<Ts...>::type; }; template<typename... Ts> using last_type_t = typename last_type<Ts...>::type; } class GAPI_EXPORTS GComputation { public: class Priv; typedef std::function<GComputation()> Generator; // Various constructors enable different ways to define a computation: ///// // 1. Generic constructors GComputation(const Generator& gen); // Generator overload GComputation(GProtoInputArgs &&ins, GProtoOutputArgs &&outs); // Arg-to-arg overload // 2. Syntax sugar and compatibility overloads GComputation(GMat in, GMat out); // Unary overload GComputation(GMat in, GScalar out); // Unary overload (scalar) GComputation(GMat in1, GMat in2, GMat out); // Binary overload GComputation(GMat in1, GMat in2, GScalar out); // Binary overload (scalar) GComputation(const std::vector<GMat> &ins, // Compatibility overload const std::vector<GMat> &outs); // Various versions of apply(): //////////////////////////////////////////// // 1. Generic apply() void apply(GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); // Arg-to-arg overload void apply(const std::vector<cv::gapi::own::Mat>& ins, // Compatibility overload const std::vector<cv::gapi::own::Mat>& outs, GCompileArgs &&args = {}); // 2. Syntax sugar and compatibility overloads #if !defined(GAPI_STANDALONE) void apply(cv::Mat in, cv::Mat &out, GCompileArgs &&args = {}); // Unary overload void apply(cv::Mat in, cv::Scalar &out, GCompileArgs &&args = {}); // Unary overload (scalar) void apply(cv::Mat in1, cv::Mat in2, cv::Mat &out, GCompileArgs &&args = {}); // Binary overload void apply(cv::Mat in1, cv::Mat in2, cv::Scalar &out, GCompileArgs &&args = {}); // Binary overload (scalar) void apply(const std::vector<cv::Mat>& ins, // Compatibility overload const std::vector<cv::Mat>& outs, GCompileArgs &&args = {}); #endif // !defined(GAPI_STANDALONE) // Various versions of compile(): ////////////////////////////////////////// // 1. Generic compile() - requires metas to be passed as vector GCompiled compile(GMetaArgs &&in_metas, GCompileArgs &&args = {}); // 2. Syntax sugar - variadic list of metas, no extra compile args template<typename... Ts> auto compile(const Ts&... metas) -> typename std::enable_if<detail::are_meta_descrs<Ts...>::value, GCompiled>::type { return compile(GMetaArgs{GMetaArg(metas)...}, GCompileArgs()); } // 3. Syntax sugar - variadic list of metas, extra compile args // (seems optional parameters don't work well when there's an variadic template // comes first) // // Ideally it should look like: // // template<typename... Ts> // GCompiled compile(const Ts&... metas, GCompileArgs &&args) // // But not all compilers can hande this (and seems they shouldn't be able to). template<typename... Ts> auto compile(const Ts&... meta_and_compile_args) -> typename std::enable_if<detail::are_meta_descrs_but_last<Ts...>::value && std::is_same<GCompileArgs, detail::last_type_t<Ts...> >::value, GCompiled>::type { //FIXME: wrapping meta_and_compile_args into a tuple to unwrap them inside a helper function is the overkill return compile(std::make_tuple(meta_and_compile_args...), typename detail::MkSeq<sizeof...(Ts)-1>::type()); } // Internal use only Priv& priv(); const Priv& priv() const; protected: // 4. Helper method for (3) template<typename... Ts, int... IIs> GCompiled compile(const std::tuple<Ts...> &meta_and_compile_args, detail::Seq<IIs...>) { GMetaArgs meta_args = {GMetaArg(std::get<IIs>(meta_and_compile_args))...}; GCompileArgs comp_args = std::get<sizeof...(Ts)-1>(meta_and_compile_args); return compile(std::move(meta_args), std::move(comp_args)); } std::shared_ptr<Priv> m_priv; }; namespace gapi { // Declare an Island tagged with `name` and defined from `ins` to `outs` // (exclusively, as ins/outs are data objects, and regioning is done on // operations level). // Throws if any operation between `ins` and `outs` are already assigned // to another island. void GAPI_EXPORTS island(const std::string &name, GProtoInputArgs &&ins, GProtoOutputArgs &&outs); } // namespace gapi } // namespace cv #endif // OPENCV_GAPI_GCOMPUTATION_HPP
5,671
1,776
//===-- ClangExpressionVariable.cpp -----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "ClangExpressionVariable.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "clang/AST/ASTContext.h" using namespace lldb_private; using namespace clang; ClangExpressionVariable::ClangExpressionVariable( ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) : ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(), m_jit_vars() { m_flags = EVNone; m_frozen_sp = ValueObjectConstResult::Create(exe_scope, byte_order, addr_byte_size); } ClangExpressionVariable::ClangExpressionVariable( ExecutionContextScope *exe_scope, Value &value, const ConstString &name, uint16_t flags) : ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(), m_jit_vars() { m_flags = flags; m_frozen_sp = ValueObjectConstResult::Create(exe_scope, value, name); } ClangExpressionVariable::ClangExpressionVariable( const lldb::ValueObjectSP &valobj_sp) : ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(), m_jit_vars() { m_flags = EVNone; m_frozen_sp = valobj_sp; } ClangExpressionVariable::ClangExpressionVariable( ExecutionContextScope *exe_scope, const ConstString &name, const TypeFromUser &user_type, lldb::ByteOrder byte_order, uint32_t addr_byte_size) : ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(), m_jit_vars() { m_flags = EVNone; m_frozen_sp = ValueObjectConstResult::Create(exe_scope, byte_order, addr_byte_size); SetName(name); SetCompilerType(user_type); } TypeFromUser ClangExpressionVariable::GetTypeFromUser() { TypeFromUser tfu(m_frozen_sp->GetCompilerType()); return tfu; }
2,219
747
//@result 151 / 151 test cases passed. Status: Accepted Runtime: 580 ms Submitted: 1 minute ago You are here! Your runtime beats 65.83% of cpp submissions. /** * Definition for an interval. * struct Interval { * int start; * int end; * Interval() : start(0), end(0) {} * Interval(int s, int e) : start(s), end(e) {} * }; */ class Solution { public: vector<Interval> insert(vector<Interval> &intervals, Interval newInterval) { vector<Interval> ans; size_t i = 0; for (i = 0; i < intervals.size() && intervals[i].end < newInterval.start; ++i) { ans.push_back(intervals[i]); } for (; i < intervals.size() && intervals[i].start <= newInterval.end; ++i) { newInterval.start = std::min(newInterval.start, intervals[i].start); newInterval.end = std::max(newInterval.end, intervals[i].end); } ans.push_back(newInterval); for (; i < intervals.size(); ++i) { ans.push_back(intervals[i]); } return ans; } };
948
367
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Mozilla Communicator client code, released * March 31, 1998. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * John Bandhauer <jband@netscape.com> * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsISupports.h" #include "xpctest_const.h" #include "xpctest_private.h" class xpcTestConst : public nsIXPCTestConst { public: NS_DECL_ISUPPORTS NS_DECL_NSIXPCTESTCONST xpcTestConst(); }; NS_IMPL_ISUPPORTS1(xpcTestConst, nsIXPCTestConst) xpcTestConst :: xpcTestConst() { NS_ADDREF_THIS(); } nsresult xpctest::ConstructXPCTestConst(nsISupports *aOuter, REFNSIID aIID, void **aResult) { nsresult rv; NS_ASSERTION(aOuter == nsnull, "no aggregation"); xpcTestConst *obj = new xpcTestConst(); if(obj) { rv = obj->QueryInterface(aIID, aResult); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface"); NS_RELEASE(obj); } else { *aResult = nsnull; rv = NS_ERROR_OUT_OF_MEMORY; } return rv; }
2,664
884
// Warning! This file is autogenerated. #include <boost/text/collation_table.hpp> #include <boost/text/collate.hpp> #include <boost/text/data/all.hpp> #ifndef LIMIT_TESTING_FOR_CI #include <boost/text/save_load_table.hpp> #include <boost/filesystem.hpp> #endif #include <gtest/gtest.h> using namespace boost::text; auto const error = [](string const & s) { std::cout << s; }; auto const warning = [](string const & s) {}; collation_table make_save_load_table() { #ifdef LIMIT_TESTING_FOR_CI string const table_str(data::zh::big5han_collation_tailoring()); return tailored_collation_table( table_str, "zh::big5han_collation_tailoring()", error, warning); #else if (!exists(boost::filesystem::path("zh_big5han.table"))) { string const table_str(data::zh::big5han_collation_tailoring()); collation_table table = tailored_collation_table( table_str, "zh::big5han_collation_tailoring()", error, warning); save_table(table, "zh_big5han.table.12"); boost::filesystem::rename("zh_big5han.table.12", "zh_big5han.table"); } return load_table("zh_big5han.table"); #endif } collation_table const & table() { static collation_table retval = make_save_load_table(); return retval; } TEST(tailoring, zh_big5han_011_000) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9beb); auto const rel = std::vector<uint32_t>(1, 0x9be0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be0); auto const rel = std::vector<uint32_t>(1, 0x9bde); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bde); auto const rel = std::vector<uint32_t>(1, 0x9be4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be4); auto const rel = std::vector<uint32_t>(1, 0x9be6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be6); auto const rel = std::vector<uint32_t>(1, 0x9be2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be2); auto const rel = std::vector<uint32_t>(1, 0x9bf0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bf0); auto const rel = std::vector<uint32_t>(1, 0x9bd4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bd4); auto const rel = std::vector<uint32_t>(1, 0x9bd7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bd7); auto const rel = std::vector<uint32_t>(1, 0x9bec); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bec); auto const rel = std::vector<uint32_t>(1, 0x9bdc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bdc); auto const rel = std::vector<uint32_t>(1, 0x9bd9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bd9); auto const rel = std::vector<uint32_t>(1, 0x9be5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be5); auto const rel = std::vector<uint32_t>(1, 0x9bd5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bd5); auto const rel = std::vector<uint32_t>(1, 0x9be1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be1); auto const rel = std::vector<uint32_t>(1, 0x9bda); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bda); auto const rel = std::vector<uint32_t>(1, 0x9d77); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d77); auto const rel = std::vector<uint32_t>(1, 0x9d81); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d81); auto const rel = std::vector<uint32_t>(1, 0x9d8a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d8a); auto const rel = std::vector<uint32_t>(1, 0x9d84); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d84); auto const rel = std::vector<uint32_t>(1, 0x9d88); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d88); auto const rel = std::vector<uint32_t>(1, 0x9d71); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d71); auto const rel = std::vector<uint32_t>(1, 0x9d80); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d80); auto const rel = std::vector<uint32_t>(1, 0x9d78); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d78); auto const rel = std::vector<uint32_t>(1, 0x9d86); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d86); auto const rel = std::vector<uint32_t>(1, 0x9d8b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d8b); auto const rel = std::vector<uint32_t>(1, 0x9d8c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d8c); auto const rel = std::vector<uint32_t>(1, 0x9d7d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d7d); auto const rel = std::vector<uint32_t>(1, 0x9d6b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d6b); auto const rel = std::vector<uint32_t>(1, 0x9d74); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d74); auto const rel = std::vector<uint32_t>(1, 0x9d75); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d75); auto const rel = std::vector<uint32_t>(1, 0x9d70); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d70); auto const rel = std::vector<uint32_t>(1, 0x9d69); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d69); auto const rel = std::vector<uint32_t>(1, 0x9d85); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d85); auto const rel = std::vector<uint32_t>(1, 0x9d73); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d73); auto const rel = std::vector<uint32_t>(1, 0x9d7b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d7b); auto const rel = std::vector<uint32_t>(1, 0x9d82); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d82); auto const rel = std::vector<uint32_t>(1, 0x9d6f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d6f); auto const rel = std::vector<uint32_t>(1, 0x9d79); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d79); auto const rel = std::vector<uint32_t>(1, 0x9d7f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d7f); auto const rel = std::vector<uint32_t>(1, 0x9d87); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d87); auto const rel = std::vector<uint32_t>(1, 0x9d68); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d68); auto const rel = std::vector<uint32_t>(1, 0x9e94); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e94); auto const rel = std::vector<uint32_t>(1, 0x9e91); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e91); auto const rel = std::vector<uint32_t>(1, 0x9ec0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ec0); auto const rel = std::vector<uint32_t>(1, 0x9efc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9efc); auto const rel = std::vector<uint32_t>(1, 0x9f2d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f2d); auto const rel = std::vector<uint32_t>(1, 0x9f40); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f40); auto const rel = std::vector<uint32_t>(1, 0x9f41); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f41); auto const rel = std::vector<uint32_t>(1, 0x9f4d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f4d); auto const rel = std::vector<uint32_t>(1, 0x9f56); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f56); auto const rel = std::vector<uint32_t>(1, 0x9f57); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_001) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f57); auto const rel = std::vector<uint32_t>(1, 0x9f58); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f58); auto const rel = std::vector<uint32_t>(1, 0x5337); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5337); auto const rel = std::vector<uint32_t>(1, 0x56b2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56b2); auto const rel = std::vector<uint32_t>(1, 0x56b5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56b5); auto const rel = std::vector<uint32_t>(1, 0x56b3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56b3); auto const rel = std::vector<uint32_t>(1, 0x58e3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58e3); auto const rel = std::vector<uint32_t>(1, 0x5b45); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b45); auto const rel = std::vector<uint32_t>(1, 0x5dc6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dc6); auto const rel = std::vector<uint32_t>(1, 0x5dc7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dc7); auto const rel = std::vector<uint32_t>(1, 0x5eee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5eee); auto const rel = std::vector<uint32_t>(1, 0x5eef); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5eef); auto const rel = std::vector<uint32_t>(1, 0x5fc0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fc0); auto const rel = std::vector<uint32_t>(1, 0x5fc1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fc1); auto const rel = std::vector<uint32_t>(1, 0x61f9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61f9); auto const rel = std::vector<uint32_t>(1, 0x6517); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6517); auto const rel = std::vector<uint32_t>(1, 0x6516); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6516); auto const rel = std::vector<uint32_t>(1, 0x6515); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6515); auto const rel = std::vector<uint32_t>(1, 0x6513); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6513); auto const rel = std::vector<uint32_t>(1, 0x65df); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65df); auto const rel = std::vector<uint32_t>(1, 0x66e8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66e8); auto const rel = std::vector<uint32_t>(1, 0x66e3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66e3); auto const rel = std::vector<uint32_t>(1, 0x66e4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66e4); auto const rel = std::vector<uint32_t>(1, 0x6af3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af3); auto const rel = std::vector<uint32_t>(1, 0x6af0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af0); auto const rel = std::vector<uint32_t>(1, 0x6aea); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aea); auto const rel = std::vector<uint32_t>(1, 0x6ae8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ae8); auto const rel = std::vector<uint32_t>(1, 0x6af9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af9); auto const rel = std::vector<uint32_t>(1, 0x6af1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af1); auto const rel = std::vector<uint32_t>(1, 0x6aee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aee); auto const rel = std::vector<uint32_t>(1, 0x6aef); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aef); auto const rel = std::vector<uint32_t>(1, 0x703c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x703c); auto const rel = std::vector<uint32_t>(1, 0x7035); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7035); auto const rel = std::vector<uint32_t>(1, 0x702f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x702f); auto const rel = std::vector<uint32_t>(1, 0x7037); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7037); auto const rel = std::vector<uint32_t>(1, 0x7034); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7034); auto const rel = std::vector<uint32_t>(1, 0x7031); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7031); auto const rel = std::vector<uint32_t>(1, 0x7042); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7042); auto const rel = std::vector<uint32_t>(1, 0x7038); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7038); auto const rel = std::vector<uint32_t>(1, 0x703f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x703f); auto const rel = std::vector<uint32_t>(1, 0x703a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x703a); auto const rel = std::vector<uint32_t>(1, 0x7039); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7039); auto const rel = std::vector<uint32_t>(1, 0x7040); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7040); auto const rel = std::vector<uint32_t>(1, 0x703b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x703b); auto const rel = std::vector<uint32_t>(1, 0x7033); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7033); auto const rel = std::vector<uint32_t>(1, 0x7041); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7041); auto const rel = std::vector<uint32_t>(1, 0x7213); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7213); auto const rel = std::vector<uint32_t>(1, 0x7214); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7214); auto const rel = std::vector<uint32_t>(1, 0x72a8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72a8); auto const rel = std::vector<uint32_t>(1, 0x737d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737d); auto const rel = std::vector<uint32_t>(1, 0x737c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737c); auto const rel = std::vector<uint32_t>(1, 0x74ba); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_002) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74ba); auto const rel = std::vector<uint32_t>(1, 0x76ab); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76ab); auto const rel = std::vector<uint32_t>(1, 0x76aa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76aa); auto const rel = std::vector<uint32_t>(1, 0x76be); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76be); auto const rel = std::vector<uint32_t>(1, 0x76ed); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76ed); auto const rel = std::vector<uint32_t>(1, 0x77cc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77cc); auto const rel = std::vector<uint32_t>(1, 0x77ce); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77ce); auto const rel = std::vector<uint32_t>(1, 0x77cf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77cf); auto const rel = std::vector<uint32_t>(1, 0x77cd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77cd); auto const rel = std::vector<uint32_t>(1, 0x77f2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77f2); auto const rel = std::vector<uint32_t>(1, 0x7925); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7925); auto const rel = std::vector<uint32_t>(1, 0x7923); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7923); auto const rel = std::vector<uint32_t>(1, 0x7927); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7927); auto const rel = std::vector<uint32_t>(1, 0x7928); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7928); auto const rel = std::vector<uint32_t>(1, 0x7924); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7924); auto const rel = std::vector<uint32_t>(1, 0x7929); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7929); auto const rel = std::vector<uint32_t>(1, 0x79b2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b2); auto const rel = std::vector<uint32_t>(1, 0x7a6e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a6e); auto const rel = std::vector<uint32_t>(1, 0x7a6c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a6c); auto const rel = std::vector<uint32_t>(1, 0x7a6d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a6d); auto const rel = std::vector<uint32_t>(1, 0x7af7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7af7); auto const rel = std::vector<uint32_t>(1, 0x7c49); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c49); auto const rel = std::vector<uint32_t>(1, 0x7c48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c48); auto const rel = std::vector<uint32_t>(1, 0x7c4a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c4a); auto const rel = std::vector<uint32_t>(1, 0x7c47); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c47); auto const rel = std::vector<uint32_t>(1, 0x7c45); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c45); auto const rel = std::vector<uint32_t>(1, 0x7cee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cee); auto const rel = std::vector<uint32_t>(1, 0x7e7b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e7b); auto const rel = std::vector<uint32_t>(1, 0x7e7e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e7e); auto const rel = std::vector<uint32_t>(1, 0x7e81); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e81); auto const rel = std::vector<uint32_t>(1, 0x7e80); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e80); auto const rel = std::vector<uint32_t>(1, 0x7fba); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fba); auto const rel = std::vector<uint32_t>(1, 0x7fff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fff); auto const rel = std::vector<uint32_t>(1, 0x8079); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8079); auto const rel = std::vector<uint32_t>(1, 0x81db); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81db); auto const rel = std::vector<uint32_t>(1, 0x81d9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81d9); auto const rel = std::vector<uint32_t>(1, 0x820b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x820b); auto const rel = std::vector<uint32_t>(1, 0x8268); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8268); auto const rel = std::vector<uint32_t>(1, 0x8269); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8269); auto const rel = std::vector<uint32_t>(1, 0x8622); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8622); auto const rel = std::vector<uint32_t>(1, 0x85ff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85ff); auto const rel = std::vector<uint32_t>(1, 0x8601); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8601); auto const rel = std::vector<uint32_t>(1, 0x85fe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85fe); auto const rel = std::vector<uint32_t>(1, 0x861b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x861b); auto const rel = std::vector<uint32_t>(1, 0x8600); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8600); auto const rel = std::vector<uint32_t>(1, 0x85f6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85f6); auto const rel = std::vector<uint32_t>(1, 0x8604); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8604); auto const rel = std::vector<uint32_t>(1, 0x8609); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8609); auto const rel = std::vector<uint32_t>(1, 0x8605); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8605); auto const rel = std::vector<uint32_t>(1, 0x860c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x860c); auto const rel = std::vector<uint32_t>(1, 0x85fd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85fd); auto const rel = std::vector<uint32_t>(1, 0x8819); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_003) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8819); auto const rel = std::vector<uint32_t>(1, 0x8810); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8810); auto const rel = std::vector<uint32_t>(1, 0x8811); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8811); auto const rel = std::vector<uint32_t>(1, 0x8817); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8817); auto const rel = std::vector<uint32_t>(1, 0x8813); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8813); auto const rel = std::vector<uint32_t>(1, 0x8816); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8816); auto const rel = std::vector<uint32_t>(1, 0x8963); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8963); auto const rel = std::vector<uint32_t>(1, 0x8966); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8966); auto const rel = std::vector<uint32_t>(1, 0x89b9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89b9); auto const rel = std::vector<uint32_t>(1, 0x89f7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89f7); auto const rel = std::vector<uint32_t>(1, 0x8b60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b60); auto const rel = std::vector<uint32_t>(1, 0x8b6a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b6a); auto const rel = std::vector<uint32_t>(1, 0x8b5d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b5d); auto const rel = std::vector<uint32_t>(1, 0x8b68); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b68); auto const rel = std::vector<uint32_t>(1, 0x8b63); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b63); auto const rel = std::vector<uint32_t>(1, 0x8b65); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b65); auto const rel = std::vector<uint32_t>(1, 0x8b67); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b67); auto const rel = std::vector<uint32_t>(1, 0x8b6d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b6d); auto const rel = std::vector<uint32_t>(1, 0x8dae); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dae); auto const rel = std::vector<uint32_t>(1, 0x8e86); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e86); auto const rel = std::vector<uint32_t>(1, 0x8e88); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e88); auto const rel = std::vector<uint32_t>(1, 0x8e84); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e84); auto const rel = std::vector<uint32_t>(1, 0x8f59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f59); auto const rel = std::vector<uint32_t>(1, 0x8f56); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f56); auto const rel = std::vector<uint32_t>(1, 0x8f57); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f57); auto const rel = std::vector<uint32_t>(1, 0x8f55); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f55); auto const rel = std::vector<uint32_t>(1, 0x8f58); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f58); auto const rel = std::vector<uint32_t>(1, 0x8f5a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5a); auto const rel = std::vector<uint32_t>(1, 0x908d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x908d); auto const rel = std::vector<uint32_t>(1, 0x9143); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9143); auto const rel = std::vector<uint32_t>(1, 0x9141); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9141); auto const rel = std::vector<uint32_t>(1, 0x91b7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b7); auto const rel = std::vector<uint32_t>(1, 0x91b5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b5); auto const rel = std::vector<uint32_t>(1, 0x91b2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b2); auto const rel = std::vector<uint32_t>(1, 0x91b3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b3); auto const rel = std::vector<uint32_t>(1, 0x940b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940b); auto const rel = std::vector<uint32_t>(1, 0x9413); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9413); auto const rel = std::vector<uint32_t>(1, 0x93fb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93fb); auto const rel = std::vector<uint32_t>(1, 0x9420); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9420); auto const rel = std::vector<uint32_t>(1, 0x940f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940f); auto const rel = std::vector<uint32_t>(1, 0x9414); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9414); auto const rel = std::vector<uint32_t>(1, 0x93fe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93fe); auto const rel = std::vector<uint32_t>(1, 0x9415); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9415); auto const rel = std::vector<uint32_t>(1, 0x9410); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9410); auto const rel = std::vector<uint32_t>(1, 0x9428); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9428); auto const rel = std::vector<uint32_t>(1, 0x9419); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9419); auto const rel = std::vector<uint32_t>(1, 0x940d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940d); auto const rel = std::vector<uint32_t>(1, 0x93f5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93f5); auto const rel = std::vector<uint32_t>(1, 0x9400); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9400); auto const rel = std::vector<uint32_t>(1, 0x93f7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93f7); auto const rel = std::vector<uint32_t>(1, 0x9407); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9407); auto const rel = std::vector<uint32_t>(1, 0x940e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_004) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940e); auto const rel = std::vector<uint32_t>(1, 0x9416); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9416); auto const rel = std::vector<uint32_t>(1, 0x9412); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9412); auto const rel = std::vector<uint32_t>(1, 0x93fa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93fa); auto const rel = std::vector<uint32_t>(1, 0x9409); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9409); auto const rel = std::vector<uint32_t>(1, 0x93f8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93f8); auto const rel = std::vector<uint32_t>(1, 0x940a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940a); auto const rel = std::vector<uint32_t>(1, 0x93ff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93ff); auto const rel = std::vector<uint32_t>(1, 0x93fc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93fc); auto const rel = std::vector<uint32_t>(1, 0x940c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x940c); auto const rel = std::vector<uint32_t>(1, 0x93f6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93f6); auto const rel = std::vector<uint32_t>(1, 0x9411); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9411); auto const rel = std::vector<uint32_t>(1, 0x9406); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9406); auto const rel = std::vector<uint32_t>(1, 0x95de); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95de); auto const rel = std::vector<uint32_t>(1, 0x95e0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e0); auto const rel = std::vector<uint32_t>(1, 0x95df); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95df); auto const rel = std::vector<uint32_t>(1, 0x972e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x972e); auto const rel = std::vector<uint32_t>(1, 0x972f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x972f); auto const rel = std::vector<uint32_t>(1, 0x97b9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97b9); auto const rel = std::vector<uint32_t>(1, 0x97bb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97bb); auto const rel = std::vector<uint32_t>(1, 0x97fd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97fd); auto const rel = std::vector<uint32_t>(1, 0x97fe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97fe); auto const rel = std::vector<uint32_t>(1, 0x9860); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9860); auto const rel = std::vector<uint32_t>(1, 0x9862); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9862); auto const rel = std::vector<uint32_t>(1, 0x9863); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9863); auto const rel = std::vector<uint32_t>(1, 0x985f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x985f); auto const rel = std::vector<uint32_t>(1, 0x98c1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c1); auto const rel = std::vector<uint32_t>(1, 0x98c2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c2); auto const rel = std::vector<uint32_t>(1, 0x9950); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9950); auto const rel = std::vector<uint32_t>(1, 0x994e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x994e); auto const rel = std::vector<uint32_t>(1, 0x9959); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9959); auto const rel = std::vector<uint32_t>(1, 0x994c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x994c); auto const rel = std::vector<uint32_t>(1, 0x994b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x994b); auto const rel = std::vector<uint32_t>(1, 0x9953); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9953); auto const rel = std::vector<uint32_t>(1, 0x9a32); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a32); auto const rel = std::vector<uint32_t>(1, 0x9a34); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a34); auto const rel = std::vector<uint32_t>(1, 0x9a31); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a31); auto const rel = std::vector<uint32_t>(1, 0x9a2c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a2c); auto const rel = std::vector<uint32_t>(1, 0x9a2a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a2a); auto const rel = std::vector<uint32_t>(1, 0x9a36); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a36); auto const rel = std::vector<uint32_t>(1, 0x9a29); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a29); auto const rel = std::vector<uint32_t>(1, 0x9a2e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a2e); auto const rel = std::vector<uint32_t>(1, 0x9a38); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a38); auto const rel = std::vector<uint32_t>(1, 0x9a2d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a2d); auto const rel = std::vector<uint32_t>(1, 0x9ac7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ac7); auto const rel = std::vector<uint32_t>(1, 0x9aca); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9aca); auto const rel = std::vector<uint32_t>(1, 0x9ac6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ac6); auto const rel = std::vector<uint32_t>(1, 0x9b10); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b10); auto const rel = std::vector<uint32_t>(1, 0x9b12); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b12); auto const rel = std::vector<uint32_t>(1, 0x9b11); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b11); auto const rel = std::vector<uint32_t>(1, 0x9c0b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c0b); auto const rel = std::vector<uint32_t>(1, 0x9c08); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_005) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c08); auto const rel = std::vector<uint32_t>(1, 0x9bf7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bf7); auto const rel = std::vector<uint32_t>(1, 0x9c05); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c05); auto const rel = std::vector<uint32_t>(1, 0x9c12); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c12); auto const rel = std::vector<uint32_t>(1, 0x9bf8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bf8); auto const rel = std::vector<uint32_t>(1, 0x9c40); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c40); auto const rel = std::vector<uint32_t>(1, 0x9c07); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c07); auto const rel = std::vector<uint32_t>(1, 0x9c0e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c0e); auto const rel = std::vector<uint32_t>(1, 0x9c06); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c06); auto const rel = std::vector<uint32_t>(1, 0x9c17); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c17); auto const rel = std::vector<uint32_t>(1, 0x9c14); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c14); auto const rel = std::vector<uint32_t>(1, 0x9c09); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c09); auto const rel = std::vector<uint32_t>(1, 0x9d9f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9f); auto const rel = std::vector<uint32_t>(1, 0x9d99); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d99); auto const rel = std::vector<uint32_t>(1, 0x9da4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da4); auto const rel = std::vector<uint32_t>(1, 0x9d9d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9d); auto const rel = std::vector<uint32_t>(1, 0x9d92); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d92); auto const rel = std::vector<uint32_t>(1, 0x9d98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d98); auto const rel = std::vector<uint32_t>(1, 0x9d90); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d90); auto const rel = std::vector<uint32_t>(1, 0x9d9b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9b); auto const rel = std::vector<uint32_t>(1, 0x9da0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da0); auto const rel = std::vector<uint32_t>(1, 0x9d94); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d94); auto const rel = std::vector<uint32_t>(1, 0x9d9c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9c); auto const rel = std::vector<uint32_t>(1, 0x9daa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9daa); auto const rel = std::vector<uint32_t>(1, 0x9d97); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d97); auto const rel = std::vector<uint32_t>(1, 0x9da1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da1); auto const rel = std::vector<uint32_t>(1, 0x9d9a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9a); auto const rel = std::vector<uint32_t>(1, 0x9da2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da2); auto const rel = std::vector<uint32_t>(1, 0x9da8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da8); auto const rel = std::vector<uint32_t>(1, 0x9d9e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d9e); auto const rel = std::vector<uint32_t>(1, 0x9da3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da3); auto const rel = std::vector<uint32_t>(1, 0x9dbf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dbf); auto const rel = std::vector<uint32_t>(1, 0x9da9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da9); auto const rel = std::vector<uint32_t>(1, 0x9d96); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d96); auto const rel = std::vector<uint32_t>(1, 0x9da6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da6); auto const rel = std::vector<uint32_t>(1, 0x9da7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9da7); auto const rel = std::vector<uint32_t>(1, 0x9e99); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e99); auto const rel = std::vector<uint32_t>(1, 0x9e9b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e9b); auto const rel = std::vector<uint32_t>(1, 0x9e9a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e9a); auto const rel = std::vector<uint32_t>(1, 0x9ee5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ee5); auto const rel = std::vector<uint32_t>(1, 0x9ee4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ee4); auto const rel = std::vector<uint32_t>(1, 0x9ee7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ee7); auto const rel = std::vector<uint32_t>(1, 0x9ee6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ee6); auto const rel = std::vector<uint32_t>(1, 0x9f30); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f30); auto const rel = std::vector<uint32_t>(1, 0x9f2e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f2e); auto const rel = std::vector<uint32_t>(1, 0x9f5b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f5b); auto const rel = std::vector<uint32_t>(1, 0x9f60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f60); auto const rel = std::vector<uint32_t>(1, 0x9f5e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f5e); auto const rel = std::vector<uint32_t>(1, 0x9f5d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f5d); auto const rel = std::vector<uint32_t>(1, 0x9f59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f59); auto const rel = std::vector<uint32_t>(1, 0x9f91); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f91); auto const rel = std::vector<uint32_t>(1, 0x513a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_006) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x513a); auto const rel = std::vector<uint32_t>(1, 0x5139); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5139); auto const rel = std::vector<uint32_t>(1, 0x5298); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5298); auto const rel = std::vector<uint32_t>(1, 0x5297); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5297); auto const rel = std::vector<uint32_t>(1, 0x56c3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56c3); auto const rel = std::vector<uint32_t>(1, 0x56bd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56bd); auto const rel = std::vector<uint32_t>(1, 0x56be); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56be); auto const rel = std::vector<uint32_t>(1, 0x5b48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b48); auto const rel = std::vector<uint32_t>(1, 0x5b47); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b47); auto const rel = std::vector<uint32_t>(1, 0x5dcb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dcb); auto const rel = std::vector<uint32_t>(1, 0x5dcf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dcf); auto const rel = std::vector<uint32_t>(1, 0x5ef1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ef1); auto const rel = std::vector<uint32_t>(1, 0x61fd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61fd); auto const rel = std::vector<uint32_t>(1, 0x651b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x651b); auto const rel = std::vector<uint32_t>(1, 0x6b02); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b02); auto const rel = std::vector<uint32_t>(1, 0x6afc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6afc); auto const rel = std::vector<uint32_t>(1, 0x6b03); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b03); auto const rel = std::vector<uint32_t>(1, 0x6af8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6af8); auto const rel = std::vector<uint32_t>(1, 0x6b00); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b00); auto const rel = std::vector<uint32_t>(1, 0x7043); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7043); auto const rel = std::vector<uint32_t>(1, 0x7044); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7044); auto const rel = std::vector<uint32_t>(1, 0x704a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x704a); auto const rel = std::vector<uint32_t>(1, 0x7048); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7048); auto const rel = std::vector<uint32_t>(1, 0x7049); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7049); auto const rel = std::vector<uint32_t>(1, 0x7045); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7045); auto const rel = std::vector<uint32_t>(1, 0x7046); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7046); auto const rel = std::vector<uint32_t>(1, 0x721d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x721d); auto const rel = std::vector<uint32_t>(1, 0x721a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x721a); auto const rel = std::vector<uint32_t>(1, 0x7219); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7219); auto const rel = std::vector<uint32_t>(1, 0x737e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737e); auto const rel = std::vector<uint32_t>(1, 0x7517); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7517); auto const rel = std::vector<uint32_t>(1, 0x766a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x766a); auto const rel = std::vector<uint32_t>(1, 0x77d0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d0); auto const rel = std::vector<uint32_t>(1, 0x792d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x792d); auto const rel = std::vector<uint32_t>(1, 0x7931); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7931); auto const rel = std::vector<uint32_t>(1, 0x792f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x792f); auto const rel = std::vector<uint32_t>(1, 0x7c54); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c54); auto const rel = std::vector<uint32_t>(1, 0x7c53); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c53); auto const rel = std::vector<uint32_t>(1, 0x7cf2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf2); auto const rel = std::vector<uint32_t>(1, 0x7e8a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e8a); auto const rel = std::vector<uint32_t>(1, 0x7e87); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e87); auto const rel = std::vector<uint32_t>(1, 0x7e88); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e88); auto const rel = std::vector<uint32_t>(1, 0x7e8b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e8b); auto const rel = std::vector<uint32_t>(1, 0x7e86); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e86); auto const rel = std::vector<uint32_t>(1, 0x7e8d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e8d); auto const rel = std::vector<uint32_t>(1, 0x7f4d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f4d); auto const rel = std::vector<uint32_t>(1, 0x7fbb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fbb); auto const rel = std::vector<uint32_t>(1, 0x8030); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8030); auto const rel = std::vector<uint32_t>(1, 0x81dd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81dd); auto const rel = std::vector<uint32_t>(1, 0x8618); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8618); auto const rel = std::vector<uint32_t>(1, 0x862a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x862a); auto const rel = std::vector<uint32_t>(1, 0x8626); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_007) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8626); auto const rel = std::vector<uint32_t>(1, 0x861f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x861f); auto const rel = std::vector<uint32_t>(1, 0x8623); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8623); auto const rel = std::vector<uint32_t>(1, 0x861c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x861c); auto const rel = std::vector<uint32_t>(1, 0x8619); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8619); auto const rel = std::vector<uint32_t>(1, 0x8627); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8627); auto const rel = std::vector<uint32_t>(1, 0x862e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x862e); auto const rel = std::vector<uint32_t>(1, 0x8621); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8621); auto const rel = std::vector<uint32_t>(1, 0x8620); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8620); auto const rel = std::vector<uint32_t>(1, 0x8629); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8629); auto const rel = std::vector<uint32_t>(1, 0x861e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x861e); auto const rel = std::vector<uint32_t>(1, 0x8625); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8625); auto const rel = std::vector<uint32_t>(1, 0x8829); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8829); auto const rel = std::vector<uint32_t>(1, 0x881d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x881d); auto const rel = std::vector<uint32_t>(1, 0x881b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x881b); auto const rel = std::vector<uint32_t>(1, 0x8820); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8820); auto const rel = std::vector<uint32_t>(1, 0x8824); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8824); auto const rel = std::vector<uint32_t>(1, 0x881c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x881c); auto const rel = std::vector<uint32_t>(1, 0x882b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882b); auto const rel = std::vector<uint32_t>(1, 0x884a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x884a); auto const rel = std::vector<uint32_t>(1, 0x896d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x896d); auto const rel = std::vector<uint32_t>(1, 0x8969); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8969); auto const rel = std::vector<uint32_t>(1, 0x896e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x896e); auto const rel = std::vector<uint32_t>(1, 0x896b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x896b); auto const rel = std::vector<uint32_t>(1, 0x89fa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89fa); auto const rel = std::vector<uint32_t>(1, 0x8b79); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b79); auto const rel = std::vector<uint32_t>(1, 0x8b78); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b78); auto const rel = std::vector<uint32_t>(1, 0x8b45); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b45); auto const rel = std::vector<uint32_t>(1, 0x8b7a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b7a); auto const rel = std::vector<uint32_t>(1, 0x8b7b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b7b); auto const rel = std::vector<uint32_t>(1, 0x8d10); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d10); auto const rel = std::vector<uint32_t>(1, 0x8d14); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d14); auto const rel = std::vector<uint32_t>(1, 0x8daf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8daf); auto const rel = std::vector<uint32_t>(1, 0x8e8e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e8e); auto const rel = std::vector<uint32_t>(1, 0x8e8c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e8c); auto const rel = std::vector<uint32_t>(1, 0x8f5e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5e); auto const rel = std::vector<uint32_t>(1, 0x8f5b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5b); auto const rel = std::vector<uint32_t>(1, 0x8f5d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5d); auto const rel = std::vector<uint32_t>(1, 0x9146); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9146); auto const rel = std::vector<uint32_t>(1, 0x9144); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9144); auto const rel = std::vector<uint32_t>(1, 0x9145); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9145); auto const rel = std::vector<uint32_t>(1, 0x91b9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b9); auto const rel = std::vector<uint32_t>(1, 0x943f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943f); auto const rel = std::vector<uint32_t>(1, 0x943b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943b); auto const rel = std::vector<uint32_t>(1, 0x9436); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9436); auto const rel = std::vector<uint32_t>(1, 0x9429); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9429); auto const rel = std::vector<uint32_t>(1, 0x943d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943d); auto const rel = std::vector<uint32_t>(1, 0x943c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943c); auto const rel = std::vector<uint32_t>(1, 0x9430); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9430); auto const rel = std::vector<uint32_t>(1, 0x9439); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9439); auto const rel = std::vector<uint32_t>(1, 0x942a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x942a); auto const rel = std::vector<uint32_t>(1, 0x9437); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_008) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9437); auto const rel = std::vector<uint32_t>(1, 0x942c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x942c); auto const rel = std::vector<uint32_t>(1, 0x9440); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9440); auto const rel = std::vector<uint32_t>(1, 0x9431); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9431); auto const rel = std::vector<uint32_t>(1, 0x95e5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e5); auto const rel = std::vector<uint32_t>(1, 0x95e4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e4); auto const rel = std::vector<uint32_t>(1, 0x95e3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e3); auto const rel = std::vector<uint32_t>(1, 0x9735); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9735); auto const rel = std::vector<uint32_t>(1, 0x973a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x973a); auto const rel = std::vector<uint32_t>(1, 0x97bf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97bf); auto const rel = std::vector<uint32_t>(1, 0x97e1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97e1); auto const rel = std::vector<uint32_t>(1, 0x9864); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9864); auto const rel = std::vector<uint32_t>(1, 0x98c9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c9); auto const rel = std::vector<uint32_t>(1, 0x98c6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c6); auto const rel = std::vector<uint32_t>(1, 0x98c0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98c0); auto const rel = std::vector<uint32_t>(1, 0x9958); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9958); auto const rel = std::vector<uint32_t>(1, 0x9956); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9956); auto const rel = std::vector<uint32_t>(1, 0x9a39); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a39); auto const rel = std::vector<uint32_t>(1, 0x9a3d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a3d); auto const rel = std::vector<uint32_t>(1, 0x9a46); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a46); auto const rel = std::vector<uint32_t>(1, 0x9a44); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a44); auto const rel = std::vector<uint32_t>(1, 0x9a42); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a42); auto const rel = std::vector<uint32_t>(1, 0x9a41); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a41); auto const rel = std::vector<uint32_t>(1, 0x9a3a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a3a); auto const rel = std::vector<uint32_t>(1, 0x9a3f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a3f); auto const rel = std::vector<uint32_t>(1, 0x9acd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9acd); auto const rel = std::vector<uint32_t>(1, 0x9b15); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b15); auto const rel = std::vector<uint32_t>(1, 0x9b17); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b17); auto const rel = std::vector<uint32_t>(1, 0x9b18); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b18); auto const rel = std::vector<uint32_t>(1, 0x9b16); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b16); auto const rel = std::vector<uint32_t>(1, 0x9b3a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b3a); auto const rel = std::vector<uint32_t>(1, 0x9b52); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b52); auto const rel = std::vector<uint32_t>(1, 0x9c2b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c2b); auto const rel = std::vector<uint32_t>(1, 0x9c1d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c1d); auto const rel = std::vector<uint32_t>(1, 0x9c1c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c1c); auto const rel = std::vector<uint32_t>(1, 0x9c2c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c2c); auto const rel = std::vector<uint32_t>(1, 0x9c23); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c23); auto const rel = std::vector<uint32_t>(1, 0x9c28); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c28); auto const rel = std::vector<uint32_t>(1, 0x9c29); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c29); auto const rel = std::vector<uint32_t>(1, 0x9c24); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c24); auto const rel = std::vector<uint32_t>(1, 0x9c21); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c21); auto const rel = std::vector<uint32_t>(1, 0x9db7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db7); auto const rel = std::vector<uint32_t>(1, 0x9db6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db6); auto const rel = std::vector<uint32_t>(1, 0x9dbc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dbc); auto const rel = std::vector<uint32_t>(1, 0x9dc1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc1); auto const rel = std::vector<uint32_t>(1, 0x9dc7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc7); auto const rel = std::vector<uint32_t>(1, 0x9dca); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dca); auto const rel = std::vector<uint32_t>(1, 0x9dcf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dcf); auto const rel = std::vector<uint32_t>(1, 0x9dbe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dbe); auto const rel = std::vector<uint32_t>(1, 0x9dc5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc5); auto const rel = std::vector<uint32_t>(1, 0x9dc3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc3); auto const rel = std::vector<uint32_t>(1, 0x9dbb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_009) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dbb); auto const rel = std::vector<uint32_t>(1, 0x9db5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db5); auto const rel = std::vector<uint32_t>(1, 0x9dce); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dce); auto const rel = std::vector<uint32_t>(1, 0x9db9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db9); auto const rel = std::vector<uint32_t>(1, 0x9dba); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dba); auto const rel = std::vector<uint32_t>(1, 0x9dac); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dac); auto const rel = std::vector<uint32_t>(1, 0x9dc8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc8); auto const rel = std::vector<uint32_t>(1, 0x9db1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db1); auto const rel = std::vector<uint32_t>(1, 0x9dad); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dad); auto const rel = std::vector<uint32_t>(1, 0x9dcc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dcc); auto const rel = std::vector<uint32_t>(1, 0x9db3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db3); auto const rel = std::vector<uint32_t>(1, 0x9dcd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dcd); auto const rel = std::vector<uint32_t>(1, 0x9db2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9db2); auto const rel = std::vector<uint32_t>(1, 0x9e7a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e7a); auto const rel = std::vector<uint32_t>(1, 0x9e9c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e9c); auto const rel = std::vector<uint32_t>(1, 0x9eeb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eeb); auto const rel = std::vector<uint32_t>(1, 0x9eee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eee); auto const rel = std::vector<uint32_t>(1, 0x9eed); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eed); auto const rel = std::vector<uint32_t>(1, 0x9f1b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1b); auto const rel = std::vector<uint32_t>(1, 0x9f18); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f18); auto const rel = std::vector<uint32_t>(1, 0x9f1a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1a); auto const rel = std::vector<uint32_t>(1, 0x9f31); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f31); auto const rel = std::vector<uint32_t>(1, 0x9f4e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f4e); auto const rel = std::vector<uint32_t>(1, 0x9f65); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f65); auto const rel = std::vector<uint32_t>(1, 0x9f64); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f64); auto const rel = std::vector<uint32_t>(1, 0x9f92); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f92); auto const rel = std::vector<uint32_t>(1, 0x4eb9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4eb9); auto const rel = std::vector<uint32_t>(1, 0x56c6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56c6); auto const rel = std::vector<uint32_t>(1, 0x56c5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56c5); auto const rel = std::vector<uint32_t>(1, 0x56cb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56cb); auto const rel = std::vector<uint32_t>(1, 0x5971); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5971); auto const rel = std::vector<uint32_t>(1, 0x5b4b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b4b); auto const rel = std::vector<uint32_t>(1, 0x5b4c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b4c); auto const rel = std::vector<uint32_t>(1, 0x5dd5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dd5); auto const rel = std::vector<uint32_t>(1, 0x5dd1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dd1); auto const rel = std::vector<uint32_t>(1, 0x5ef2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ef2); auto const rel = std::vector<uint32_t>(1, 0x6521); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6521); auto const rel = std::vector<uint32_t>(1, 0x6520); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6520); auto const rel = std::vector<uint32_t>(1, 0x6526); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6526); auto const rel = std::vector<uint32_t>(1, 0x6522); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6522); auto const rel = std::vector<uint32_t>(1, 0x6b0b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b0b); auto const rel = std::vector<uint32_t>(1, 0x6b08); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b08); auto const rel = std::vector<uint32_t>(1, 0x6b09); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b09); auto const rel = std::vector<uint32_t>(1, 0x6c0d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c0d); auto const rel = std::vector<uint32_t>(1, 0x7055); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7055); auto const rel = std::vector<uint32_t>(1, 0x7056); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7056); auto const rel = std::vector<uint32_t>(1, 0x7057); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7057); auto const rel = std::vector<uint32_t>(1, 0x7052); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7052); auto const rel = std::vector<uint32_t>(1, 0x721e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x721e); auto const rel = std::vector<uint32_t>(1, 0x721f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x721f); auto const rel = std::vector<uint32_t>(1, 0x72a9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72a9); auto const rel = std::vector<uint32_t>(1, 0x737f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_010) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737f); auto const rel = std::vector<uint32_t>(1, 0x74d8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74d8); auto const rel = std::vector<uint32_t>(1, 0x74d5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74d5); auto const rel = std::vector<uint32_t>(1, 0x74d9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74d9); auto const rel = std::vector<uint32_t>(1, 0x74d7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74d7); auto const rel = std::vector<uint32_t>(1, 0x766d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x766d); auto const rel = std::vector<uint32_t>(1, 0x76ad); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76ad); auto const rel = std::vector<uint32_t>(1, 0x7935); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7935); auto const rel = std::vector<uint32_t>(1, 0x79b4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b4); auto const rel = std::vector<uint32_t>(1, 0x7a70); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a70); auto const rel = std::vector<uint32_t>(1, 0x7a71); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a71); auto const rel = std::vector<uint32_t>(1, 0x7c57); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c57); auto const rel = std::vector<uint32_t>(1, 0x7c5c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c5c); auto const rel = std::vector<uint32_t>(1, 0x7c59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c59); auto const rel = std::vector<uint32_t>(1, 0x7c5b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c5b); auto const rel = std::vector<uint32_t>(1, 0x7c5a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c5a); auto const rel = std::vector<uint32_t>(1, 0x7cf4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf4); auto const rel = std::vector<uint32_t>(1, 0x7cf1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf1); auto const rel = std::vector<uint32_t>(1, 0x7e91); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e91); auto const rel = std::vector<uint32_t>(1, 0x7f4f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f4f); auto const rel = std::vector<uint32_t>(1, 0x7f87); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f87); auto const rel = std::vector<uint32_t>(1, 0x81de); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81de); auto const rel = std::vector<uint32_t>(1, 0x826b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x826b); auto const rel = std::vector<uint32_t>(1, 0x8634); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8634); auto const rel = std::vector<uint32_t>(1, 0x8635); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8635); auto const rel = std::vector<uint32_t>(1, 0x8633); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8633); auto const rel = std::vector<uint32_t>(1, 0x862c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x862c); auto const rel = std::vector<uint32_t>(1, 0x8632); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8632); auto const rel = std::vector<uint32_t>(1, 0x8636); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8636); auto const rel = std::vector<uint32_t>(1, 0x882c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882c); auto const rel = std::vector<uint32_t>(1, 0x8828); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8828); auto const rel = std::vector<uint32_t>(1, 0x8826); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8826); auto const rel = std::vector<uint32_t>(1, 0x882a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882a); auto const rel = std::vector<uint32_t>(1, 0x8825); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8825); auto const rel = std::vector<uint32_t>(1, 0x8971); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8971); auto const rel = std::vector<uint32_t>(1, 0x89bf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89bf); auto const rel = std::vector<uint32_t>(1, 0x89be); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89be); auto const rel = std::vector<uint32_t>(1, 0x89fb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89fb); auto const rel = std::vector<uint32_t>(1, 0x8b7e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b7e); auto const rel = std::vector<uint32_t>(1, 0x8b84); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b84); auto const rel = std::vector<uint32_t>(1, 0x8b82); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b82); auto const rel = std::vector<uint32_t>(1, 0x8b86); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b86); auto const rel = std::vector<uint32_t>(1, 0x8b85); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b85); auto const rel = std::vector<uint32_t>(1, 0x8b7f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b7f); auto const rel = std::vector<uint32_t>(1, 0x8d15); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d15); auto const rel = std::vector<uint32_t>(1, 0x8e95); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e95); auto const rel = std::vector<uint32_t>(1, 0x8e94); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e94); auto const rel = std::vector<uint32_t>(1, 0x8e9a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e9a); auto const rel = std::vector<uint32_t>(1, 0x8e92); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e92); auto const rel = std::vector<uint32_t>(1, 0x8e90); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e90); auto const rel = std::vector<uint32_t>(1, 0x8e96); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e96); auto const rel = std::vector<uint32_t>(1, 0x8e97); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_011) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e97); auto const rel = std::vector<uint32_t>(1, 0x8f60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f60); auto const rel = std::vector<uint32_t>(1, 0x8f62); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f62); auto const rel = std::vector<uint32_t>(1, 0x9147); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9147); auto const rel = std::vector<uint32_t>(1, 0x944c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x944c); auto const rel = std::vector<uint32_t>(1, 0x9450); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9450); auto const rel = std::vector<uint32_t>(1, 0x944a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x944a); auto const rel = std::vector<uint32_t>(1, 0x944b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x944b); auto const rel = std::vector<uint32_t>(1, 0x944f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x944f); auto const rel = std::vector<uint32_t>(1, 0x9447); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9447); auto const rel = std::vector<uint32_t>(1, 0x9445); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9445); auto const rel = std::vector<uint32_t>(1, 0x9448); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9448); auto const rel = std::vector<uint32_t>(1, 0x9449); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9449); auto const rel = std::vector<uint32_t>(1, 0x9446); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9446); auto const rel = std::vector<uint32_t>(1, 0x973f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x973f); auto const rel = std::vector<uint32_t>(1, 0x97e3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97e3); auto const rel = std::vector<uint32_t>(1, 0x986a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x986a); auto const rel = std::vector<uint32_t>(1, 0x9869); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9869); auto const rel = std::vector<uint32_t>(1, 0x98cb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98cb); auto const rel = std::vector<uint32_t>(1, 0x9954); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9954); auto const rel = std::vector<uint32_t>(1, 0x995b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x995b); auto const rel = std::vector<uint32_t>(1, 0x9a4e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a4e); auto const rel = std::vector<uint32_t>(1, 0x9a53); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a53); auto const rel = std::vector<uint32_t>(1, 0x9a54); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a54); auto const rel = std::vector<uint32_t>(1, 0x9a4c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a4c); auto const rel = std::vector<uint32_t>(1, 0x9a4f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a4f); auto const rel = std::vector<uint32_t>(1, 0x9a48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a48); auto const rel = std::vector<uint32_t>(1, 0x9a4a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a4a); auto const rel = std::vector<uint32_t>(1, 0x9a49); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a49); auto const rel = std::vector<uint32_t>(1, 0x9a52); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a52); auto const rel = std::vector<uint32_t>(1, 0x9a50); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a50); auto const rel = std::vector<uint32_t>(1, 0x9ad0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ad0); auto const rel = std::vector<uint32_t>(1, 0x9b19); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b19); auto const rel = std::vector<uint32_t>(1, 0x9b2b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b2b); auto const rel = std::vector<uint32_t>(1, 0x9b3b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b3b); auto const rel = std::vector<uint32_t>(1, 0x9b56); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b56); auto const rel = std::vector<uint32_t>(1, 0x9b55); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b55); auto const rel = std::vector<uint32_t>(1, 0x9c46); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c46); auto const rel = std::vector<uint32_t>(1, 0x9c48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c48); auto const rel = std::vector<uint32_t>(1, 0x9c3f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c3f); auto const rel = std::vector<uint32_t>(1, 0x9c44); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c44); auto const rel = std::vector<uint32_t>(1, 0x9c39); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c39); auto const rel = std::vector<uint32_t>(1, 0x9c33); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c33); auto const rel = std::vector<uint32_t>(1, 0x9c41); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c41); auto const rel = std::vector<uint32_t>(1, 0x9c3c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c3c); auto const rel = std::vector<uint32_t>(1, 0x9c37); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c37); auto const rel = std::vector<uint32_t>(1, 0x9c34); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c34); auto const rel = std::vector<uint32_t>(1, 0x9c32); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c32); auto const rel = std::vector<uint32_t>(1, 0x9c3d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c3d); auto const rel = std::vector<uint32_t>(1, 0x9c36); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c36); auto const rel = std::vector<uint32_t>(1, 0x9ddb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ddb); auto const rel = std::vector<uint32_t>(1, 0x9dd2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_012) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd2); auto const rel = std::vector<uint32_t>(1, 0x9dde); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dde); auto const rel = std::vector<uint32_t>(1, 0x9dda); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dda); auto const rel = std::vector<uint32_t>(1, 0x9dcb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dcb); auto const rel = std::vector<uint32_t>(1, 0x9dd0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd0); auto const rel = std::vector<uint32_t>(1, 0x9ddc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ddc); auto const rel = std::vector<uint32_t>(1, 0x9dd1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd1); auto const rel = std::vector<uint32_t>(1, 0x9ddf); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ddf); auto const rel = std::vector<uint32_t>(1, 0x9de9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de9); auto const rel = std::vector<uint32_t>(1, 0x9dd9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd9); auto const rel = std::vector<uint32_t>(1, 0x9dd8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd8); auto const rel = std::vector<uint32_t>(1, 0x9dd6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd6); auto const rel = std::vector<uint32_t>(1, 0x9df5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df5); auto const rel = std::vector<uint32_t>(1, 0x9dd5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd5); auto const rel = std::vector<uint32_t>(1, 0x9ddd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ddd); auto const rel = std::vector<uint32_t>(1, 0x9eb6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eb6); auto const rel = std::vector<uint32_t>(1, 0x9ef0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef0); auto const rel = std::vector<uint32_t>(1, 0x9f35); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f35); auto const rel = std::vector<uint32_t>(1, 0x9f33); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f33); auto const rel = std::vector<uint32_t>(1, 0x9f32); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f32); auto const rel = std::vector<uint32_t>(1, 0x9f42); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f42); auto const rel = std::vector<uint32_t>(1, 0x9f6b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f6b); auto const rel = std::vector<uint32_t>(1, 0x9f95); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f95); auto const rel = std::vector<uint32_t>(1, 0x9fa2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9fa2); auto const rel = std::vector<uint32_t>(1, 0x513d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x513d); auto const rel = std::vector<uint32_t>(1, 0x5299); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5299); auto const rel = std::vector<uint32_t>(1, 0x58e8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58e8); auto const rel = std::vector<uint32_t>(1, 0x58e7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58e7); auto const rel = std::vector<uint32_t>(1, 0x5972); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5972); auto const rel = std::vector<uint32_t>(1, 0x5b4d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b4d); auto const rel = std::vector<uint32_t>(1, 0x5dd8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dd8); auto const rel = std::vector<uint32_t>(1, 0x882f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882f); auto const rel = std::vector<uint32_t>(1, 0x5f4f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f4f); auto const rel = std::vector<uint32_t>(1, 0x6201); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6201); auto const rel = std::vector<uint32_t>(1, 0x6203); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6203); auto const rel = std::vector<uint32_t>(1, 0x6204); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6204); auto const rel = std::vector<uint32_t>(1, 0x6529); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6529); auto const rel = std::vector<uint32_t>(1, 0x6525); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6525); auto const rel = std::vector<uint32_t>(1, 0x6596); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6596); auto const rel = std::vector<uint32_t>(1, 0x66eb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66eb); auto const rel = std::vector<uint32_t>(1, 0x6b11); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b11); auto const rel = std::vector<uint32_t>(1, 0x6b12); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b12); auto const rel = std::vector<uint32_t>(1, 0x6b0f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b0f); auto const rel = std::vector<uint32_t>(1, 0x6bca); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bca); auto const rel = std::vector<uint32_t>(1, 0x705b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x705b); auto const rel = std::vector<uint32_t>(1, 0x705a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x705a); auto const rel = std::vector<uint32_t>(1, 0x7222); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7222); auto const rel = std::vector<uint32_t>(1, 0x7382); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7382); auto const rel = std::vector<uint32_t>(1, 0x7381); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7381); auto const rel = std::vector<uint32_t>(1, 0x7383); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7383); auto const rel = std::vector<uint32_t>(1, 0x7670); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7670); auto const rel = std::vector<uint32_t>(1, 0x77d4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_013) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d4); auto const rel = std::vector<uint32_t>(1, 0x7c67); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c67); auto const rel = std::vector<uint32_t>(1, 0x7c66); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c66); auto const rel = std::vector<uint32_t>(1, 0x7e95); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e95); auto const rel = std::vector<uint32_t>(1, 0x826c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x826c); auto const rel = std::vector<uint32_t>(1, 0x863a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x863a); auto const rel = std::vector<uint32_t>(1, 0x8640); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8640); auto const rel = std::vector<uint32_t>(1, 0x8639); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8639); auto const rel = std::vector<uint32_t>(1, 0x863c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x863c); auto const rel = std::vector<uint32_t>(1, 0x8631); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8631); auto const rel = std::vector<uint32_t>(1, 0x863b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x863b); auto const rel = std::vector<uint32_t>(1, 0x863e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x863e); auto const rel = std::vector<uint32_t>(1, 0x8830); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8830); auto const rel = std::vector<uint32_t>(1, 0x8832); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8832); auto const rel = std::vector<uint32_t>(1, 0x882e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882e); auto const rel = std::vector<uint32_t>(1, 0x8833); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8833); auto const rel = std::vector<uint32_t>(1, 0x8976); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8976); auto const rel = std::vector<uint32_t>(1, 0x8974); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8974); auto const rel = std::vector<uint32_t>(1, 0x8973); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8973); auto const rel = std::vector<uint32_t>(1, 0x89fe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89fe); auto const rel = std::vector<uint32_t>(1, 0x8b8c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b8c); auto const rel = std::vector<uint32_t>(1, 0x8b8e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b8e); auto const rel = std::vector<uint32_t>(1, 0x8b8b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b8b); auto const rel = std::vector<uint32_t>(1, 0x8b88); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b88); auto const rel = std::vector<uint32_t>(1, 0x8c45); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c45); auto const rel = std::vector<uint32_t>(1, 0x8d19); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d19); auto const rel = std::vector<uint32_t>(1, 0x8e98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e98); auto const rel = std::vector<uint32_t>(1, 0x8f64); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f64); auto const rel = std::vector<uint32_t>(1, 0x8f63); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f63); auto const rel = std::vector<uint32_t>(1, 0x91bc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91bc); auto const rel = std::vector<uint32_t>(1, 0x9462); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9462); auto const rel = std::vector<uint32_t>(1, 0x9455); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9455); auto const rel = std::vector<uint32_t>(1, 0x945d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x945d); auto const rel = std::vector<uint32_t>(1, 0x9457); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9457); auto const rel = std::vector<uint32_t>(1, 0x945e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x945e); auto const rel = std::vector<uint32_t>(1, 0x97c4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97c4); auto const rel = std::vector<uint32_t>(1, 0x97c5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97c5); auto const rel = std::vector<uint32_t>(1, 0x9800); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9800); auto const rel = std::vector<uint32_t>(1, 0x9a56); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a56); auto const rel = std::vector<uint32_t>(1, 0x9a59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a59); auto const rel = std::vector<uint32_t>(1, 0x9b1e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b1e); auto const rel = std::vector<uint32_t>(1, 0x9b1f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b1f); auto const rel = std::vector<uint32_t>(1, 0x9b20); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b20); auto const rel = std::vector<uint32_t>(1, 0x9c52); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c52); auto const rel = std::vector<uint32_t>(1, 0x9c58); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c58); auto const rel = std::vector<uint32_t>(1, 0x9c50); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c50); auto const rel = std::vector<uint32_t>(1, 0x9c4a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4a); auto const rel = std::vector<uint32_t>(1, 0x9c4d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4d); auto const rel = std::vector<uint32_t>(1, 0x9c4b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4b); auto const rel = std::vector<uint32_t>(1, 0x9c55); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c55); auto const rel = std::vector<uint32_t>(1, 0x9c59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c59); auto const rel = std::vector<uint32_t>(1, 0x9c4c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_014) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4c); auto const rel = std::vector<uint32_t>(1, 0x9c4e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c4e); auto const rel = std::vector<uint32_t>(1, 0x9dfb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dfb); auto const rel = std::vector<uint32_t>(1, 0x9df7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df7); auto const rel = std::vector<uint32_t>(1, 0x9def); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9def); auto const rel = std::vector<uint32_t>(1, 0x9de3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de3); auto const rel = std::vector<uint32_t>(1, 0x9deb); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9deb); auto const rel = std::vector<uint32_t>(1, 0x9df8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df8); auto const rel = std::vector<uint32_t>(1, 0x9de4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de4); auto const rel = std::vector<uint32_t>(1, 0x9df6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df6); auto const rel = std::vector<uint32_t>(1, 0x9de1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de1); auto const rel = std::vector<uint32_t>(1, 0x9dee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dee); auto const rel = std::vector<uint32_t>(1, 0x9de6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de6); auto const rel = std::vector<uint32_t>(1, 0x9df2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df2); auto const rel = std::vector<uint32_t>(1, 0x9df0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df0); auto const rel = std::vector<uint32_t>(1, 0x9de2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de2); auto const rel = std::vector<uint32_t>(1, 0x9dec); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dec); auto const rel = std::vector<uint32_t>(1, 0x9df4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df4); auto const rel = std::vector<uint32_t>(1, 0x9df3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9df3); auto const rel = std::vector<uint32_t>(1, 0x9de8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de8); auto const rel = std::vector<uint32_t>(1, 0x9ded); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ded); auto const rel = std::vector<uint32_t>(1, 0x9ec2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ec2); auto const rel = std::vector<uint32_t>(1, 0x9ed0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ed0); auto const rel = std::vector<uint32_t>(1, 0x9ef2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef2); auto const rel = std::vector<uint32_t>(1, 0x9ef3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef3); auto const rel = std::vector<uint32_t>(1, 0x9f06); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f06); auto const rel = std::vector<uint32_t>(1, 0x9f1c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1c); auto const rel = std::vector<uint32_t>(1, 0x9f38); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f38); auto const rel = std::vector<uint32_t>(1, 0x9f37); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f37); auto const rel = std::vector<uint32_t>(1, 0x9f36); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f36); auto const rel = std::vector<uint32_t>(1, 0x9f43); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f43); auto const rel = std::vector<uint32_t>(1, 0x9f4f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f4f); auto const rel = std::vector<uint32_t>(1, 0x9f71); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f71); auto const rel = std::vector<uint32_t>(1, 0x9f70); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f70); auto const rel = std::vector<uint32_t>(1, 0x9f6e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f6e); auto const rel = std::vector<uint32_t>(1, 0x9f6f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f6f); auto const rel = std::vector<uint32_t>(1, 0x56d3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56d3); auto const rel = std::vector<uint32_t>(1, 0x56cd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56cd); auto const rel = std::vector<uint32_t>(1, 0x5b4e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b4e); auto const rel = std::vector<uint32_t>(1, 0x5c6d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c6d); auto const rel = std::vector<uint32_t>(1, 0x652d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x652d); auto const rel = std::vector<uint32_t>(1, 0x66ed); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66ed); auto const rel = std::vector<uint32_t>(1, 0x66ee); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66ee); auto const rel = std::vector<uint32_t>(1, 0x6b13); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b13); auto const rel = std::vector<uint32_t>(1, 0x705f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x705f); auto const rel = std::vector<uint32_t>(1, 0x7061); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7061); auto const rel = std::vector<uint32_t>(1, 0x705d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x705d); auto const rel = std::vector<uint32_t>(1, 0x7060); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7060); auto const rel = std::vector<uint32_t>(1, 0x7223); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7223); auto const rel = std::vector<uint32_t>(1, 0x74db); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74db); auto const rel = std::vector<uint32_t>(1, 0x74e5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74e5); auto const rel = std::vector<uint32_t>(1, 0x77d5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_015) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d5); auto const rel = std::vector<uint32_t>(1, 0x7938); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7938); auto const rel = std::vector<uint32_t>(1, 0x79b7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b7); auto const rel = std::vector<uint32_t>(1, 0x79b6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b6); auto const rel = std::vector<uint32_t>(1, 0x7c6a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c6a); auto const rel = std::vector<uint32_t>(1, 0x7e97); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e97); auto const rel = std::vector<uint32_t>(1, 0x7f89); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f89); auto const rel = std::vector<uint32_t>(1, 0x826d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x826d); auto const rel = std::vector<uint32_t>(1, 0x8643); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8643); auto const rel = std::vector<uint32_t>(1, 0x8838); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8838); auto const rel = std::vector<uint32_t>(1, 0x8837); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8837); auto const rel = std::vector<uint32_t>(1, 0x8835); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8835); auto const rel = std::vector<uint32_t>(1, 0x884b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x884b); auto const rel = std::vector<uint32_t>(1, 0x8b94); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b94); auto const rel = std::vector<uint32_t>(1, 0x8b95); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b95); auto const rel = std::vector<uint32_t>(1, 0x8e9e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e9e); auto const rel = std::vector<uint32_t>(1, 0x8e9f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e9f); auto const rel = std::vector<uint32_t>(1, 0x8ea0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea0); auto const rel = std::vector<uint32_t>(1, 0x8e9d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e9d); auto const rel = std::vector<uint32_t>(1, 0x91be); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91be); auto const rel = std::vector<uint32_t>(1, 0x91bd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91bd); auto const rel = std::vector<uint32_t>(1, 0x91c2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91c2); auto const rel = std::vector<uint32_t>(1, 0x946b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x946b); auto const rel = std::vector<uint32_t>(1, 0x9468); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9468); auto const rel = std::vector<uint32_t>(1, 0x9469); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9469); auto const rel = std::vector<uint32_t>(1, 0x96e5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x96e5); auto const rel = std::vector<uint32_t>(1, 0x9746); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9746); auto const rel = std::vector<uint32_t>(1, 0x9743); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9743); auto const rel = std::vector<uint32_t>(1, 0x9747); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9747); auto const rel = std::vector<uint32_t>(1, 0x97c7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97c7); auto const rel = std::vector<uint32_t>(1, 0x97e5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97e5); auto const rel = std::vector<uint32_t>(1, 0x9a5e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a5e); auto const rel = std::vector<uint32_t>(1, 0x9ad5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ad5); auto const rel = std::vector<uint32_t>(1, 0x9b59); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b59); auto const rel = std::vector<uint32_t>(1, 0x9c63); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c63); auto const rel = std::vector<uint32_t>(1, 0x9c67); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c67); auto const rel = std::vector<uint32_t>(1, 0x9c66); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c66); auto const rel = std::vector<uint32_t>(1, 0x9c62); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c62); auto const rel = std::vector<uint32_t>(1, 0x9c5e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c5e); auto const rel = std::vector<uint32_t>(1, 0x9c60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c60); auto const rel = std::vector<uint32_t>(1, 0x9e02); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e02); auto const rel = std::vector<uint32_t>(1, 0x9dfe); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dfe); auto const rel = std::vector<uint32_t>(1, 0x9e07); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e07); auto const rel = std::vector<uint32_t>(1, 0x9e03); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e03); auto const rel = std::vector<uint32_t>(1, 0x9e06); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e06); auto const rel = std::vector<uint32_t>(1, 0x9e05); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e05); auto const rel = std::vector<uint32_t>(1, 0x9e00); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e00); auto const rel = std::vector<uint32_t>(1, 0x9e01); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e01); auto const rel = std::vector<uint32_t>(1, 0x9e09); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e09); auto const rel = std::vector<uint32_t>(1, 0x9dff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dff); auto const rel = std::vector<uint32_t>(1, 0x9dfd); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dfd); auto const rel = std::vector<uint32_t>(1, 0x9e04); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_016) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e04); auto const rel = std::vector<uint32_t>(1, 0x9ea0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ea0); auto const rel = std::vector<uint32_t>(1, 0x9f1e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1e); auto const rel = std::vector<uint32_t>(1, 0x9f46); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f46); auto const rel = std::vector<uint32_t>(1, 0x9f74); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f74); auto const rel = std::vector<uint32_t>(1, 0x9f75); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f75); auto const rel = std::vector<uint32_t>(1, 0x9f76); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f76); auto const rel = std::vector<uint32_t>(1, 0x56d4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56d4); auto const rel = std::vector<uint32_t>(1, 0x652e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x652e); auto const rel = std::vector<uint32_t>(1, 0x65b8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65b8); auto const rel = std::vector<uint32_t>(1, 0x6b18); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b18); auto const rel = std::vector<uint32_t>(1, 0x6b19); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b19); auto const rel = std::vector<uint32_t>(1, 0x6b17); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b17); auto const rel = std::vector<uint32_t>(1, 0x6b1a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b1a); auto const rel = std::vector<uint32_t>(1, 0x7062); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7062); auto const rel = std::vector<uint32_t>(1, 0x7226); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7226); auto const rel = std::vector<uint32_t>(1, 0x72aa); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72aa); auto const rel = std::vector<uint32_t>(1, 0x77d8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d8); auto const rel = std::vector<uint32_t>(1, 0x77d9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77d9); auto const rel = std::vector<uint32_t>(1, 0x7939); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7939); auto const rel = std::vector<uint32_t>(1, 0x7c69); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c69); auto const rel = std::vector<uint32_t>(1, 0x7c6b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c6b); auto const rel = std::vector<uint32_t>(1, 0x7cf6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf6); auto const rel = std::vector<uint32_t>(1, 0x7e9a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e9a); auto const rel = std::vector<uint32_t>(1, 0x7e98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e98); auto const rel = std::vector<uint32_t>(1, 0x7e9b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e9b); auto const rel = std::vector<uint32_t>(1, 0x7e99); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e99); auto const rel = std::vector<uint32_t>(1, 0x81e0); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81e0); auto const rel = std::vector<uint32_t>(1, 0x81e1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81e1); auto const rel = std::vector<uint32_t>(1, 0x8646); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8646); auto const rel = std::vector<uint32_t>(1, 0x8647); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8647); auto const rel = std::vector<uint32_t>(1, 0x8648); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8648); auto const rel = std::vector<uint32_t>(1, 0x8979); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8979); auto const rel = std::vector<uint32_t>(1, 0x897a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x897a); auto const rel = std::vector<uint32_t>(1, 0x897c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x897c); auto const rel = std::vector<uint32_t>(1, 0x897b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x897b); auto const rel = std::vector<uint32_t>(1, 0x89ff); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89ff); auto const rel = std::vector<uint32_t>(1, 0x8b98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b98); auto const rel = std::vector<uint32_t>(1, 0x8b99); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b99); auto const rel = std::vector<uint32_t>(1, 0x8ea5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea5); auto const rel = std::vector<uint32_t>(1, 0x8ea4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea4); auto const rel = std::vector<uint32_t>(1, 0x8ea3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea3); auto const rel = std::vector<uint32_t>(1, 0x946e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x946e); auto const rel = std::vector<uint32_t>(1, 0x946d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x946d); auto const rel = std::vector<uint32_t>(1, 0x946f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x946f); auto const rel = std::vector<uint32_t>(1, 0x9471); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9471); auto const rel = std::vector<uint32_t>(1, 0x9473); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9473); auto const rel = std::vector<uint32_t>(1, 0x9749); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9749); auto const rel = std::vector<uint32_t>(1, 0x9872); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9872); auto const rel = std::vector<uint32_t>(1, 0x995f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x995f); auto const rel = std::vector<uint32_t>(1, 0x9c68); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c68); auto const rel = std::vector<uint32_t>(1, 0x9c6e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_017) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c6e); auto const rel = std::vector<uint32_t>(1, 0x9c6d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c6d); auto const rel = std::vector<uint32_t>(1, 0x9e0b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e0b); auto const rel = std::vector<uint32_t>(1, 0x9e0d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e0d); auto const rel = std::vector<uint32_t>(1, 0x9e10); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e10); auto const rel = std::vector<uint32_t>(1, 0x9e0f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e0f); auto const rel = std::vector<uint32_t>(1, 0x9e12); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e12); auto const rel = std::vector<uint32_t>(1, 0x9e11); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e11); auto const rel = std::vector<uint32_t>(1, 0x9ea1); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ea1); auto const rel = std::vector<uint32_t>(1, 0x9ef5); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef5); auto const rel = std::vector<uint32_t>(1, 0x9f09); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f09); auto const rel = std::vector<uint32_t>(1, 0x9f47); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f47); auto const rel = std::vector<uint32_t>(1, 0x9f78); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f78); auto const rel = std::vector<uint32_t>(1, 0x9f7b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f7b); auto const rel = std::vector<uint32_t>(1, 0x9f7a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f7a); auto const rel = std::vector<uint32_t>(1, 0x9f79); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f79); auto const rel = std::vector<uint32_t>(1, 0x571e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x571e); auto const rel = std::vector<uint32_t>(1, 0x7066); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7066); auto const rel = std::vector<uint32_t>(1, 0x7c6f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c6f); auto const rel = std::vector<uint32_t>(1, 0x883c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x883c); auto const rel = std::vector<uint32_t>(1, 0x8db2); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8db2); auto const rel = std::vector<uint32_t>(1, 0x8ea6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea6); auto const rel = std::vector<uint32_t>(1, 0x91c3); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91c3); auto const rel = std::vector<uint32_t>(1, 0x9474); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9474); auto const rel = std::vector<uint32_t>(1, 0x9478); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9478); auto const rel = std::vector<uint32_t>(1, 0x9476); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9476); auto const rel = std::vector<uint32_t>(1, 0x9475); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9475); auto const rel = std::vector<uint32_t>(1, 0x9a60); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a60); auto const rel = std::vector<uint32_t>(1, 0x9c74); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c74); auto const rel = std::vector<uint32_t>(1, 0x9c73); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c73); auto const rel = std::vector<uint32_t>(1, 0x9c71); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c71); auto const rel = std::vector<uint32_t>(1, 0x9c75); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c75); auto const rel = std::vector<uint32_t>(1, 0x9e14); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e14); auto const rel = std::vector<uint32_t>(1, 0x9e13); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e13); auto const rel = std::vector<uint32_t>(1, 0x9ef6); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef6); auto const rel = std::vector<uint32_t>(1, 0x9f0a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f0a); auto const rel = std::vector<uint32_t>(1, 0x9fa4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9fa4); auto const rel = std::vector<uint32_t>(1, 0x7068); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7068); auto const rel = std::vector<uint32_t>(1, 0x7065); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7065); auto const rel = std::vector<uint32_t>(1, 0x7cf7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cf7); auto const rel = std::vector<uint32_t>(1, 0x866a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x866a); auto const rel = std::vector<uint32_t>(1, 0x883e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x883e); auto const rel = std::vector<uint32_t>(1, 0x883d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x883d); auto const rel = std::vector<uint32_t>(1, 0x883f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x883f); auto const rel = std::vector<uint32_t>(1, 0x8b9e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b9e); auto const rel = std::vector<uint32_t>(1, 0x8c9c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c9c); auto const rel = std::vector<uint32_t>(1, 0x8ea9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea9); auto const rel = std::vector<uint32_t>(1, 0x8ec9); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ec9); auto const rel = std::vector<uint32_t>(1, 0x974b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x974b); auto const rel = std::vector<uint32_t>(1, 0x9873); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9873); auto const rel = std::vector<uint32_t>(1, 0x9874); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9874); auto const rel = std::vector<uint32_t>(1, 0x98cc); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_big5han_012_018) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98cc); auto const rel = std::vector<uint32_t>(1, 0x9961); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9961); auto const rel = std::vector<uint32_t>(1, 0x99ab); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99ab); auto const rel = std::vector<uint32_t>(1, 0x9a64); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a64); auto const rel = std::vector<uint32_t>(1, 0x9a66); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a66); auto const rel = std::vector<uint32_t>(1, 0x9a67); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a67); auto const rel = std::vector<uint32_t>(1, 0x9b24); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b24); auto const rel = std::vector<uint32_t>(1, 0x9e15); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e15); auto const rel = std::vector<uint32_t>(1, 0x9e17); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e17); auto const rel = std::vector<uint32_t>(1, 0x9f48); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f48); auto const rel = std::vector<uint32_t>(1, 0x6207); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6207); auto const rel = std::vector<uint32_t>(1, 0x6b1e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b1e); auto const rel = std::vector<uint32_t>(1, 0x7227); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7227); auto const rel = std::vector<uint32_t>(1, 0x864c); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x864c); auto const rel = std::vector<uint32_t>(1, 0x8ea8); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea8); auto const rel = std::vector<uint32_t>(1, 0x9482); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9482); auto const rel = std::vector<uint32_t>(1, 0x9480); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9480); auto const rel = std::vector<uint32_t>(1, 0x9481); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9481); auto const rel = std::vector<uint32_t>(1, 0x9a69); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a69); auto const rel = std::vector<uint32_t>(1, 0x9a68); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a68); auto const rel = std::vector<uint32_t>(1, 0x9b2e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b2e); auto const rel = std::vector<uint32_t>(1, 0x9e19); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e19); auto const rel = std::vector<uint32_t>(1, 0x7229); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7229); auto const rel = std::vector<uint32_t>(1, 0x864b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x864b); auto const rel = std::vector<uint32_t>(1, 0x8b9f); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b9f); auto const rel = std::vector<uint32_t>(1, 0x9483); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9483); auto const rel = std::vector<uint32_t>(1, 0x9c79); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c79); auto const rel = std::vector<uint32_t>(1, 0x9eb7); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eb7); auto const rel = std::vector<uint32_t>(1, 0x7675); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7675); auto const rel = std::vector<uint32_t>(1, 0x9a6b); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a6b); auto const rel = std::vector<uint32_t>(1, 0x9c7a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c7a); auto const rel = std::vector<uint32_t>(1, 0x9e1d); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e1d); auto const rel = std::vector<uint32_t>(1, 0x7069); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7069); auto const rel = std::vector<uint32_t>(1, 0x706a); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x706a); auto const rel = std::vector<uint32_t>(1, 0x9ea4); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ea4); auto const rel = std::vector<uint32_t>(1, 0x9f7e); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f7e); auto const rel = std::vector<uint32_t>(1, 0x9f49); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f49); auto const rel = std::vector<uint32_t>(1, 0x9f98); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); } }
312,429
118,910
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! #include "config.h" #include "V8SVGPreserveAspectRatio.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/V8DOMConfiguration.h" #include "bindings/core/v8/V8ObjectConstructor.h" #include "bindings/core/v8/V8SVGElement.h" #include "core/dom/ContextFeatures.h" #include "core/dom/Document.h" #include "core/frame/UseCounter.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/TraceEvent.h" #include "wtf/GetPtr.h" #include "wtf/RefPtr.h" namespace blink { // Suppress warning: global constructors, because struct WrapperTypeInfo is trivial // and does not depend on another global objects. #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wglobal-constructors" #endif const WrapperTypeInfo V8SVGPreserveAspectRatio::wrapperTypeInfo = { gin::kEmbedderBlink, V8SVGPreserveAspectRatio::domTemplate, V8SVGPreserveAspectRatio::refObject, V8SVGPreserveAspectRatio::derefObject, V8SVGPreserveAspectRatio::trace, 0, V8SVGPreserveAspectRatio::visitDOMWrapper, V8SVGPreserveAspectRatio::preparePrototypeObject, V8SVGPreserveAspectRatio::installConditionallyEnabledProperties, "SVGPreserveAspectRatio", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::NotInheritFromEventTarget, WrapperTypeInfo::Dependent, WrapperTypeInfo::WillBeGarbageCollectedObject }; #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) #pragma clang diagnostic pop #endif // This static member must be declared by DEFINE_WRAPPERTYPEINFO in SVGPreserveAspectRatioTearOff.h. // For details, see the comment of DEFINE_WRAPPERTYPEINFO in // bindings/core/v8/ScriptWrappable.h. const WrapperTypeInfo& SVGPreserveAspectRatioTearOff::s_wrapperTypeInfo = V8SVGPreserveAspectRatio::wrapperTypeInfo; namespace SVGPreserveAspectRatioTearOffV8Internal { static void alignAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); SVGPreserveAspectRatioTearOff* impl = V8SVGPreserveAspectRatio::toImpl(holder); v8SetReturnValueUnsigned(info, impl->align()); } static void alignAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); SVGPreserveAspectRatioTearOffV8Internal::alignAttributeGetter(info); TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); } static void alignAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); ExceptionState exceptionState(ExceptionState::SetterContext, "align", "SVGPreserveAspectRatio", holder, info.GetIsolate()); SVGPreserveAspectRatioTearOff* impl = V8SVGPreserveAspectRatio::toImpl(holder); unsigned cppValue = toUInt16(info.GetIsolate(), v8Value, NormalConversion, exceptionState); if (exceptionState.throwIfNeeded()) return; impl->setAlign(cppValue, exceptionState); exceptionState.throwIfNeeded(); } static void alignAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Value> v8Value = info[0]; TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); SVGPreserveAspectRatioTearOffV8Internal::alignAttributeSetter(v8Value, info); TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); } static void meetOrSliceAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); SVGPreserveAspectRatioTearOff* impl = V8SVGPreserveAspectRatio::toImpl(holder); v8SetReturnValueUnsigned(info, impl->meetOrSlice()); } static void meetOrSliceAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); SVGPreserveAspectRatioTearOffV8Internal::meetOrSliceAttributeGetter(info); TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); } static void meetOrSliceAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); ExceptionState exceptionState(ExceptionState::SetterContext, "meetOrSlice", "SVGPreserveAspectRatio", holder, info.GetIsolate()); SVGPreserveAspectRatioTearOff* impl = V8SVGPreserveAspectRatio::toImpl(holder); unsigned cppValue = toUInt16(info.GetIsolate(), v8Value, NormalConversion, exceptionState); if (exceptionState.throwIfNeeded()) return; impl->setMeetOrSlice(cppValue, exceptionState); exceptionState.throwIfNeeded(); } static void meetOrSliceAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Value> v8Value = info[0]; TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); SVGPreserveAspectRatioTearOffV8Internal::meetOrSliceAttributeSetter(v8Value, info); TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); } } // namespace SVGPreserveAspectRatioTearOffV8Internal void V8SVGPreserveAspectRatio::visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* scriptWrappable, const v8::Persistent<v8::Object>& wrapper) { SVGPreserveAspectRatioTearOff* impl = scriptWrappable->toImpl<SVGPreserveAspectRatioTearOff>(); v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate, wrapper); V8WrapperInstantiationScope scope(creationContext, isolate); SVGElement* contextElement = impl->contextElement(); if (contextElement) { if (DOMDataStore::containsWrapper(contextElement, isolate)) DOMDataStore::setWrapperReference(wrapper, contextElement, isolate); } } static const V8DOMConfiguration::AccessorConfiguration V8SVGPreserveAspectRatioAccessors[] = { {"align", SVGPreserveAspectRatioTearOffV8Internal::alignAttributeGetterCallback, SVGPreserveAspectRatioTearOffV8Internal::alignAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder}, {"meetOrSlice", SVGPreserveAspectRatioTearOffV8Internal::meetOrSliceAttributeGetterCallback, SVGPreserveAspectRatioTearOffV8Internal::meetOrSliceAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder}, }; static void installV8SVGPreserveAspectRatioTemplate(v8::Local<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) { functionTemplate->ReadOnlyPrototype(); v8::Local<v8::Signature> defaultSignature; if (!RuntimeEnabledFeatures::svg1DOMEnabled()) defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "SVGPreserveAspectRatio", v8::Local<v8::FunctionTemplate>(), V8SVGPreserveAspectRatio::internalFieldCount, 0, 0, 0, 0, 0, 0); else defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "SVGPreserveAspectRatio", v8::Local<v8::FunctionTemplate>(), V8SVGPreserveAspectRatio::internalFieldCount, 0, 0, V8SVGPreserveAspectRatioAccessors, WTF_ARRAY_LENGTH(V8SVGPreserveAspectRatioAccessors), 0, 0); v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate(); ALLOW_UNUSED_LOCAL(instanceTemplate); v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate(); ALLOW_UNUSED_LOCAL(prototypeTemplate); static const V8DOMConfiguration::ConstantConfiguration V8SVGPreserveAspectRatioConstants[] = { {"SVG_PRESERVEASPECTRATIO_UNKNOWN", 0, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_NONE", 1, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMINYMIN", 2, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMIDYMIN", 3, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMAXYMIN", 4, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMINYMID", 5, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMIDYMID", 6, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMAXYMID", 7, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMINYMAX", 8, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMIDYMAX", 9, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_PRESERVEASPECTRATIO_XMAXYMAX", 10, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_MEETORSLICE_UNKNOWN", 0, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_MEETORSLICE_MEET", 1, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, {"SVG_MEETORSLICE_SLICE", 2, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}, }; V8DOMConfiguration::installConstants(isolate, functionTemplate, prototypeTemplate, V8SVGPreserveAspectRatioConstants, WTF_ARRAY_LENGTH(V8SVGPreserveAspectRatioConstants)); static_assert(0 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_UNKNOWN, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_UNKNOWN does not match with implementation"); static_assert(1 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_NONE, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_NONE does not match with implementation"); static_assert(2 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMINYMIN, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMINYMIN does not match with implementation"); static_assert(3 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMIDYMIN, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMIDYMIN does not match with implementation"); static_assert(4 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMAXYMIN, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMAXYMIN does not match with implementation"); static_assert(5 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMINYMID, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMINYMID does not match with implementation"); static_assert(6 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMIDYMID, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMIDYMID does not match with implementation"); static_assert(7 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMAXYMID, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMAXYMID does not match with implementation"); static_assert(8 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMINYMAX, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMINYMAX does not match with implementation"); static_assert(9 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMIDYMAX, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMIDYMAX does not match with implementation"); static_assert(10 == SVGPreserveAspectRatioTearOff::SVG_PRESERVEASPECTRATIO_XMAXYMAX, "the value of SVGPreserveAspectRatioTearOff_SVG_PRESERVEASPECTRATIO_XMAXYMAX does not match with implementation"); static_assert(0 == SVGPreserveAspectRatioTearOff::SVG_MEETORSLICE_UNKNOWN, "the value of SVGPreserveAspectRatioTearOff_SVG_MEETORSLICE_UNKNOWN does not match with implementation"); static_assert(1 == SVGPreserveAspectRatioTearOff::SVG_MEETORSLICE_MEET, "the value of SVGPreserveAspectRatioTearOff_SVG_MEETORSLICE_MEET does not match with implementation"); static_assert(2 == SVGPreserveAspectRatioTearOff::SVG_MEETORSLICE_SLICE, "the value of SVGPreserveAspectRatioTearOff_SVG_MEETORSLICE_SLICE does not match with implementation"); // Custom toString template functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); } v8::Local<v8::FunctionTemplate> V8SVGPreserveAspectRatio::domTemplate(v8::Isolate* isolate) { return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8SVGPreserveAspectRatioTemplate); } bool V8SVGPreserveAspectRatio::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate) { return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); } v8::Local<v8::Object> V8SVGPreserveAspectRatio::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate) { return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); } SVGPreserveAspectRatioTearOff* V8SVGPreserveAspectRatio::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value) { return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : 0; } void V8SVGPreserveAspectRatio::refObject(ScriptWrappable* scriptWrappable) { #if !ENABLE(OILPAN) scriptWrappable->toImpl<SVGPreserveAspectRatioTearOff>()->ref(); #endif } void V8SVGPreserveAspectRatio::derefObject(ScriptWrappable* scriptWrappable) { #if !ENABLE(OILPAN) scriptWrappable->toImpl<SVGPreserveAspectRatioTearOff>()->deref(); #endif } } // namespace blink
13,925
4,970
// Copyright (c) 1999, Google Inc. // 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 Google Inc. 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. #define _GNU_SOURCE 1 // needed for O_NOFOLLOW and pread()/pwrite() #include "utilities.h" #include <assert.h> #include <iomanip> #include <string> #ifdef HAVE_UNISTD_H # include <unistd.h> // For _exit. #endif #include <climits> #include <sys/types.h> #include <sys/stat.h> #ifdef HAVE_SYS_UTSNAME_H # include <sys/utsname.h> // For uname. #endif #include <fcntl.h> #include <cstdio> #include <iostream> #include <stdarg.h> #include <stdlib.h> #ifdef HAVE_PWD_H # include <pwd.h> #endif #ifdef HAVE_SYSLOG_H # include <syslog.h> #endif #include <vector> #include <errno.h> // for errno #include <sstream> #include "base/commandlineflags.h" // to get the program name #include "glog/logging.h" #include "glog/raw_logging.h" #include "base/googleinit.h" #ifdef HAVE_STACKTRACE # include "stacktrace.h" #endif using std::string; using std::vector; using std::ostrstream; using std::setw; using std::setfill; using std::hex; using std::dec; using std::min; using std::ostream; using std::ostringstream; using std::strstream; // There is no thread annotation support. #define EXCLUSIVE_LOCKS_REQUIRED(mu) static bool BoolFromEnv(const char *varname, bool defval) { const char* const valstr = getenv(varname); if (!valstr) { return defval; } return memchr("tTyY1\0", valstr[0], 6) != NULL; } GLOG_DEFINE_bool(logtostderr, BoolFromEnv("GOOGLE_LOGTOSTDERR", false), "log messages go to stderr instead of logfiles"); GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false), "log messages go to stderr in addition to logfiles"); #ifdef OS_LINUX GLOG_DEFINE_bool(drop_log_memory, true, "Drop in-memory buffers of log contents. " "Logs can grow very quickly and they are rarely read before they " "need to be evicted from memory. Instead, drop them from memory " "as soon as they are flushed to disk."); _START_GOOGLE_NAMESPACE_ namespace logging { static const int64 kPageSize = getpagesize(); } _END_GOOGLE_NAMESPACE_ #endif // By default, errors (including fatal errors) get logged to stderr as // well as the file. // // The default is ERROR instead of FATAL so that users can see problems // when they run a program without having to look in another file. DEFINE_int32(stderrthreshold, GOOGLE_NAMESPACE::ERROR, "log messages at or above this level are copied to stderr in " "addition to logfiles. This flag obsoletes --alsologtostderr."); GLOG_DEFINE_string(alsologtoemail, "", "log messages go to these email addresses " "in addition to logfiles"); GLOG_DEFINE_bool(log_prefix, true, "Prepend the log prefix to the start of each log line"); GLOG_DEFINE_int32(minloglevel, 0, "Messages logged at a lower level than this don't " "actually get logged anywhere"); GLOG_DEFINE_int32(logbuflevel, 0, "Buffer log messages logged at this level or lower" " (-1 means don't buffer; 0 means buffer INFO only;" " ...)"); GLOG_DEFINE_int32(logbufsecs, 30, "Buffer log messages for at most this many seconds"); GLOG_DEFINE_int32(logemaillevel, 999, "Email log messages logged at this level or higher" " (0 means email all; 3 means email FATAL only;" " ...)"); GLOG_DEFINE_string(logmailer, "/bin/mail", "Mailer used to send logging email"); // Compute the default value for --log_dir static const char* DefaultLogDir() { const char* env; env = getenv("GOOGLE_LOG_DIR"); if (env != NULL && env[0] != '\0') { return env; } env = getenv("TEST_TMPDIR"); if (env != NULL && env[0] != '\0') { return env; } return ""; } GLOG_DEFINE_string(log_dir, DefaultLogDir(), "If specified, logfiles are written into this directory instead " "of the default logging directory."); GLOG_DEFINE_string(log_link, "", "Put additional links to the log " "files in this directory"); GLOG_DEFINE_int32(max_log_size, 1800, "approx. maximum log file size (in MB). A value of 0 will " "be silently overridden to 1."); GLOG_DEFINE_bool(stop_logging_if_full_disk, false, "Stop attempting to log to disk if the disk is full."); GLOG_DEFINE_string(log_backtrace_at, "", "Emit a backtrace when logging at file:linenum."); // TODO(hamaji): consider windows #define PATH_SEPARATOR '/' static void GetHostName(string* hostname) { #if defined(HAVE_SYS_UTSNAME_H) struct utsname buf; if (0 != uname(&buf)) { // ensure null termination on failure *buf.nodename = '\0'; } *hostname = buf.nodename; #elif defined(OS_WINDOWS) char buf[MAX_COMPUTERNAME_LENGTH + 1]; DWORD len = MAX_COMPUTERNAME_LENGTH + 1; if (GetComputerNameA(buf, &len)) { *hostname = buf; } else { hostname->clear(); } #else # warning There is no way to retrieve the host name. *hostname = "(unknown)"; #endif } _START_GOOGLE_NAMESPACE_ // Safely get max_log_size, overriding to 1 if it somehow gets defined as 0 static int32 MaxLogSize() { return (FLAGS_max_log_size > 0 ? FLAGS_max_log_size : 1); } // A mutex that allows only one thread to log at a time, to keep things from // getting jumbled. Some other very uncommon logging operations (like // changing the destination file for log messages of a given severity) also // lock this mutex. Please be sure that anybody who might possibly need to // lock it does so. static Mutex log_mutex; // Number of messages sent at each severity. Under log_mutex. int64 LogMessage::num_messages_[NUM_SEVERITIES] = {0, 0, 0, 0}; // Globally disable log writing (if disk is full) static bool stop_writing = false; const char*const LogSeverityNames[NUM_SEVERITIES] = { "INFO", "WARNING", "ERROR", "FATAL" }; // Has the user called SetExitOnDFatal(true)? static bool exit_on_dfatal = true; const char* GetLogSeverityName(LogSeverity severity) { return LogSeverityNames[severity]; } static bool SendEmailInternal(const char*dest, const char *subject, const char*body, bool use_logging); base::Logger::~Logger() { } namespace { // Encapsulates all file-system related state class LogFileObject : public base::Logger { public: LogFileObject(LogSeverity severity, const char* base_filename); ~LogFileObject(); virtual void Write(bool force_flush, // Should we force a flush here? time_t timestamp, // Timestamp for this entry const char* message, int message_len); // Configuration options void SetBasename(const char* basename); void SetExtension(const char* ext); void SetSymlinkBasename(const char* symlink_basename); // Normal flushing routine virtual void Flush(); // It is the actual file length for the system loggers, // i.e., INFO, ERROR, etc. virtual uint32 LogSize() { MutexLock l(&lock_); return file_length_; } // Internal flush routine. Exposed so that FlushLogFilesUnsafe() // can avoid grabbing a lock. Usually Flush() calls it after // acquiring lock_. void FlushUnlocked(); private: static const uint32 kRolloverAttemptFrequency = 0x20; Mutex lock_; bool base_filename_selected_; string base_filename_; string symlink_basename_; string filename_extension_; // option users can specify (eg to add port#) FILE* file_; LogSeverity severity_; uint32 bytes_since_flush_; uint32 file_length_; unsigned int rollover_attempt_; int64 next_flush_time_; // cycle count at which to flush log // Actually create a logfile using the value of base_filename_ and the // supplied argument time_pid_string // REQUIRES: lock_ is held bool CreateLogfile(const char* time_pid_string); }; } // namespace class LogDestination { public: friend class LogMessage; friend void ReprintFatalMessage(); friend base::Logger* base::GetLogger(LogSeverity); friend void base::SetLogger(LogSeverity, base::Logger*); // These methods are just forwarded to by their global versions. static void SetLogDestination(LogSeverity severity, const char* base_filename); static void SetLogSymlink(LogSeverity severity, const char* symlink_basename); static void AddLogSink(LogSink *destination); static void RemoveLogSink(LogSink *destination); static void SetLogFilenameExtension(const char* filename_extension); static void SetStderrLogging(LogSeverity min_severity); static void SetEmailLogging(LogSeverity min_severity, const char* addresses); static void LogToStderr(); // Flush all log files that are at least at the given severity level static void FlushLogFiles(int min_severity); static void FlushLogFilesUnsafe(int min_severity); // we set the maximum size of our packet to be 1400, the logic being // to prevent fragmentation. // Really this number is arbitrary. static const int kNetworkBytes = 1400; static const string& hostname(); static void DeleteLogDestinations(); private: LogDestination(LogSeverity severity, const char* base_filename); ~LogDestination() { } // Take a log message of a particular severity and log it to stderr // iff it's of a high enough severity to deserve it. static void MaybeLogToStderr(LogSeverity severity, const char* message, size_t len); // Take a log message of a particular severity and log it to email // iff it's of a high enough severity to deserve it. static void MaybeLogToEmail(LogSeverity severity, const char* message, size_t len); // Take a log message of a particular severity and log it to a file // iff the base filename is not "" (which means "don't log to me") static void MaybeLogToLogfile(LogSeverity severity, time_t timestamp, const char* message, size_t len); // Take a log message of a particular severity and log it to the file // for that severity and also for all files with severity less than // this severity. static void LogToAllLogfiles(LogSeverity severity, time_t timestamp, const char* message, size_t len); // Send logging info to all registered sinks. static void LogToSinks(LogSeverity severity, const char *full_filename, const char *base_filename, int line, const struct ::tm* tm_time, const char* message, size_t message_len); // Wait for all registered sinks via WaitTillSent // including the optional one in "data". static void WaitForSinks(LogMessage::LogMessageData* data); static LogDestination* log_destination(LogSeverity severity); LogFileObject fileobject_; base::Logger* logger_; // Either &fileobject_, or wrapper around it static LogDestination* log_destinations_[NUM_SEVERITIES]; static LogSeverity email_logging_severity_; static string addresses_; static string hostname_; // arbitrary global logging destinations. static vector<LogSink*>* sinks_; // Protects the vector sinks_, // but not the LogSink objects its elements reference. static Mutex sink_mutex_; // Disallow LogDestination(const LogDestination&); LogDestination& operator=(const LogDestination&); }; // Errors do not get logged to email by default. LogSeverity LogDestination::email_logging_severity_ = 99999; string LogDestination::addresses_; string LogDestination::hostname_; vector<LogSink*>* LogDestination::sinks_ = NULL; Mutex LogDestination::sink_mutex_; /* static */ const string& LogDestination::hostname() { if (hostname_.empty()) { GetHostName(&hostname_); if (hostname_.empty()) { hostname_ = "(unknown)"; } } return hostname_; } LogDestination::LogDestination(LogSeverity severity, const char* base_filename) : fileobject_(severity, base_filename), logger_(&fileobject_) { } inline void LogDestination::FlushLogFilesUnsafe(int min_severity) { // assume we have the log_mutex or we simply don't care // about it for (int i = min_severity; i < NUM_SEVERITIES; i++) { LogDestination* log = log_destination(i); if (log != NULL) { // Flush the base fileobject_ logger directly instead of going // through any wrappers to reduce chance of deadlock. log->fileobject_.FlushUnlocked(); } } } inline void LogDestination::FlushLogFiles(int min_severity) { // Prevent any subtle race conditions by wrapping a mutex lock around // all this stuff. MutexLock l(&log_mutex); for (int i = min_severity; i < NUM_SEVERITIES; i++) { LogDestination* log = log_destination(i); if (log != NULL) { log->logger_->Flush(); } } } inline void LogDestination::SetLogDestination(LogSeverity severity, const char* base_filename) { assert(severity >= 0 && severity < NUM_SEVERITIES); // Prevent any subtle race conditions by wrapping a mutex lock around // all this stuff. MutexLock l(&log_mutex); log_destination(severity)->fileobject_.SetBasename(base_filename); } inline void LogDestination::SetLogSymlink(LogSeverity severity, const char* symlink_basename) { CHECK_GE(severity, 0); CHECK_LT(severity, NUM_SEVERITIES); MutexLock l(&log_mutex); log_destination(severity)->fileobject_.SetSymlinkBasename(symlink_basename); } inline void LogDestination::AddLogSink(LogSink *destination) { // Prevent any subtle race conditions by wrapping a mutex lock around // all this stuff. MutexLock l(&sink_mutex_); if (!sinks_) sinks_ = new vector<LogSink*>; sinks_->push_back(destination); } inline void LogDestination::RemoveLogSink(LogSink *destination) { // Prevent any subtle race conditions by wrapping a mutex lock around // all this stuff. MutexLock l(&sink_mutex_); // This doesn't keep the sinks in order, but who cares? if (sinks_) { for (int i = sinks_->size() - 1; i >= 0; i--) { if ((*sinks_)[i] == destination) { (*sinks_)[i] = (*sinks_)[sinks_->size() - 1]; sinks_->pop_back(); break; } } } } inline void LogDestination::SetLogFilenameExtension(const char* ext) { // Prevent any subtle race conditions by wrapping a mutex lock around // all this stuff. MutexLock l(&log_mutex); for ( int severity = 0; severity < NUM_SEVERITIES; ++severity ) { log_destination(severity)->fileobject_.SetExtension(ext); } } inline void LogDestination::SetStderrLogging(LogSeverity min_severity) { assert(min_severity >= 0 && min_severity < NUM_SEVERITIES); // Prevent any subtle race conditions by wrapping a mutex lock around // all this stuff. MutexLock l(&log_mutex); FLAGS_stderrthreshold = min_severity; } inline void LogDestination::LogToStderr() { // *Don't* put this stuff in a mutex lock, since SetStderrLogging & // SetLogDestination already do the locking! SetStderrLogging(0); // thus everything is "also" logged to stderr for ( int i = 0; i < NUM_SEVERITIES; ++i ) { SetLogDestination(i, ""); // "" turns off logging to a logfile } } inline void LogDestination::SetEmailLogging(LogSeverity min_severity, const char* addresses) { assert(min_severity >= 0 && min_severity < NUM_SEVERITIES); // Prevent any subtle race conditions by wrapping a mutex lock around // all this stuff. MutexLock l(&log_mutex); LogDestination::email_logging_severity_ = min_severity; LogDestination::addresses_ = addresses; } static void WriteToStderr(const char* message, size_t len) { // Avoid using cerr from this module since we may get called during // exit code, and cerr may be partially or fully destroyed by then. fwrite(message, len, 1, stderr); } inline void LogDestination::MaybeLogToStderr(LogSeverity severity, const char* message, size_t len) { if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) { WriteToStderr(message, len); #ifdef OS_WINDOWS // On Windows, also output to the debugger ::OutputDebugStringA(string(message,len).c_str()); #endif } } inline void LogDestination::MaybeLogToEmail(LogSeverity severity, const char* message, size_t len) { if (severity >= email_logging_severity_ || severity >= FLAGS_logemaillevel) { string to(FLAGS_alsologtoemail); if (!addresses_.empty()) { if (!to.empty()) { to += ","; } to += addresses_; } const string subject(string("[LOG] ") + LogSeverityNames[severity] + ": " + glog_internal_namespace_::ProgramInvocationShortName()); string body(hostname()); body += "\n\n"; body.append(message, len); // should NOT use SendEmail(). The caller of this function holds the // log_mutex and SendEmail() calls LOG/VLOG which will block trying to // acquire the log_mutex object. Use SendEmailInternal() and set // use_logging to false. SendEmailInternal(to.c_str(), subject.c_str(), body.c_str(), false); } } inline void LogDestination::MaybeLogToLogfile(LogSeverity severity, time_t timestamp, const char* message, size_t len) { const bool should_flush = severity > FLAGS_logbuflevel; LogDestination* destination = log_destination(severity); destination->logger_->Write(should_flush, timestamp, message, len); } inline void LogDestination::LogToAllLogfiles(LogSeverity severity, time_t timestamp, const char* message, size_t len) { if ( FLAGS_logtostderr ) // global flag: never log to file WriteToStderr(message, len); else for (int i = severity; i >= 0; --i) LogDestination::MaybeLogToLogfile(i, timestamp, message, len); } inline void LogDestination::LogToSinks(LogSeverity severity, const char *full_filename, const char *base_filename, int line, const struct ::tm* tm_time, const char* message, size_t message_len) { ReaderMutexLock l(&sink_mutex_); if (sinks_) { for (int i = sinks_->size() - 1; i >= 0; i--) { (*sinks_)[i]->send(severity, full_filename, base_filename, line, tm_time, message, message_len); } } } inline void LogDestination::WaitForSinks(LogMessage::LogMessageData* data) { ReaderMutexLock l(&sink_mutex_); if (sinks_) { for (int i = sinks_->size() - 1; i >= 0; i--) { (*sinks_)[i]->WaitTillSent(); } } const bool send_to_sink = (data->send_method_ == &LogMessage::SendToSink) || (data->send_method_ == &LogMessage::SendToSinkAndLog); if (send_to_sink && data->sink_ != NULL) { data->sink_->WaitTillSent(); } } LogDestination* LogDestination::log_destinations_[NUM_SEVERITIES]; inline LogDestination* LogDestination::log_destination(LogSeverity severity) { assert(severity >=0 && severity < NUM_SEVERITIES); if (!log_destinations_[severity]) { log_destinations_[severity] = new LogDestination(severity, NULL); } return log_destinations_[severity]; } void LogDestination::DeleteLogDestinations() { for (int severity = 0; severity < NUM_SEVERITIES; ++severity) { delete log_destinations_[severity]; log_destinations_[severity] = NULL; } } namespace { LogFileObject::LogFileObject(LogSeverity severity, const char* base_filename) : base_filename_selected_(base_filename != NULL), base_filename_((base_filename != NULL) ? base_filename : ""), symlink_basename_(glog_internal_namespace_::ProgramInvocationShortName()), filename_extension_(), file_(NULL), severity_(severity), bytes_since_flush_(0), file_length_(0), rollover_attempt_(kRolloverAttemptFrequency-1), next_flush_time_(0) { assert(severity >= 0); assert(severity < NUM_SEVERITIES); } LogFileObject::~LogFileObject() { MutexLock l(&lock_); if (file_ != NULL) { fclose(file_); file_ = NULL; } } void LogFileObject::SetBasename(const char* basename) { MutexLock l(&lock_); base_filename_selected_ = true; if (base_filename_ != basename) { // Get rid of old log file since we are changing names if (file_ != NULL) { fclose(file_); file_ = NULL; rollover_attempt_ = kRolloverAttemptFrequency-1; } base_filename_ = basename; } } void LogFileObject::SetExtension(const char* ext) { MutexLock l(&lock_); if (filename_extension_ != ext) { // Get rid of old log file since we are changing names if (file_ != NULL) { fclose(file_); file_ = NULL; rollover_attempt_ = kRolloverAttemptFrequency-1; } filename_extension_ = ext; } } void LogFileObject::SetSymlinkBasename(const char* symlink_basename) { MutexLock l(&lock_); symlink_basename_ = symlink_basename; } void LogFileObject::Flush() { MutexLock l(&lock_); FlushUnlocked(); } void LogFileObject::FlushUnlocked(){ if (file_ != NULL) { fflush(file_); bytes_since_flush_ = 0; } // Figure out when we are due for another flush. const int64 next = (FLAGS_logbufsecs * static_cast<int64>(1000000)); // in usec next_flush_time_ = CycleClock_Now() + UsecToCycles(next); } bool LogFileObject::CreateLogfile(const char* time_pid_string) { string string_filename = base_filename_+filename_extension_+ time_pid_string; const char* filename = string_filename.c_str(); int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0664); if (fd == -1) return false; #ifdef HAVE_FCNTL // Mark the file close-on-exec. We don't really care if this fails fcntl(fd, F_SETFD, FD_CLOEXEC); #endif file_ = fdopen(fd, "a"); // Make a FILE*. if (file_ == NULL) { // Man, we're screwed! close(fd); unlink(filename); // Erase the half-baked evidence: an unusable log file return false; } // We try to create a symlink called <program_name>.<severity>, // which is easier to use. (Every time we create a new logfile, // we destroy the old symlink and create a new one, so it always // points to the latest logfile.) If it fails, we're sad but it's // no error. if (!symlink_basename_.empty()) { // take directory from filename const char* slash = strrchr(filename, PATH_SEPARATOR); const string linkname = symlink_basename_ + '.' + LogSeverityNames[severity_]; string linkpath; if ( slash ) linkpath = string(filename, slash-filename+1); // get dirname linkpath += linkname; unlink(linkpath.c_str()); // delete old one if it exists // We must have unistd.h. #ifdef HAVE_UNISTD_H // Make the symlink be relative (in the same dir) so that if the // entire log directory gets relocated the link is still valid. const char *linkdest = slash ? (slash + 1) : filename; if (symlink(linkdest, linkpath.c_str()) != 0) { // silently ignore failures } // Make an additional link to the log file in a place specified by // FLAGS_log_link, if indicated if (!FLAGS_log_link.empty()) { linkpath = FLAGS_log_link + "/" + linkname; unlink(linkpath.c_str()); // delete old one if it exists if (symlink(filename, linkpath.c_str()) != 0) { // silently ignore failures } } #endif } return true; // Everything worked } void LogFileObject::Write(bool force_flush, time_t timestamp, const char* message, int message_len) { MutexLock l(&lock_); // We don't log if the base_name_ is "" (which means "don't write") if (base_filename_selected_ && base_filename_.empty()) { return; } if (static_cast<int>(file_length_ >> 20) >= MaxLogSize() || PidHasChanged()) { if (file_ != NULL) fclose(file_); file_ = NULL; file_length_ = bytes_since_flush_ = 0; rollover_attempt_ = kRolloverAttemptFrequency-1; } // If there's no destination file, make one before outputting if (file_ == NULL) { // Try to rollover the log file every 32 log messages. The only time // this could matter would be when we have trouble creating the log // file. If that happens, we'll lose lots of log messages, of course! if (++rollover_attempt_ != kRolloverAttemptFrequency) return; rollover_attempt_ = 0; struct ::tm tm_time; localtime_r(&timestamp, &tm_time); // The logfile's filename will have the date/time & pid in it char time_pid_string[256]; // More than enough chars for time, pid, \0 ostrstream time_pid_stream(time_pid_string, sizeof(time_pid_string)); time_pid_stream.fill('0'); time_pid_stream << 1900+tm_time.tm_year << setw(2) << 1+tm_time.tm_mon << setw(2) << tm_time.tm_mday << '-' << setw(2) << tm_time.tm_hour << setw(2) << tm_time.tm_min << setw(2) << tm_time.tm_sec << '.' << GetMainThreadPid() << '\0'; if (base_filename_selected_) { if (!CreateLogfile(time_pid_string)) { perror("Could not create log file"); fprintf(stderr, "COULD NOT CREATE LOGFILE '%s'!\n", time_pid_string); return; } } else { // If no base filename for logs of this severity has been set, use a // default base filename of // "<program name>.<hostname>.<user name>.log.<severity level>.". So // logfiles will have names like // webserver.examplehost.root.log.INFO.19990817-150000.4354, where // 19990817 is a date (1999 August 17), 150000 is a time (15:00:00), // and 4354 is the pid of the logging process. The date & time reflect // when the file was created for output. // // Where does the file get put? Successively try the directories // "/tmp", and "." string stripped_filename( glog_internal_namespace_::ProgramInvocationShortName()); string hostname; GetHostName(&hostname); string uidname = MyUserName(); // We should not call CHECK() here because this function can be // called after holding on to log_mutex. We don't want to // attempt to hold on to the same mutex, and get into a // deadlock. Simply use a name like invalid-user. if (uidname.empty()) uidname = "invalid-user"; stripped_filename = stripped_filename+'.'+hostname+'.' +uidname+".log." +LogSeverityNames[severity_]+'.'; // We're going to (potentially) try to put logs in several different dirs const vector<string> & log_dirs = GetLoggingDirectories(); // Go through the list of dirs, and try to create the log file in each // until we succeed or run out of options bool success = false; for (vector<string>::const_iterator dir = log_dirs.begin(); dir != log_dirs.end(); ++dir) { base_filename_ = *dir + "/" + stripped_filename; if ( CreateLogfile(time_pid_string) ) { success = true; break; } } // If we never succeeded, we have to give up if ( success == false ) { perror("Could not create logging file"); fprintf(stderr, "COULD NOT CREATE A LOGGINGFILE %s!", time_pid_string); return; } } // Write a header message into the log file char file_header_string[512]; // Enough chars for time and binary info ostrstream file_header_stream(file_header_string, sizeof(file_header_string)); file_header_stream.fill('0'); file_header_stream << "Log file created at: " << 1900+tm_time.tm_year << '/' << setw(2) << 1+tm_time.tm_mon << '/' << setw(2) << tm_time.tm_mday << ' ' << setw(2) << tm_time.tm_hour << ':' << setw(2) << tm_time.tm_min << ':' << setw(2) << tm_time.tm_sec << '\n' << "Running on machine: " << LogDestination::hostname() << '\n' << "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu " << "threadid file:line] msg" << '\n' << '\0'; int header_len = strlen(file_header_string); fwrite(file_header_string, 1, header_len, file_); file_length_ += header_len; bytes_since_flush_ += header_len; } // Write to LOG file if ( !stop_writing ) { // fwrite() doesn't return an error when the disk is full, for // messages that are less than 4096 bytes. When the disk is full, // it returns the message length for messages that are less than // 4096 bytes. fwrite() returns 4096 for message lengths that are // greater than 4096, thereby indicating an error. errno = 0; fwrite(message, 1, message_len, file_); if ( FLAGS_stop_logging_if_full_disk && errno == ENOSPC ) { // disk full, stop writing to disk stop_writing = true; // until the disk is return; } else { file_length_ += message_len; bytes_since_flush_ += message_len; } } else { if ( CycleClock_Now() >= next_flush_time_ ) stop_writing = false; // check to see if disk has free space. return; // no need to flush } // See important msgs *now*. Also, flush logs at least every 10^6 chars, // or every "FLAGS_logbufsecs" seconds. if ( force_flush || (bytes_since_flush_ >= 1000000) || (CycleClock_Now() >= next_flush_time_) ) { FlushUnlocked(); #ifdef OS_LINUX if (FLAGS_drop_log_memory) { if (file_length_ >= logging::kPageSize) { // don't evict the most recent page uint32 len = file_length_ & ~(logging::kPageSize - 1); posix_fadvise(fileno(file_), 0, len, POSIX_FADV_DONTNEED); } } #endif } } } // namespace // An arbitrary limit on the length of a single log message. This // is so that streaming can be done more efficiently. const size_t LogMessage::kMaxLogMessageLen = 30000; // Static log data space to avoid alloc failures in a LOG(FATAL) // // Since multiple threads may call LOG(FATAL), and we want to preserve // the data from the first call, we allocate two sets of space. One // for exclusive use by the first thread, and one for shared use by // all other threads. static Mutex fatal_msg_lock; static CrashReason crash_reason; static bool fatal_msg_exclusive = true; static char fatal_msg_buf_exclusive[LogMessage::kMaxLogMessageLen+1]; static char fatal_msg_buf_shared[LogMessage::kMaxLogMessageLen+1]; static LogMessage::LogStream fatal_msg_stream_exclusive( fatal_msg_buf_exclusive, LogMessage::kMaxLogMessageLen, 0); static LogMessage::LogStream fatal_msg_stream_shared( fatal_msg_buf_shared, LogMessage::kMaxLogMessageLen, 0); LogMessage::LogMessageData LogMessage::fatal_msg_data_exclusive_; LogMessage::LogMessageData LogMessage::fatal_msg_data_shared_; LogMessage::LogMessageData::~LogMessageData() { delete[] buf_; delete stream_alloc_; } LogMessage::LogMessage(const char* file, int line, LogSeverity severity, int ctr, void (LogMessage::*send_method)()) { Init(file, line, severity, send_method); data_->stream_->set_ctr(ctr); } LogMessage::LogMessage(const char* file, int line, const CheckOpString& result) { Init(file, line, FATAL, &LogMessage::SendToLog); stream() << "Check failed: " << (*result.str_) << " "; } LogMessage::LogMessage(const char* file, int line) { Init(file, line, INFO, &LogMessage::SendToLog); } LogMessage::LogMessage(const char* file, int line, LogSeverity severity) { Init(file, line, severity, &LogMessage::SendToLog); } LogMessage::LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink, bool also_send_to_log) { Init(file, line, severity, also_send_to_log ? &LogMessage::SendToSinkAndLog : &LogMessage::SendToSink); data_->sink_ = sink; // override Init()'s setting to NULL } LogMessage::LogMessage(const char* file, int line, LogSeverity severity, vector<string> *outvec) { Init(file, line, severity, &LogMessage::SaveOrSendToLog); data_->outvec_ = outvec; // override Init()'s setting to NULL } LogMessage::LogMessage(const char* file, int line, LogSeverity severity, string *message) { Init(file, line, severity, &LogMessage::WriteToStringAndLog); data_->message_ = message; // override Init()'s setting to NULL } void LogMessage::Init(const char* file, int line, LogSeverity severity, void (LogMessage::*send_method)()) { allocated_ = NULL; if (severity != FATAL || !exit_on_dfatal) { allocated_ = new LogMessageData(); data_ = allocated_; data_->buf_ = new char[kMaxLogMessageLen+1]; data_->message_text_ = data_->buf_; data_->stream_alloc_ = new LogStream(data_->message_text_, kMaxLogMessageLen, 0); data_->stream_ = data_->stream_alloc_; data_->first_fatal_ = false; } else { MutexLock l(&fatal_msg_lock); if (fatal_msg_exclusive) { fatal_msg_exclusive = false; data_ = &fatal_msg_data_exclusive_; data_->message_text_ = fatal_msg_buf_exclusive; data_->stream_ = &fatal_msg_stream_exclusive; data_->first_fatal_ = true; } else { data_ = &fatal_msg_data_shared_; data_->message_text_ = fatal_msg_buf_shared; data_->stream_ = &fatal_msg_stream_shared; data_->first_fatal_ = false; } data_->stream_alloc_ = NULL; } stream().fill('0'); data_->preserved_errno_ = errno; data_->severity_ = severity; data_->line_ = line; data_->send_method_ = send_method; data_->sink_ = NULL; data_->outvec_ = NULL; WallTime now = WallTime_Now(); data_->timestamp_ = static_cast<time_t>(now); localtime_r(&data_->timestamp_, &data_->tm_time_); int usecs = static_cast<int>((now - data_->timestamp_) * 1000000); RawLog__SetLastTime(data_->tm_time_, usecs); data_->num_chars_to_log_ = 0; data_->num_chars_to_syslog_ = 0; data_->basename_ = const_basename(file); data_->fullname_ = file; data_->has_been_flushed_ = false; // If specified, prepend a prefix to each line. For example: // I1018 160715 f5d4fbb0 logging.cc:1153] // (log level, GMT month, date, time, thread_id, file basename, line) // We exclude the thread_id for the default thread. if (FLAGS_log_prefix && (line != kNoLogPrefix)) { stream() << LogSeverityNames[severity][0] << setw(2) << 1+data_->tm_time_.tm_mon << setw(2) << data_->tm_time_.tm_mday << ' ' << setw(2) << data_->tm_time_.tm_hour << ':' << setw(2) << data_->tm_time_.tm_min << ':' << setw(2) << data_->tm_time_.tm_sec << "." << setw(6) << usecs << ' ' << setfill(' ') << setw(5) << static_cast<unsigned int>(GetTID()) << setfill('0') << ' ' << data_->basename_ << ':' << data_->line_ << "] "; } data_->num_prefix_chars_ = data_->stream_->pcount(); if (!FLAGS_log_backtrace_at.empty()) { char fileline[128]; snprintf(fileline, sizeof(fileline), "%s:%d", data_->basename_, line); #ifdef HAVE_STACKTRACE if (!strcmp(FLAGS_log_backtrace_at.c_str(), fileline)) { string stacktrace; DumpStackTraceToString(&stacktrace); stream() << " (stacktrace:\n" << stacktrace << ") "; } #endif } } LogMessage::~LogMessage() { Flush(); delete allocated_; } // Flush buffered message, called by the destructor, or any other function // that needs to synchronize the log. void LogMessage::Flush() { if (data_->has_been_flushed_ || data_->severity_ < FLAGS_minloglevel) return; data_->num_chars_to_log_ = data_->stream_->pcount(); data_->num_chars_to_syslog_ = data_->num_chars_to_log_ - data_->num_prefix_chars_; // Do we need to add a \n to the end of this message? bool append_newline = (data_->message_text_[data_->num_chars_to_log_-1] != '\n'); char original_final_char = '\0'; // If we do need to add a \n, we'll do it by violating the memory of the // ostrstream buffer. This is quick, and we'll make sure to undo our // modification before anything else is done with the ostrstream. It // would be preferable not to do things this way, but it seems to be // the best way to deal with this. if (append_newline) { original_final_char = data_->message_text_[data_->num_chars_to_log_]; data_->message_text_[data_->num_chars_to_log_++] = '\n'; } // Prevent any subtle race conditions by wrapping a mutex lock around // the actual logging action per se. { MutexLock l(&log_mutex); (this->*(data_->send_method_))(); ++num_messages_[static_cast<int>(data_->severity_)]; } LogDestination::WaitForSinks(data_); if (append_newline) { // Fix the ostrstream back how it was before we screwed with it. // It's 99.44% certain that we don't need to worry about doing this. data_->message_text_[data_->num_chars_to_log_-1] = original_final_char; } // If errno was already set before we enter the logging call, we'll // set it back to that value when we return from the logging call. // It happens often that we log an error message after a syscall // failure, which can potentially set the errno to some other // values. We would like to preserve the original errno. if (data_->preserved_errno_ != 0) { errno = data_->preserved_errno_; } // Note that this message is now safely logged. If we're asked to flush // again, as a result of destruction, say, we'll do nothing on future calls. data_->has_been_flushed_ = true; } // Copy of first FATAL log message so that we can print it out again // after all the stack traces. To preserve legacy behavior, we don't // use fatal_msg_buf_exclusive. static time_t fatal_time; static char fatal_message[256]; void ReprintFatalMessage() { if (fatal_message[0]) { const int n = strlen(fatal_message); if (!FLAGS_logtostderr) { // Also write to stderr WriteToStderr(fatal_message, n); } LogDestination::LogToAllLogfiles(ERROR, fatal_time, fatal_message, n); } } // L >= log_mutex (callers must hold the log_mutex). void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { static bool already_warned_before_initgoogle = false; log_mutex.AssertHeld(); RAW_DCHECK(data_->num_chars_to_log_ > 0 && data_->message_text_[data_->num_chars_to_log_-1] == '\n', ""); // Messages of a given severity get logged to lower severity logs, too if (!already_warned_before_initgoogle && !IsGoogleLoggingInitialized()) { const char w[] = "WARNING: Logging before InitGoogleLogging() is " "written to STDERR\n"; WriteToStderr(w, strlen(w)); already_warned_before_initgoogle = true; } // global flag: never log to file if set. Also -- don't log to a // file if we haven't parsed the command line flags to get the // program name. if (FLAGS_logtostderr || !IsGoogleLoggingInitialized()) { WriteToStderr(data_->message_text_, data_->num_chars_to_log_); // this could be protected by a flag if necessary. LogDestination::LogToSinks(data_->severity_, data_->fullname_, data_->basename_, data_->line_, &data_->tm_time_, data_->message_text_ + data_->num_prefix_chars_, (data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1)); } else { // log this message to all log files of severity <= severity_ LogDestination::LogToAllLogfiles(data_->severity_, data_->timestamp_, data_->message_text_, data_->num_chars_to_log_); LogDestination::MaybeLogToStderr(data_->severity_, data_->message_text_, data_->num_chars_to_log_); LogDestination::MaybeLogToEmail(data_->severity_, data_->message_text_, data_->num_chars_to_log_); LogDestination::LogToSinks(data_->severity_, data_->fullname_, data_->basename_, data_->line_, &data_->tm_time_, data_->message_text_ + data_->num_prefix_chars_, (data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1)); // NOTE: -1 removes trailing \n } // If we log a FATAL message, flush all the log destinations, then toss // a signal for others to catch. We leave the logs in a state that // someone else can use them (as long as they flush afterwards) if (data_->severity_ == FATAL && exit_on_dfatal) { if (data_->first_fatal_) { // Store crash information so that it is accessible from within signal // handlers that may be invoked later. RecordCrashReason(&crash_reason); SetCrashReason(&crash_reason); // Store shortened fatal message for other logs and GWQ status const int copy = min<int>(data_->num_chars_to_log_, sizeof(fatal_message)-1); memcpy(fatal_message, data_->message_text_, copy); fatal_message[copy] = '\0'; fatal_time = data_->timestamp_; } if (!FLAGS_logtostderr) { for (int i = 0; i < NUM_SEVERITIES; ++i) { if ( LogDestination::log_destinations_[i] ) LogDestination::log_destinations_[i]->logger_->Write(true, 0, "", 0); } } // release the lock that our caller (directly or indirectly) // LogMessage::~LogMessage() grabbed so that signal handlers // can use the logging facility. Alternately, we could add // an entire unsafe logging interface to bypass locking // for signal handlers but this seems simpler. log_mutex.Unlock(); LogDestination::WaitForSinks(data_); const char* message = "*** Check failure stack trace: ***\n"; if (write(STDERR_FILENO, message, strlen(message)) < 0) { // Ignore errors. } Fail(); } } void LogMessage::RecordCrashReason( glog_internal_namespace_::CrashReason* reason) { reason->filename = fatal_msg_data_exclusive_.fullname_; reason->line_number = fatal_msg_data_exclusive_.line_; reason->message = fatal_msg_buf_exclusive + fatal_msg_data_exclusive_.num_prefix_chars_; #ifdef HAVE_STACKTRACE // Retrieve the stack trace, omitting the logging frames that got us here. reason->depth = GetStackTrace(reason->stack, ARRAYSIZE(reason->stack), 4); #else reason->depth = 0; #endif } static void logging_fail() { #if defined(_DEBUG) && defined(_MSC_VER) // When debugging on windows, avoid the obnoxious dialog and make // it possible to continue past a LOG(FATAL) in the debugger _asm int 3 #else abort(); #endif } #ifdef HAVE___ATTRIBUTE__ GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)() __attribute__((noreturn)) = &logging_fail; #else GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)() = &logging_fail; #endif void InstallFailureFunction(void (*fail_func)()) { g_logging_fail_func = fail_func; } void LogMessage::Fail() { g_logging_fail_func(); } // L >= log_mutex (callers must hold the log_mutex). void LogMessage::SendToSink() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { if (data_->sink_ != NULL) { RAW_DCHECK(data_->num_chars_to_log_ > 0 && data_->message_text_[data_->num_chars_to_log_-1] == '\n', ""); data_->sink_->send(data_->severity_, data_->fullname_, data_->basename_, data_->line_, &data_->tm_time_, data_->message_text_ + data_->num_prefix_chars_, (data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1)); } } // L >= log_mutex (callers must hold the log_mutex). void LogMessage::SendToSinkAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { SendToSink(); SendToLog(); } // L >= log_mutex (callers must hold the log_mutex). void LogMessage::SaveOrSendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { if (data_->outvec_ != NULL) { RAW_DCHECK(data_->num_chars_to_log_ > 0 && data_->message_text_[data_->num_chars_to_log_-1] == '\n', ""); // Omit prefix of message and trailing newline when recording in outvec_. const char *start = data_->message_text_ + data_->num_prefix_chars_; int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1; data_->outvec_->push_back(string(start, len)); } else { SendToLog(); } } void LogMessage::WriteToStringAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { if (data_->message_ != NULL) { RAW_DCHECK(data_->num_chars_to_log_ > 0 && data_->message_text_[data_->num_chars_to_log_-1] == '\n', ""); // Omit prefix of message and trailing newline when writing to message_. const char *start = data_->message_text_ + data_->num_prefix_chars_; int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1; data_->message_->assign(start, len); } SendToLog(); } // L >= log_mutex (callers must hold the log_mutex). void LogMessage::SendToSyslogAndLog() { #ifdef HAVE_SYSLOG_H // Before any calls to syslog(), make a single call to openlog() static bool openlog_already_called = false; if (!openlog_already_called) { openlog(glog_internal_namespace_::ProgramInvocationShortName(), LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER); openlog_already_called = true; } // This array maps Google severity levels to syslog levels const int SEVERITY_TO_LEVEL[] = { LOG_INFO, LOG_WARNING, LOG_ERR, LOG_EMERG }; syslog(LOG_USER | SEVERITY_TO_LEVEL[static_cast<int>(data_->severity_)], "%.*s", int(data_->num_chars_to_syslog_), data_->message_text_ + data_->num_prefix_chars_); SendToLog(); #else LOG(ERROR) << "No syslog support: message=" << data_->message_text_; #endif } base::Logger* base::GetLogger(LogSeverity severity) { MutexLock l(&log_mutex); return LogDestination::log_destination(severity)->logger_; } void base::SetLogger(LogSeverity severity, base::Logger* logger) { MutexLock l(&log_mutex); LogDestination::log_destination(severity)->logger_ = logger; } // L < log_mutex. Acquires and releases mutex_. int64 LogMessage::num_messages(int severity) { MutexLock l(&log_mutex); return num_messages_[severity]; } // Output the COUNTER value. This is only valid if ostream is a // LogStream. ostream& operator<<(ostream &os, const PRIVATE_Counter&) { LogMessage::LogStream *log = dynamic_cast<LogMessage::LogStream*>(&os); CHECK(log == log->self()); os << log->ctr(); return os; } ErrnoLogMessage::ErrnoLogMessage(const char* file, int line, LogSeverity severity, int ctr, void (LogMessage::*send_method)()) : LogMessage(file, line, severity, ctr, send_method) { } ErrnoLogMessage::~ErrnoLogMessage() { // Don't access errno directly because it may have been altered // while streaming the message. char buf[100]; posix_strerror_r(preserved_errno(), buf, sizeof(buf)); stream() << ": " << buf << " [" << preserved_errno() << "]"; } void FlushLogFiles(LogSeverity min_severity) { LogDestination::FlushLogFiles(min_severity); } void FlushLogFilesUnsafe(LogSeverity min_severity) { LogDestination::FlushLogFilesUnsafe(min_severity); } void SetLogDestination(LogSeverity severity, const char* base_filename) { LogDestination::SetLogDestination(severity, base_filename); } void SetLogSymlink(LogSeverity severity, const char* symlink_basename) { LogDestination::SetLogSymlink(severity, symlink_basename); } LogSink::~LogSink() { } void LogSink::WaitTillSent() { // noop default } string LogSink::ToString(LogSeverity severity, const char* file, int line, const struct ::tm* tm_time, const char* message, size_t message_len) { ostringstream stream(string(message, message_len)); stream.fill('0'); // FIXME(jrvb): Updating this to use the correct value for usecs // requires changing the signature for both this method and // LogSink::send(). This change needs to be done in a separate CL // so subclasses of LogSink can be updated at the same time. int usecs = 0; stream << LogSeverityNames[severity][0] << setw(2) << 1+tm_time->tm_mon << setw(2) << tm_time->tm_mday << ' ' << setw(2) << tm_time->tm_hour << ':' << setw(2) << tm_time->tm_min << ':' << setw(2) << tm_time->tm_sec << '.' << setw(6) << usecs << ' ' << setfill(' ') << setw(5) << GetTID() << setfill('0') << ' ' << file << ':' << line << "] "; stream << string(message, message_len); return stream.str(); } void AddLogSink(LogSink *destination) { LogDestination::AddLogSink(destination); } void RemoveLogSink(LogSink *destination) { LogDestination::RemoveLogSink(destination); } void SetLogFilenameExtension(const char* ext) { LogDestination::SetLogFilenameExtension(ext); } void SetStderrLogging(LogSeverity min_severity) { LogDestination::SetStderrLogging(min_severity); } void SetEmailLogging(LogSeverity min_severity, const char* addresses) { LogDestination::SetEmailLogging(min_severity, addresses); } void LogToStderr() { LogDestination::LogToStderr(); } namespace base { namespace internal { bool GetExitOnDFatal() { MutexLock l(&log_mutex); return exit_on_dfatal; } // Determines whether we exit the program for a LOG(DFATAL) message in // debug mode. It does this by skipping the call to Fail/FailQuietly. // This is intended for testing only. // // This can have some effects on LOG(FATAL) as well. Failure messages // are always allocated (rather than sharing a buffer), the crash // reason is not recorded, the "gwq" status message is not updated, // and the stack trace is not recorded. The LOG(FATAL) *will* still // exit the program. Since this function is used only in testing, // these differences are acceptable. void SetExitOnDFatal(bool value) { MutexLock l(&log_mutex); exit_on_dfatal = value; } } // namespace internal } // namespace base // use_logging controls whether the logging functions LOG/VLOG are used // to log errors. It should be set to false when the caller holds the // log_mutex. static bool SendEmailInternal(const char*dest, const char *subject, const char*body, bool use_logging) { if (dest && *dest) { if ( use_logging ) { VLOG(1) << "Trying to send TITLE:" << subject << " BODY:" << body << " to " << dest; } else { fprintf(stderr, "Trying to send TITLE: %s BODY: %s to %s\n", subject, body, dest); } string cmd = FLAGS_logmailer + " -s\"" + subject + "\" " + dest; FILE* pipe = popen(cmd.c_str(), "w"); if (pipe != NULL) { // Add the body if we have one if (body) fwrite(body, sizeof(char), strlen(body), pipe); bool ok = pclose(pipe) != -1; if ( !ok ) { if ( use_logging ) { char buf[100]; posix_strerror_r(errno, buf, sizeof(buf)); LOG(ERROR) << "Problems sending mail to " << dest << ": " << buf; } else { char buf[100]; posix_strerror_r(errno, buf, sizeof(buf)); fprintf(stderr, "Problems sending mail to %s: %s\n", dest, buf); } } return ok; } else { if ( use_logging ) { LOG(ERROR) << "Unable to send mail to " << dest; } else { fprintf(stderr, "Unable to send mail to %s\n", dest); } } } return false; } bool SendEmail(const char*dest, const char *subject, const char*body){ return SendEmailInternal(dest, subject, body, true); } static void GetTempDirectories(vector<string>* list) { list->clear(); #ifdef OS_WINDOWS // On windows we'll try to find a directory in this order: // C:/Documents & Settings/whomever/TEMP (or whatever GetTempPath() is) // C:/TMP/ // C:/TEMP/ // C:/WINDOWS/ or C:/WINNT/ // . char tmp[MAX_PATH]; if (GetTempPathA(MAX_PATH, tmp)) list->push_back(tmp); list->push_back("C:\\tmp\\"); list->push_back("C:\\temp\\"); #else // Directories, in order of preference. If we find a dir that // exists, we stop adding other less-preferred dirs const char * candidates[] = { // Non-null only during unittest/regtest getenv("TEST_TMPDIR"), // Explicitly-supplied temp dirs getenv("TMPDIR"), getenv("TMP"), // If all else fails "/tmp", }; for (int i = 0; i < ARRAYSIZE(candidates); i++) { const char *d = candidates[i]; if (!d) continue; // Empty env var // Make sure we don't surprise anyone who's expecting a '/' string dstr = d; if (dstr[dstr.size() - 1] != '/') { dstr += "/"; } list->push_back(dstr); struct stat statbuf; if (!stat(d, &statbuf) && S_ISDIR(statbuf.st_mode)) { // We found a dir that exists - we're done. return; } } #endif } static vector<string>* logging_directories_list; const vector<string>& GetLoggingDirectories() { // Not strictly thread-safe but we're called early in InitGoogle(). if (logging_directories_list == NULL) { logging_directories_list = new vector<string>; if ( !FLAGS_log_dir.empty() ) { // A dir was specified, we should use it logging_directories_list->push_back(FLAGS_log_dir.c_str()); } else { GetTempDirectories(logging_directories_list); #ifdef OS_WINDOWS char tmp[MAX_PATH]; if (GetWindowsDirectoryA(tmp, MAX_PATH)) logging_directories_list->push_back(tmp); logging_directories_list->push_back(".\\"); #else logging_directories_list->push_back("./"); #endif } } return *logging_directories_list; } void TestOnly_ClearLoggingDirectoriesList() { fprintf(stderr, "TestOnly_ClearLoggingDirectoriesList should only be " "called from test code.\n"); delete logging_directories_list; logging_directories_list = NULL; } void GetExistingTempDirectories(vector<string>* list) { GetTempDirectories(list); vector<string>::iterator i_dir = list->begin(); while( i_dir != list->end() ) { // zero arg to access means test for existence; no constant // defined on windows if ( access(i_dir->c_str(), 0) ) { i_dir = list->erase(i_dir); } else { ++i_dir; } } } void TruncateLogFile(const char *path, int64 limit, int64 keep) { #ifdef HAVE_UNISTD_H struct stat statbuf; const int kCopyBlockSize = 8 << 10; char copybuf[kCopyBlockSize]; int64 read_offset, write_offset; // Don't follow symlinks unless they're our own fd symlinks in /proc int flags = O_RDWR; const char *procfd_prefix = "/proc/self/fd/"; if (strncmp(procfd_prefix, path, strlen(procfd_prefix))) flags |= O_NOFOLLOW; int fd = open(path, flags); if (fd == -1) { if (errno == EFBIG) { // The log file in question has got too big for us to open. The // real fix for this would be to compile logging.cc (or probably // all of base/...) with -D_FILE_OFFSET_BITS=64 but that's // rather scary. // Instead just truncate the file to something we can manage if (truncate(path, 0) == -1) { PLOG(ERROR) << "Unable to truncate " << path; } else { LOG(ERROR) << "Truncated " << path << " due to EFBIG error"; } } else { PLOG(ERROR) << "Unable to open " << path; } return; } if (fstat(fd, &statbuf) == -1) { PLOG(ERROR) << "Unable to fstat()"; goto out_close_fd; } // See if the path refers to a regular file bigger than the // specified limit if (!S_ISREG(statbuf.st_mode)) goto out_close_fd; if (statbuf.st_size <= limit) goto out_close_fd; if (statbuf.st_size <= keep) goto out_close_fd; // This log file is too large - we need to truncate it LOG(INFO) << "Truncating " << path << " to " << keep << " bytes"; // Copy the last "keep" bytes of the file to the beginning of the file read_offset = statbuf.st_size - keep; write_offset = 0; int bytesin, bytesout; while ((bytesin = pread(fd, copybuf, sizeof(copybuf), read_offset)) > 0) { bytesout = pwrite(fd, copybuf, bytesin, write_offset); if (bytesout == -1) { PLOG(ERROR) << "Unable to write to " << path; break; } else if (bytesout != bytesin) { LOG(ERROR) << "Expected to write " << bytesin << ", wrote " << bytesout; } read_offset += bytesin; write_offset += bytesout; } if (bytesin == -1) PLOG(ERROR) << "Unable to read from " << path; // Truncate the remainder of the file. If someone else writes to the // end of the file after our last read() above, we lose their latest // data. Too bad ... if (ftruncate(fd, write_offset) == -1) { PLOG(ERROR) << "Unable to truncate " << path; } out_close_fd: close(fd); #else LOG(ERROR) << "No log truncation support."; #endif } void TruncateStdoutStderr() { #ifdef HAVE_UNISTD_H int64 limit = MaxLogSize() << 20; int64 keep = 1 << 20; TruncateLogFile("/proc/self/fd/1", limit, keep); TruncateLogFile("/proc/self/fd/2", limit, keep); #else LOG(ERROR) << "No log truncation support."; #endif } // Helper functions for string comparisons. #define DEFINE_CHECK_STROP_IMPL(name, func, expected) \ string* Check##func##expected##Impl(const char* s1, const char* s2, \ const char* names) { \ bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2)); \ if (equal == expected) return NULL; \ else { \ strstream ss; \ if (!s1) s1 = ""; \ if (!s2) s2 = ""; \ ss << #name " failed: " << names << " (" << s1 << " vs. " << s2 << ")"; \ return new string(ss.str(), ss.pcount()); \ } \ } DEFINE_CHECK_STROP_IMPL(CHECK_STREQ, strcmp, true) DEFINE_CHECK_STROP_IMPL(CHECK_STRNE, strcmp, false) DEFINE_CHECK_STROP_IMPL(CHECK_STRCASEEQ, strcasecmp, true) DEFINE_CHECK_STROP_IMPL(CHECK_STRCASENE, strcasecmp, false) #undef DEFINE_CHECK_STROP_IMPL int posix_strerror_r(int err, char *buf, size_t len) { // Sanity check input parameters if (buf == NULL || len <= 0) { errno = EINVAL; return -1; } // Reset buf and errno, and try calling whatever version of strerror_r() // is implemented by glibc buf[0] = '\000'; int old_errno = errno; errno = 0; char *rc = reinterpret_cast<char *>(strerror_r(err, buf, len)); // Both versions set errno on failure if (errno) { // Should already be there, but better safe than sorry buf[0] = '\000'; return -1; } errno = old_errno; // POSIX is vague about whether the string will be terminated, although // is indirectly implies that typically ERANGE will be returned, instead // of truncating the string. This is different from the GNU implementation. // We play it safe by always terminating the string explicitly. buf[len-1] = '\000'; // If the function succeeded, we can use its exit code to determine the // semantics implemented by glibc if (!rc) { return 0; } else { // GNU semantics detected if (rc == buf) { return 0; } else { buf[0] = '\000'; #if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) if (reinterpret_cast<intptr_t>(rc) < sys_nerr) { // This means an error on MacOSX or FreeBSD. return -1; } #endif strncat(buf, rc, len-1); return 0; } } } LogMessageFatal::LogMessageFatal(const char* file, int line) : LogMessage(file, line, FATAL) {} LogMessageFatal::LogMessageFatal(const char* file, int line, const CheckOpString& result) : LogMessage(file, line, result) {} LogMessageFatal::~LogMessageFatal() { Flush(); LogMessage::Fail(); } void InitGoogleLogging(const char* argv0) { glog_internal_namespace_::InitGoogleLoggingUtilities(argv0); } void ShutdownGoogleLogging() { glog_internal_namespace_::ShutdownGoogleLoggingUtilities(); LogDestination::DeleteLogDestinations(); delete logging_directories_list; logging_directories_list = NULL; } _END_GOOGLE_NAMESPACE_
62,881
20,980
// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved. // // 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. #ifndef ROCPRIM_DEVICE_DEVICE_MERGE_SORT_CONFIG_HPP_ #define ROCPRIM_DEVICE_DEVICE_MERGE_SORT_CONFIG_HPP_ #include <type_traits> #include "../config.hpp" #include "../detail/various.hpp" #include "config_types.hpp" /// \addtogroup primitivesmodule_deviceconfigs /// @{ BEGIN_ROCPRIM_NAMESPACE /// \brief Configuration of device-level merge primitives. /// /// \tparam BlockSize - block size used in merge sort. template<unsigned int BlockSize> using merge_sort_config = kernel_config<BlockSize, 1>; namespace detail { template<class Key, class Value> struct merge_sort_config_803 { static constexpr size_t key_value_size = sizeof(Key) + sizeof(Value); static constexpr unsigned int item_scale = ::rocprim::detail::ceiling_div<unsigned int>(key_value_size, 8); using type = merge_sort_config<::rocprim::max(256U, 1024U / item_scale)>; }; template<class Key> struct merge_sort_config_803<Key, empty_type> { static constexpr unsigned int item_scale = ::rocprim::detail::ceiling_div<unsigned int>(sizeof(Key), 8); using type = merge_sort_config<::rocprim::max(256U, 1024U / item_scale)>; }; template<class Key, class Value> struct merge_sort_config_900 { static constexpr size_t key_value_size = sizeof(Key) + sizeof(Value); static constexpr unsigned int item_scale = ::rocprim::detail::ceiling_div<unsigned int>(key_value_size, 16); using type = merge_sort_config<::rocprim::max(256U, 1024U / item_scale)>; }; template<class Key> struct merge_sort_config_900<Key, empty_type> { static constexpr unsigned int item_scale = ::rocprim::detail::ceiling_div<unsigned int>(sizeof(Key), 16); using type = merge_sort_config<::rocprim::max(256U, 1024U / item_scale)>; }; template<unsigned int TargetArch, class Key, class Value> struct default_merge_sort_config : select_arch< TargetArch, select_arch_case<803, merge_sort_config_803<Key, Value>>, select_arch_case<900, merge_sort_config_900<Key, Value>>, merge_sort_config_900<Key, Value> > { }; } // end namespace detail END_ROCPRIM_NAMESPACE /// @} // end of group primitivesmodule_deviceconfigs #endif // ROCPRIM_DEVICE_DEVICE_MERGE_SORT_CONFIG_HPP_
3,371
1,171
/** * @author Moe_Sakiya sakiya@tun.moe * @date 2018-03-01 00:07:15 * */ #include <iostream> #include <string> #include <algorithm> #include <set> #include <map> #include <vector> #include <stack> #include <queue> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> using namespace std; char arr[8][9]; int n, k, ans; bool vis[8]; void dfs(int nowRow, int nowCnt) { int i; if (nowCnt == k) { ans++; return; } if (nowRow == n) return; for (i = 0; i < n; i++) if (arr[nowRow][i] == '#' && vis[i] == false) { vis[i] = true; dfs(nowRow + 1, nowCnt + 1); vis[i] = false; } dfs(nowRow + 1, nowCnt); } int main(void) { ios::sync_with_stdio(false); while (~scanf("%d %d", &n, &k)) { if (n == -1 && k == -1) break; getchar(); //init ans = 0; for (int i = 0; i < n; i++) { gets(arr[i]); vis[i] = false; } dfs(0, 0); printf("%d\n", ans ); } return 0; }
934
474
#include <CGAL/Curves_on_surface_topology.h> #include <CGAL/Path_on_surface.h> #include <CGAL/Polygonal_schema.h> /////////////////////////////////////////////////////////////////////////////// [[ noreturn ]] void usage(int /*argc*/, char** argv) { std::cout<<"usage: "<<argv[0]<<" scheme [-nbdefo D] [-nbedges E] " <<" [-nbtests N] [-seed S] [-time]"<<std::endl <<" Load the given polygonal scheme (by default \"a b -a -b\")," << "compute one random path, deform it " <<"into a second path and test that the two paths are homotope." <<std::endl <<" -nbdefo D: use D deformations to generate the second path (by default a random number between 10 and 100)."<<std::endl <<" -nbedges E: generate paths of length E (by default a random number beween 10 and 100)."<<std::endl <<" -nbtests N: do N tests of homotopy (using 2*N random paths) (by default 1)."<<std::endl <<" -seed S: uses S as seed of random generator. Otherwise use a different seed at each run (based on time)."<<std::endl <<" -time: display computation times."<<std::endl <<std::endl; exit(EXIT_FAILURE); } /////////////////////////////////////////////////////////////////////////////// [[ noreturn ]] void error_command_line(int argc, char** argv, const char* msg) { std::cout<<"ERROR: "<<msg<<std::endl; usage(argc, argv); } /////////////////////////////////////////////////////////////////////////////// void process_command_line(int argc, char** argv, std::string& file, bool& withD, unsigned int& D, bool& withE, unsigned int& E, unsigned int& N, CGAL::Random& random, bool& time) { std::string arg; for (int i=1; i<argc; ++i) { arg=argv[i]; if (arg=="-nbdefo") { if (i==argc-1) { error_command_line(argc, argv, "Error: no number after -nbdefo option."); } withD=true; D=static_cast<unsigned int>(std::stoi(std::string(argv[++i]))); } else if (arg=="-nbedges") { if (i==argc-1) { error_command_line(argc, argv, "Error: no number after -nbedges option."); } withE=true; E=static_cast<unsigned int>(std::stoi(std::string(argv[++i]))); } else if (arg=="-nbtests") { if (i==argc-1) { error_command_line(argc, argv, "Error: no number after -nbtests option."); } N=static_cast<unsigned int>(std::stoi(std::string(argv[++i]))); } else if (arg=="-seed") { if (i==argc-1) { error_command_line(argc, argv, "Error: no number after -seed option."); } random=CGAL::Random(static_cast<unsigned int>(std::stoi(std::string(argv[++i])))); // initialize the random generator with the given seed } else if (arg=="-time") { time=true; } else if (arg=="-h" || arg=="--help" || arg=="-?") { usage(argc, argv); } else if (arg[0]=='-') { std::cout<<"Unknown option "<<arg<<", ignored."<<std::endl; } else { file=arg; } } if (N==0) { N=1; } } /////////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { using namespace CGAL::Surface_mesh_topology; std::string scheme="a b -a -b"; bool withD=false; unsigned int D=0; bool withE=false; unsigned int E=0; unsigned int N=1; CGAL::Random random; // Used when user do not provide its own seed. bool time=false; process_command_line(argc, argv, scheme, withD, D, withE, E, N, random, time); Polygonal_schema_with_combinatorial_map<> cm; cm.add_facet(scheme); std::cout<<"Initial map: "; cm.display_characteristics(std::cout) << ", valid=" << cm.is_valid() << std::endl; Curves_on_surface_topology<Polygonal_schema_with_combinatorial_map<> > smct(cm, time); smct.compute_minimal_quadrangulation(time); std::cout<<"Reduced map: "; smct.get_minimal_quadrangulation().display_characteristics(std::cout) << ", valid="<< smct.get_minimal_quadrangulation().is_valid() << std::endl; unsigned int nbcontractible=0; std::vector<std::size_t> errors_seeds; for (unsigned int i=0; i<N; ++i) { if (i!=0) { random=CGAL::Random(random.get_int(0, std::numeric_limits<int>::max())); } std::cout<<"Random seed: "<<random.get_seed()<<": "; if (!withE) { E=static_cast<unsigned int>(random.get_int (10, std::max(std::size_t(11), cm.number_of_darts()/10))); } if (!withD) { D=static_cast<unsigned int>(random.get_int (10, std::max(std::size_t(11), cm.number_of_darts()/10))); } Path_on_surface<Polygonal_schema_with_combinatorial_map<>> path1(cm); path1.generate_random_closed_path(E, random); std::cout<<"Path1 size: "<<path1.length()<<" (from "<<E<<" darts); "; Path_on_surface<Polygonal_schema_with_combinatorial_map<>> deformed_path1(path1); deformed_path1.update_path_randomly(D, random); std::cout<<"Path2 size: "<<deformed_path1.length()<<" (from "<<D<<" deformations)."; std::cout<<std::endl; if (smct.is_contractible(path1, time)) { ++nbcontractible; } bool res=smct.are_freely_homotopic(path1, deformed_path1, time); if (!res) { errors_seeds.push_back(random.get_seed()); } } if (errors_seeds.empty()) { if (N==1) { std::cout<<"Test OK: both paths are homotopic."<<std::endl; } else { std::cout<<"All the "<<N<<" tests OK: each pair of paths were homotopic."<<std::endl; } } else { std::cout<<"ERRORS for "<<errors_seeds.size()<<" tests among "<<N <<" (i.e. "<<(double)(errors_seeds.size()*100)/double(N)<<"%)."<<std::endl; std::cout<<"Errors for seeds: "; for (std::size_t i=0; i<errors_seeds.size(); ++i) { std::cout<<errors_seeds[i]<<" "; } std::cout<<std::endl; } std::cout<<"Number of contractible paths: "<<nbcontractible<<" among "<<N <<" (i.e. "<<(double)(nbcontractible*100)/double(N)<<"%)."<< std::endl << "==============" <<std::endl; return EXIT_SUCCESS; }
6,354
2,213
#define USE_FILE_IO #include <cstdio> #include <cstring> #include <climits> #include <algorithm> using namespace std; typedef long long i64; #define NMAX 200000 #define MOD 998244353 static int n; static int A[NMAX + 10], B[NMAX + 10]; static i64 fac[NMAX + 10]; static i64 inv[NMAX + 10]; inline i64 qpow(i64 a, i64 b) { i64 r = 1; for (; b; b >>= 1, a = a * a % MOD) { if (b & 1) r = r * a % MOD; } return r; } void initialize() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", A + i, B + i); } fac[0] = 1; for (int i = 1; i <= NMAX; i++) { fac[i] = fac[i - 1] * i % MOD; } inv[NMAX] = qpow(fac[NMAX], MOD - 2); for (int i = NMAX - 1; i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1) % MOD; } } int main() { #ifdef USE_FILE_IO freopen("gf.in", "r", stdin); freopen("gf.out", "w", stdout); #endif initialize(); i64 ans = 0; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { ans = fac[A[i] + A[j] + B[i] + B[j]] * inv[A[i] + A[j]] % MOD * inv[B[i] + B[j]] % MOD; ans %= MOD; } } printf("%lld\n", ans); return 0; }
1,274
601
/** * @file testPlanarSDFutils.cpp * @author Jing Dong * @date May 8 2016 **/ #include <CppUnitLite/TestHarness.h> #include <gtsam/base/numericalDerivative.h> #include <gtsam/base/Matrix.h> #include <gpmp2/obstacle/PlanarSDF.h> #include <iostream> using namespace std; using namespace gtsam; using namespace gpmp2; double sdf_wrapper(const PlanarSDF& field, const Point2& p) { return field.getSignedDistance(p); } /* ************************************************************************** */ TEST(PlanarSDFutils, test1) { // data Matrix data; data = (Matrix(5, 5) << 1.7321, 1.4142, 1.4142, 1.4142, 1.7321, 1.4142, 1, 1, 1, 1.4142, 1.4142, 1, 1, 1, 1.4142, 1.4142, 1, 1, 1, 1.4142, 1.7321, 1.4142, 1.4142, 1.4142, 1.7321).finished(); Point2 origin(-0.2, -0.2); double cell_size = 0.1; // constructor PlanarSDF field(origin, cell_size, data); EXPECT_LONGS_EQUAL(5, field.x_count()); EXPECT_LONGS_EQUAL(5, field.y_count()); EXPECT_DOUBLES_EQUAL(0.1, field.cell_size(), 1e-9); EXPECT(assert_equal(origin, field.origin())); // access PlanarSDF::float_index idx; idx = field.convertPoint2toCell(Point2(0, 0)); EXPECT_DOUBLES_EQUAL(2, idx.get<0>(), 1e-9); EXPECT_DOUBLES_EQUAL(2, idx.get<1>(), 1e-9); EXPECT_DOUBLES_EQUAL(1, field.signed_distance(idx), 1e-9) idx = field.convertPoint2toCell(Point2(0.18, -0.17)); // tri-linear interpolation EXPECT_DOUBLES_EQUAL(0.3, idx.get<0>(), 1e-9); EXPECT_DOUBLES_EQUAL(3.8, idx.get<1>(), 1e-9); EXPECT_DOUBLES_EQUAL(1.567372, field.signed_distance(idx), 1e-9) idx = boost::make_tuple(1.0, 2.0); EXPECT(assert_equal(Point2(0.0, -0.1), field.convertCelltoPoint2(idx))); // gradient Vector2 grad_act, grad_exp; Point2 p; p = Point2(-0.13, -0.14); field.getSignedDistance(p, grad_act); grad_exp = numericalDerivative11(std::function<double(const Point2&)>( boost::bind(sdf_wrapper, field, _1)), p, 1e-6); EXPECT(assert_equal(grad_exp, grad_act, 1e-6)); p = Point2(0.18, 0.12); field.getSignedDistance(p, grad_act); grad_exp = numericalDerivative11(std::function<double(const Point2&)>( boost::bind(sdf_wrapper, field, _1)), p, 1e-6); EXPECT(assert_equal(grad_exp, grad_act, 1e-6)); } /* ************************************************************************** */ /* main function */ int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
2,425
1,116
#include "rectangle.h" #include "main.h" Rectangle::Rectangle(float x, float y,float x1, float y1,float length, float width, color_t color) { this->position = glm::vec3(x, y, 0); const GLfloat vertex_buffer_data[] = { x1, y1, 0, // vertex 1 x1, y1+width, 0, // vertex 2 x1+length, y1+width, 0, // vertex 3 x1+length, y1+width, 0, // vertex 3 x1, y1, 0, // vertex 1 x1+length, y1, 0, // vertex 1 }; this->object = create3DObject(GL_TRIANGLES, 6, vertex_buffer_data, color, GL_FILL); } void Rectangle::draw(glm::mat4 VP) { Matrices.model = glm::mat4(1.0f); glm::mat4 translate = glm::translate (this->position); // glTranslatef glm::mat4 rotate = glm::rotate((float) (this->rotation * M_PI / 180.0f), glm::vec3(0, 0, 1)); rotate = rotate * glm::translate(glm::vec3(0, 0, 1)); Matrices.model *= (translate * rotate); glm::mat4 MVP = VP * Matrices.model; glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]); draw3DObject(this->object); } //void Rectangle::set_position(float x, float y) { // this->position = glm::vec3(x, y, 0); //}
1,168
481
/* behemoth: A syntax-guided synthesis library * Copyright (C) 2018 EPFL * * 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. */ #pragma once #include <behemoth/expr.hpp> #include <cassert> #include <fmt/format.h> #include <iostream> #include <queue> #include <algorithm> #include <map> #include <utility> namespace behemoth { struct rule_t { unsigned match; unsigned replace; unsigned cost = 1; }; using rules_t = std::vector<rule_t>; /* expression with associated cost */ using cexpr_t = std::pair<unsigned,unsigned>; struct expr_greater_than { expr_greater_than( context& ctx ) : _ctx( ctx ) {} bool operator()(const cexpr_t& a, const cexpr_t& b) const { /* higher costs means greater */ if ( a.second > b.second ) return true; if ( a.second < b.second ) return false; /* more non-terminals means greater */ if ( _ctx.count_nonterminals( a.first ) > _ctx.count_nonterminals( b.first ) ) return true; if ( _ctx.count_nonterminals( a.first ) < _ctx.count_nonterminals( b.first ) ) return false; /* more nodes means greater */ if ( _ctx.count_nodes( a.first ) > _ctx.count_nodes( b.first ) ) return true; if ( _ctx.count_nodes( a.first ) < _ctx.count_nodes( b.first ) ) return false; return false; } context& _ctx; }; // expr_greater_than struct path_t { path_t ( unsigned initial_depth = std::numeric_limits<unsigned>::max() ) : depth( initial_depth ) {} bool operator<( const path_t& other ) const { return ( depth < other.depth ); } std::string as_string() const { std::string s = "["; for ( auto i = 0u; i < indices.size(); ++i ) { s += fmt::format( "%s", indices[indices.size()-1u-i] ); } s += "] "; s += invalid() ? "∞" : ( fmt::format( "%d", depth ) ); return s; } inline unsigned operator[]( std::size_t i ) { return indices[indices.size()-1u-i]; } inline void push_front( unsigned v ) { indices.push_back( v ); } inline void pop_front() { indices.pop_back(); } inline void incr_depth() { ++depth; } inline bool invalid() const { return indices.empty() && depth == std::numeric_limits<unsigned>::max(); } inline bool valid() const { return !invalid(); } /* indices in reverse order */ std::vector<unsigned> indices; unsigned depth; }; // path_t std::vector<std::pair<unsigned,unsigned>> refine_expression_recurse( context& ctx, unsigned e, path_t path, const rules_t& rules ) { if ( path.indices.empty() ) { /* apply all rules */ std::vector<std::pair<unsigned,unsigned>> results; for ( const auto& r : rules ) { if ( e == r.match ) { results.emplace_back( r.replace, r.cost ); } } return results; } auto index = path[ 0u ]; path.pop_front(); auto candidates = refine_expression_recurse( ctx, ctx._exprs[ e ]._children[ index ], path, rules ); std::vector<std::pair<unsigned,unsigned>> results; for ( const auto& c : candidates ) { std::vector<unsigned> new_children; /* copy the children before index */ for ( auto i = 0u; i < index; ++i ) { new_children.push_back( ctx._exprs[ e ]._children[ i ] ); } /* add new instantiation */ new_children.push_back( c.first ); /* copy the children after index */ for ( auto i = index+1; i < ctx._exprs[ e ]._children.size(); ++i ) { new_children.push_back( ctx._exprs[ e ]._children[ i ] ); } results.emplace_back( ctx.make_fun( ctx._exprs[ e ]._name, new_children, ctx._exprs[ e ]._attr ), c.second ); } return results; } path_t get_path_to_concretizable_element( context& ctx, unsigned e ) { /* non-terminal */ if ( ctx._exprs[ e ]._name[0] == '_' ) { return path_t( 0u ); } /* variable or constant */ if ( ctx._exprs[ e ]._children.empty() ) { return path_t( std::numeric_limits<unsigned>::max() ); } /* others */ path_t min_path; min_path.depth = std::numeric_limits<unsigned>::max(); for ( auto i = 0u; i < ctx._exprs[e]._children.size(); ++i ) { auto path = get_path_to_concretizable_element( ctx, ctx._exprs[e]._children[ i ] ); if ( path < min_path ) { auto new_path = path; new_path.push_front( i ); min_path = new_path; } } if ( min_path < std::numeric_limits<unsigned>::max() ) { min_path.incr_depth(); } return min_path; } bool is_concrete( context& ctx, unsigned e ) { return get_path_to_concretizable_element( ctx, e ).invalid(); } class enumerator { public: using expr_queue_t = std::priority_queue<cexpr_t, std::vector<cexpr_t>, expr_greater_than>; public: enumerator( context& ctx, rules_t rules, int max_cost ) : ctx( ctx ) , rules(std::move( rules )) , max_cost( max_cost ) , candidate_expressions( ctx ) /* pass ctx to the expr_greater_than */ {} virtual ~enumerator() = default; void add_expression( unsigned e ); void deduce( unsigned number_of_steps = 1u ); virtual bool is_redundant_in_search_order( unsigned e ) const; bool check_double_application( unsigned e ) const; bool check_idempotence_and_commutative( unsigned e ) const; bool check_idempotence( unsigned e ) const; bool check_commutativity( unsigned e ) const; virtual void on_expression( cexpr_t e ) { (void)e; } virtual void on_concrete_expression( cexpr_t e ) { (void)e; } virtual void on_abstract_expression( cexpr_t e ) { candidate_expressions.push( e ); } void signal_termination() { quit_enumeration = true; } bool is_running() const { return !quit_enumeration; } protected: context& ctx; bool quit_enumeration = false; rules_t rules; unsigned max_cost; expr_queue_t candidate_expressions; unsigned current_costs = 0u; }; void enumerator::add_expression( unsigned e ) { candidate_expressions.push( { e, 0u } ); } void enumerator::deduce( unsigned number_of_steps ) { for ( auto i = 0u; i < number_of_steps; ++i ) { if ( candidate_expressions.empty() ) { quit_enumeration = true; } if ( !is_running() ) { return; } auto next_candidate = candidate_expressions.top(); candidate_expressions.pop(); if ( next_candidate.second > current_costs ) { std::cout << "[i] finished considering expressions of cost " << (current_costs+1u) << std::endl; current_costs = next_candidate.second; } if ( next_candidate.second >= max_cost ) { quit_enumeration = true; continue; } auto p = get_path_to_concretizable_element( ctx, next_candidate.first ); auto new_candidates = refine_expression_recurse( ctx, next_candidate.first, p, rules ); for ( const auto& c : new_candidates ) { if ( !is_running() ) break; if ( is_redundant_in_search_order( c.first ) ) continue; auto cc = cexpr_t{ c.first, next_candidate.second + c.second }; on_expression( cc ); if ( is_concrete( ctx, c.first ) ) { on_concrete_expression(cc); } else { on_abstract_expression(cc); } } } } bool enumerator::check_double_application( unsigned e ) const { const auto expr = ctx._exprs[ e ]; /* no double-negation */ if ( expr._name[0] != '_' && (expr._attr & expr_attr_enum::_no_double_application) == expr_attr_enum::_no_double_application ) { assert( expr._children.size() == 1u ); const auto child0 = ctx._exprs[ expr._children[0u] ]; if ( child0._name == expr._name && child0._attr == expr_attr_enum::_no_double_application ) { return true; } } for ( const auto& c : expr._children ) { if ( check_double_application( c ) ) { return true; } } return false; } void get_leaves_of_same_op_impl( context& ctx, unsigned e, const std::string& op, std::vector<unsigned>& leaves ) { const auto expr = ctx._exprs[e]; for ( const auto& c : expr._children ) { if ( ctx._exprs[c]._children.empty() && ctx._exprs[c]._name[0] != '_' ) { leaves.emplace_back( c ); } if ( ctx._exprs[c]._name == op ) { get_leaves_of_same_op_impl( ctx, c, op, leaves ); } } } // this function gets all the leaves of the chains of the same operation std::vector<unsigned> get_leaves_of_same_op( context& ctx, unsigned e ) { std::vector<unsigned> leaves; const auto expr = ctx._exprs[e]; for ( const auto& c : expr._children ) { if ( ctx._exprs[c]._children.empty() && ctx._exprs[c]._name[0] != '_' ) { leaves.emplace_back( c ); } if ( ctx._exprs[c]._name == expr._name ) { get_leaves_of_same_op_impl( ctx, c, expr._name, leaves ); } } return leaves; } bool enumerator::check_idempotence( unsigned e ) const { // get all chains of same op starting from e auto leaves = get_leaves_of_same_op( ctx, e ); // check for equal elements if ( leaves.size() < 2 ) { return false; } std::map<unsigned, unsigned> dup; std::for_each( leaves.begin(), leaves.end(), [&dup]( unsigned val ) { dup[val]++; } ); auto result = std::find_if( dup.begin(), dup.end(), []( std::pair<const unsigned int, unsigned int> val ) { return val.second > 1; } ); return result != dup.end(); } bool enumerator::check_commutativity( unsigned e ) const { // get all chains of same op starting from e auto leaves = get_leaves_of_same_op( ctx, e ); // check ordering of elements if ( leaves.size() < 2 ) { return false; } if ( !std::is_sorted( leaves.begin(), leaves.end() ) ) { return true; } return false; } bool enumerator::check_idempotence_and_commutative( unsigned e ) const { const auto is_set = []( unsigned value, unsigned flag ) { return ( ( value & flag ) == flag ); }; const auto expr = ctx._exprs[ e ]; if ( expr._name[0] != '_' && expr._children.size() == 2u && (ctx.count_nonterminals( expr._children[0u] ) == 0) && (ctx.count_nonterminals( expr._children[1u] ) == 0) ) { if ( is_set( expr._attr, expr_attr_enum::_idempotent | expr_attr_enum::_commutative ) && expr._children[0u] >= expr._children[1u] ) { return true; } else if ( is_set( expr._attr, expr_attr_enum::_commutative ) && expr._children[0u] > expr._children[1u] ) { return true; } else if ( is_set( expr._attr, expr_attr_enum::_idempotent ) && expr._children[0u] == expr._children[1u] ) { return true; } } if ( expr._name[0] != '_' && expr._children.size() == 2u && is_set( expr._attr, expr_attr_enum::_idempotent ) ) { if ( check_idempotence( e ) ) { return true; } } if ( expr._name[0] != '_' && expr._children.size() == 2u && is_set( expr._attr, expr_attr_enum::_commutative ) ) { if ( check_commutativity( e ) ) { return true; } } for ( const auto& c : expr._children ) { if ( check_idempotence_and_commutative( c ) ) { return true; } } return false; } bool enumerator::is_redundant_in_search_order( unsigned e ) const { if ( check_double_application( e ) ) { return true; } if ( check_idempotence_and_commutative( e ) ) { return true; } /* keep all other expressions */ return false; } } // namespace behemoth // Local Variables: // c-basic-offset: 2 // eval: (c-set-offset 'substatement-open 0) // eval: (c-set-offset 'innamespace 0) // End:
12,464
4,478
/** * File: HVocabulary.cpp * Date: April 2010 * Author: Dorian Galvez * Description: hierarchical vocabulary implementing (Nister, 2006) */ #include "HVocabulary.h" #include "HVocParams.h" #include "DUtils.h" #include <cassert> #include <algorithm> #include <numeric> #include <vector> #include <cmath> #include <fstream> using namespace std; using namespace DBow; // Use Kmeans++ // (no other method supported currently) #define KMEANS_PLUS_PLUS HVocabulary::HVocabulary(const HVocParams &params): Vocabulary(params), m_params(params) { assert(params.k > 1 && params.L > 0); } HVocabulary::HVocabulary(const char *filename) : Vocabulary(HVocParams(0,0)), m_params(HVocParams(0,0)) { Load(filename); } HVocabulary::HVocabulary(const HVocabulary &voc) : Vocabulary(voc), m_params(voc.m_params) { m_nodes = voc.m_nodes; m_words.clear(); m_words.resize(voc.m_words.size()); vector<Node*>::const_iterator it; for(it = voc.m_words.begin(); it != voc.m_words.end(); it++){ const Node *p = *it; m_words[it - voc.m_words.begin()] = &m_nodes[p->Id]; } } HVocabulary::~HVocabulary(void) { } void HVocabulary::Create(const vector<vector<float> >& training_features) { // expected_nodes = Sum_{i=0..L} ( k^i ) int expected_nodes = (int)((pow((double)m_params.k, (double)m_params.L + 1) - 1)/(m_params.k - 1)); // remove previous tree, allocate memory and insert root node m_nodes.resize(0); m_nodes.reserve(expected_nodes); // prevents allocations when creating the tree m_nodes.push_back(Node(0)); // root // prepare data int nfeatures = 0; for(unsigned int i = 0; i < training_features.size(); i++){ assert(training_features[i].size() % m_params.DescriptorLength == 0); nfeatures += training_features[i].size() / m_params.DescriptorLength; } vector<pFeature> pfeatures; pfeatures.reserve(nfeatures); vector<vector<float> >::const_iterator it; vector<float>::const_iterator jt; for(it = training_features.begin(); it != training_features.end(); it++){ for(jt = it->begin(); jt < it->end(); jt += m_params.DescriptorLength){ pfeatures.push_back( jt ); } } vector<float> buffer; buffer.reserve( m_params.k * m_params.DescriptorLength ); // start hierarchical kmeans HKMeansStep(0, pfeatures, 1, buffer); // create word nodes CreateWords(); // set the flag m_created = true; // set node weigths SetNodeWeights(training_features); } void HVocabulary::HKMeansStep(NodeId parentId, const vector<pFeature> &pfeatures, int level, vector<float>& clusters) { if(pfeatures.empty()) return; // features associated to each cluster vector<vector<unsigned int> > groups; // indices from pfeatures groups.reserve(m_params.k); // number of final clusters int nclusters = 0; if((int)pfeatures.size() <= m_params.k){ // trivial case: if there is a few features, each feature is a cluster nclusters = pfeatures.size(); clusters.resize(pfeatures.size() * m_params.DescriptorLength); groups.resize(pfeatures.size()); for(unsigned int i = 0; i < pfeatures.size(); i++){ copy(pfeatures[i], pfeatures[i] + m_params.DescriptorLength, clusters.begin() + i * m_params.DescriptorLength); groups[i].push_back(i); } }else{ // choose clusters with kmeans++ bool first_time = true; bool goon = true; vector<pFeature>::const_iterator fit; // to check if clusters move after iterations vector<int> last_association, current_association; while(goon){ // 1. Calculate clusters if(first_time){ // random sample #ifdef KMEANS_PLUS_PLUS RandomClustersPlusPlus(clusters, pfeatures); #else #error No initial clustering method #endif nclusters = clusters.size() / m_params.DescriptorLength; }else{ // calculate cluster centres vector<float>::iterator pfirst, pend, cit; vector<unsigned int>::const_iterator vit; for(int i = 0; i < nclusters; i++){ pfirst = clusters.begin() + i * m_params.DescriptorLength; pend = clusters.begin() + (i+1) * m_params.DescriptorLength; fill(pfirst, pend, 0.f); for(vit = groups[i].begin(); vit != groups[i].end(); vit++){ fit = pfeatures.begin() + *vit; // Possible improvement: divide this into chunks of 4 operations for(cit = pfirst; cit != pend; cit++){ *cit += *((*fit) + (cit - pfirst)); } } for(cit = pfirst; cit != pend; cit++) *cit /= groups[i].size(); } } // if(first_time) // 2. Associate features with clusters // calculate distances to cluster centers groups.clear(); groups.resize(nclusters, vector<unsigned int>()); current_association.resize(pfeatures.size()); for(fit = pfeatures.begin(); fit != pfeatures.end(); fit++){ double best_sqd = DescriptorSqDistance(*fit, clusters.begin()); int icluster = 0; for(int i = 1; i < nclusters; i++){ double sqd = DescriptorSqDistance(*fit, clusters.begin() + i * m_params.DescriptorLength); if(sqd < best_sqd){ best_sqd = sqd; icluster = i; } } groups[icluster].push_back(fit - pfeatures.begin()); current_association[ fit - pfeatures.begin() ] = icluster; } // remove clusters with no features // (this is not necessary with kmeans++) #ifndef KMEANS_PLUS_PLUS for(int i = nclusters-1; i >= 0; i--){ if(groups[i].empty()){ groups.erase(groups.begin() + i); clusters.erase(clusters.begin() + i * m_params.DescriptorLength, clusters.begin() + (i+1) * m_params.DescriptorLength); } } nclusters = groups.size(); #endif // 3. check convergence if(first_time){ first_time = false; }else{ goon = false; for(unsigned int i = 0; i < current_association.size(); i++){ if(current_association[i] != last_association[i]){ goon = true; break; } } } if(goon){ // copy last feature-cluster association last_association = current_association; } } // while(goon) } // if trivial case // Kmeans done, create nodes // create child nodes for(int i = 0; i < nclusters; i++){ NodeId id = m_nodes.size(); m_nodes.push_back(Node(id)); m_nodes.back().Descriptor.resize(m_params.DescriptorLength); copy(clusters.begin() + i * m_params.DescriptorLength, clusters.begin() + (i+1) * m_params.DescriptorLength, m_nodes.back().Descriptor.begin()); m_nodes[parentId].Children.push_back(id); } if(level < m_params.L){ // iterate again with the resulting clusters for(int i = 0; i < nclusters; i++){ NodeId id = m_nodes[m_nodes[parentId].Children[i]].Id; vector<pFeature> child_features; child_features.reserve(groups[i].size()); vector<unsigned int>::const_iterator vit; for(vit = groups[i].begin(); vit != groups[i].end(); vit++){ child_features.push_back(pfeatures[*vit]); } if(child_features.size() > 1){ // (clusters variable can be safely reused now) HKMeansStep(id, child_features, level + 1, clusters); } } } } int HVocabulary::GetNumberOfWords() const { return m_words.size(); } void HVocabulary::SaveBinary(const char *filename) const { // Format (binary): // [Header] // k L N // NodeId_1 ParentId Weight d1 ... d_D // ... // NodeId_(N-1) ParentId Weight d1 ... d_D // WordId_0 frequency NodeId // ... // WordId_(N-1) frequency NodeId // // Where: // k (int32): branching factor // L (int32): depth levels // N (int32): number of nodes, including root // NodeId (int32): root node is not present. Not in order // ParentId (int32) // Weight (double64) // d_i (float32): descriptor entry // WordId (int32): in ascending order // frequency (float32): frequency of word // NodeId (int32): node associated to word // // (the number along with the data type represents the size in bits) DUtils::BinaryFile f(filename, DUtils::WRITE); const int N = m_nodes.size(); // header SaveBinaryHeader(f); f << m_params.k << m_params.L << N; // tree vector<NodeId> parents, children; vector<NodeId>::const_iterator pit; parents.push_back(0); // root while(!parents.empty()){ NodeId pid = parents.back(); parents.pop_back(); const Node& parent = m_nodes[pid]; children = parent.Children; for(pit = children.begin(); pit != children.end(); pit++){ const Node& child = m_nodes[*pit]; // save node data f << (int)child.Id << (int)pid << (double)child.Weight; for(int i = 0; i < m_params.DescriptorLength; i++){ f << child.Descriptor[i]; } // add to parent list if(!child.isLeaf()){ parents.push_back(*pit); } } } // vocabulary vector<Node*>::const_iterator wit; for(wit = m_words.begin(); wit != m_words.end(); wit++){ WordId id = wit - m_words.begin(); f << (int)id << GetWordFrequency(id) << (int)(*wit)->Id; } f.Close(); } void HVocabulary::SaveText(const char *filename) const { // Format (text) // [Header] // k L N // NodeId_1 ParentId Weight d1 ... d_D // ... // NodeId_(N-1) ParentId Weight d1 ... d_D // WordId_0 frequency NodeId // ... // WordId_(N-1) frequency NodeId fstream f(filename, ios::out); if(!f.is_open()) throw DUtils::DException("Cannot open file"); // magic word is not necessary in the text file f.precision(10); const int N = m_nodes.size(); // header SaveTextHeader(f); f << m_params.k << " " << m_params.L << " " << N << endl; // tree vector<NodeId> parents, children; vector<NodeId>::const_iterator pit; parents.push_back(0); // root while(!parents.empty()){ NodeId pid = parents.back(); parents.pop_back(); const Node& parent = m_nodes[pid]; children = parent.Children; for(pit = children.begin(); pit != children.end(); pit++){ const Node& child = m_nodes[*pit]; // save node data f << child.Id << " " << pid << " " << child.Weight << " "; for(int i = 0; i < m_params.DescriptorLength; i++){ f << child.Descriptor[i] << " "; } f << endl; // add to parent list if(!child.isLeaf()){ parents.push_back(*pit); } } } // vocabulary vector<Node*>::const_iterator wit; for(wit = m_words.begin(); wit != m_words.end(); wit++){ WordId id = wit - m_words.begin(); f << (int)id << " " << GetWordFrequency(id) << " " << (int)(*wit)->Id << endl; } f.close(); } unsigned int HVocabulary::LoadBinary(const char *filename) { // Format (binary): // [Header] // k L N // NodeId_1 ParentId Weight d1 ... d_D // ... // NodeId_(N-1) ParentId Weight d1 ... d_D // WordId_0 frequency NodeId // ... // WordId_(N-1) frequency NodeId DUtils::BinaryFile f(filename, DUtils::READ); int nwords = LoadBinaryHeader(f); _load<DUtils::BinaryFile>(f, nwords); unsigned int ret = f.BytesRead(); f.Close(); return ret; } unsigned int HVocabulary::LoadText(const char *filename) { // Format (text) // [Header] // k L N // NodeId_1 ParentId Weight d1 ... d_D // ... // NodeId_(N-1) ParentId Weight d1 ... d_D // WordId_0 frequency NodeId // ... // WordId_(N-1) frequency NodeId fstream f(filename, ios::in); if(!f.is_open()) throw DUtils::DException("Cannot open file"); int nwords = LoadTextHeader(f); _load<fstream>(f, nwords); unsigned int ret = (unsigned int)f.tellg(); f.close(); return ret; } template<class T> void HVocabulary::_load(T &f, int nwords) { // general header has already been read, // giving value to these member variables int nfreq = m_frequent_words_stopped; int ninfreq = m_infrequent_words_stopped; // removes nodes, words and frequencies m_created = false; m_words.clear(); m_nodes.clear(); m_word_frequency.clear(); // h header int nnodes; f >> m_params.k >> m_params.L >> nnodes; // creates all the nodes at a time m_nodes.resize(nnodes); m_nodes[0].Id = 0; // root node for(int i = 1; i < nnodes; i++){ int nodeid, parentid; double weight; f >> nodeid >> parentid >> weight; m_nodes[nodeid].Id = nodeid; m_nodes[nodeid].Weight = weight; m_nodes[parentid].Children.push_back(nodeid); m_nodes[nodeid].Descriptor.resize(m_params.DescriptorLength); for(int j = 0; j < m_params.DescriptorLength; j++){ f >> m_nodes[nodeid].Descriptor[j]; } } m_words.resize(nwords); m_word_frequency.resize(nwords); for(int i = 0; i < nwords; i++){ int wordid, nodeid; float frequency; f >> wordid >> frequency >> nodeid; m_nodes[nodeid].WId = wordid; m_words[wordid] = &m_nodes[nodeid]; m_word_frequency[wordid] = frequency; } // all was ok m_created = true; // create an empty stop list CreateStopList(); // and stop words StopWords(nfreq, ninfreq); } void HVocabulary::RandomClustersPlusPlus(vector<float>& clusters, const vector<pFeature> &pfeatures) const { // Implements kmeans++ seeding algorithm // Algorithm: // 1. Choose one center uniformly at random from among the data points. // 2. For each data point x, compute D(x), the distance between x and the nearest // center that has already been chosen. // 3. Add one new data point as a center. Each point x is chosen with probability // proportional to D(x)^2. // 4. Repeat Steps 2 and 3 until k centers have been chosen. // 5. Now that the initial centers have been chosen, proceed using standard k-means // clustering. clusters.resize(m_params.k * m_params.DescriptorLength); vector<bool> feature_used(pfeatures.size(), false); // 1. int ifeature = DUtils::Random::RandomInt(0, pfeatures.size()-1); feature_used[ifeature] = true; // create first cluster copy(pfeatures[ifeature], pfeatures[ifeature] + m_params.DescriptorLength, clusters.begin()); int used_clusters = 1; vector<double> sqdistances; vector<int> ifeatures; sqdistances.reserve(pfeatures.size()); ifeatures.reserve(pfeatures.size()); vector<pFeature>::const_iterator fit; while(used_clusters < m_params.k){ // 2. sqdistances.resize(0); ifeatures.resize(0); for(fit = pfeatures.begin(); fit != pfeatures.end(); fit++){ ifeature = fit - pfeatures.begin(); if(!feature_used[ifeature]){ double min_sqd = DescriptorSqDistance(*fit, clusters.begin()); for(int i = 1; i < used_clusters; i++){ double sqd = DescriptorSqDistance(*fit, clusters.begin() + i * m_params.DescriptorLength); if(sqd < min_sqd){ min_sqd = sqd; } } sqdistances.push_back(min_sqd); ifeatures.push_back(ifeature); } } // 3. double sqd_sum = accumulate(sqdistances.begin(), sqdistances.end(), 0.0); if(sqd_sum > 0){ double cut_d; do{ cut_d = DUtils::Random::RandomValue<double>(0, sqd_sum); }while(cut_d == 0.0); double d_up_now = 0; vector<double>::iterator dit; for(dit = sqdistances.begin(); dit != sqdistances.end(); dit++){ d_up_now += *dit; if(d_up_now >= cut_d) break; } if(dit == sqdistances.end()) dit = sqdistances.begin() + sqdistances.size()-1; ifeature = ifeatures[dit - sqdistances.begin()]; assert(!feature_used[ifeature]); copy(pfeatures[ifeature], pfeatures[ifeature] + m_params.DescriptorLength, clusters.begin() + used_clusters * m_params.DescriptorLength); feature_used[ifeature] = true; used_clusters++; }else break; } if(used_clusters < m_params.k) clusters.resize(used_clusters * m_params.DescriptorLength); } double HVocabulary::DescriptorSqDistance(const pFeature &v, const pFeature &w) const { double sqd = 0.0; const int rest = m_params.DescriptorLength % 4; for(int i = 0; i < m_params.DescriptorLength - rest; i += 4){ sqd += (*(v + i) - *(w + i)) * (*(v + i) - *(w + i)); sqd += (*(v + i + 1) - *(w + i + 1)) * (*(v + i + 1) - *(w + i + 1)); sqd += (*(v + i + 2) - *(w + i + 2)) * (*(v + i + 2) - *(w + i + 2)); sqd += (*(v + i + 3) - *(w + i + 3)) * (*(v + i + 3) - *(w + i + 3)); } for(int i = m_params.DescriptorLength - rest; i < m_params.DescriptorLength; i++){ sqd += (*(v + i) - *(w + i)) * (*(v + i) - *(w + i)); } return sqd; } void HVocabulary::SetNodeWeights(const vector<vector<float> >& training_features) { vector<WordValue> weights; GetWordWeightsAndCreateStopList(training_features, weights); assert(weights.size() == m_words.size()); for(unsigned int i = 0; i < m_words.size(); i++){ m_words[i]->Weight = weights[i]; } } WordId HVocabulary::Transform(const vector<float>::const_iterator &pfeature) const { if(isEmpty()) return 0; assert(!m_nodes[0].isLeaf()); // propagate the feature down the tree vector<NodeId> nodes; vector<NodeId>::const_iterator it; NodeId final_id = 0; // root do{ nodes = m_nodes[final_id].Children; final_id = nodes[0]; double best_sqd = DescriptorSqDistance(pfeature, m_nodes[final_id].Descriptor.begin()); for(it = nodes.begin() + 1; it != nodes.end(); it++){ NodeId id = *it; double sqd = DescriptorSqDistance(pfeature, m_nodes[id].Descriptor.begin()); if(sqd < best_sqd){ best_sqd = sqd; final_id = id; } } } while( !m_nodes[final_id].isLeaf() ); // turn node id into word id return m_nodes[final_id].WId; } void HVocabulary::CreateWords() { m_words.resize(0); m_words.reserve( (int)pow((double)m_params.k, (double)m_params.L) ); // the actual order of the words is not important vector<Node>::iterator it; for(it = m_nodes.begin(); it != m_nodes.end(); it++){ if(it->isLeaf()){ it->WId = m_words.size(); m_words.push_back( &(*it) ); } } } WordValue HVocabulary::GetWordWeight(WordId id) const { if(isEmpty()) return 0; assert(id < m_words.size()); return m_words[id]->Weight; }
18,187
7,608
/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Assistant of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QtCore/QFile> #include "qhpwriter.h" #include "adpreader.h" QT_BEGIN_NAMESPACE QhpWriter::QhpWriter(const QString &namespaceName, const QString &virtualFolder) { m_namespaceName = namespaceName; m_virtualFolder = virtualFolder; setAutoFormatting(true); } void QhpWriter::setAdpReader(AdpReader *reader) { m_adpReader = reader; } void QhpWriter::setFilterAttributes(const QStringList &attributes) { m_filterAttributes = attributes; } void QhpWriter::setCustomFilters(const QList<CustomFilter> filters) { m_customFilters = filters; } void QhpWriter::setFiles(const QStringList &files) { m_files = files; } void QhpWriter::generateIdentifiers(IdentifierPrefix prefix, const QString prefixString) { m_prefix = prefix; m_prefixString = prefixString; } bool QhpWriter::writeFile(const QString &fileName) { QFile out(fileName); if (!out.open(QIODevice::WriteOnly)) return false; setDevice(&out); writeStartDocument(); writeStartElement(QLatin1String("QtHelpProject")); writeAttribute(QLatin1String("version"), QLatin1String("1.0")); writeTextElement(QLatin1String("namespace"), m_namespaceName); writeTextElement(QLatin1String("virtualFolder"), m_virtualFolder); writeCustomFilters(); writeFilterSection(); writeEndDocument(); out.close(); return true; } void QhpWriter::writeCustomFilters() { if (!m_customFilters.count()) return; for (const CustomFilter &f : qAsConst(m_customFilters)) { writeStartElement(QLatin1String("customFilter")); writeAttribute(QLatin1String("name"), f.name); for (const QString &a : f.filterAttributes) writeTextElement(QLatin1String("filterAttribute"), a); writeEndElement(); } } void QhpWriter::writeFilterSection() { writeStartElement(QLatin1String("filterSection")); for (const QString &a : qAsConst(m_filterAttributes)) writeTextElement(QLatin1String("filterAttribute"), a); writeToc(); writeKeywords(); writeFiles(); writeEndElement(); } void QhpWriter::writeToc() { const QList<ContentItem> &list = m_adpReader->contents(); if (list.isEmpty()) return; int depth = -1; writeStartElement(QLatin1String("toc")); for (const ContentItem &i : list) { while (depth-- >= i.depth) writeEndElement(); writeStartElement(QLatin1String("section")); writeAttribute(QLatin1String("title"), i.title); writeAttribute(QLatin1String("ref"), i.reference); depth = i.depth; } while (depth-- >= -1) writeEndElement(); } void QhpWriter::writeKeywords() { const QList<KeywordItem> &list = m_adpReader->keywords(); if (list.isEmpty()) return; writeStartElement(QLatin1String("keywords")); for (const KeywordItem &i : list) { writeEmptyElement(QLatin1String("keyword")); writeAttribute(QLatin1String("name"), i.keyword); writeAttribute(QLatin1String("ref"), i.reference); if (m_prefix == FilePrefix) { QString str = i.reference.mid( i.reference.lastIndexOf(QLatin1Char('/')) + 1); str = str.left(str.lastIndexOf(QLatin1Char('.'))); writeAttribute(QLatin1String("id"), str + QLatin1String("::") + i.keyword); } else if (m_prefix == GlobalPrefix) { writeAttribute(QLatin1String("id"), m_prefixString + i.keyword); } } writeEndElement(); } void QhpWriter::writeFiles() { if (m_files.isEmpty()) return; writeStartElement(QLatin1String("files")); for (const QString &f : qAsConst(m_files)) writeTextElement(QLatin1String("file"), f); writeEndElement(); } QT_END_NAMESPACE
5,096
1,512
/* * Copyright (c) 2013, Willow Garage, Inc. * 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 the Willow Garage, Inc. 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. */ #include <sstream> #ifndef _WIN32 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-parameter" # pragma GCC diagnostic ignored "-Wpedantic" #else #pragma warning(push) #pragma warning(disable : 4996) #endif #include <OgreCamera.h> #include <OgreRay.h> #include <OgreVector3.h> #include <OgreViewport.h> #ifndef _WIN32 # pragma GCC diagnostic pop #else # pragma warning(pop) #endif #include "rviz_common/display_context.hpp" #include "rviz_common/interaction/view_picker_iface.hpp" #include "rviz_common/load_resource.hpp" #include "rviz_common/render_panel.hpp" #include "rviz_common/viewport_mouse_event.hpp" #include "rviz_common/view_controller.hpp" #include "rviz_rendering/render_window.hpp" #include "rviz_default_plugins/tools/focus/focus_tool.hpp" namespace rviz_default_plugins { namespace tools { FocusTool::FocusTool() : Tool() { shortcut_key_ = 'c'; } FocusTool::~FocusTool() = default; void FocusTool::onInitialize() { std_cursor_ = rviz_common::getDefaultCursor(); hit_cursor_ = rviz_common::makeIconCursor("package://rviz_common/icons/crosshair.svg"); } void FocusTool::activate() {} void FocusTool::deactivate() {} int FocusTool::processMouseEvent(rviz_common::ViewportMouseEvent & event) { int flags = 0; Ogre::Vector3 position; bool success = context_->getViewPicker()->get3DPoint(event.panel, event.x, event.y, position); setCursor(success ? hit_cursor_ : std_cursor_); if (!success) { computePositionForDirection(event, position); setStatus("<b>Left-Click:</b> Look in this direction."); } else { setStatusFrom(position); } if (event.leftUp()) { if (event.panel->getViewController()) { event.panel->getViewController()->lookAt(position); } flags |= Finished; } return flags; } void FocusTool::setStatusFrom(const Ogre::Vector3 & position) { std::ostringstream s; s << "<b>Left-Click:</b> Focus on this point."; s.precision(3); s << " [" << position.x << "," << position.y << "," << position.z << "]"; setStatus(s.str().c_str()); } void FocusTool::computePositionForDirection( const rviz_common::ViewportMouseEvent & event, Ogre::Vector3 & position) { auto viewport = rviz_rendering::RenderWindowOgreAdapter::getOgreViewport(event.panel->getRenderWindow()); Ogre::Ray mouse_ray = viewport->getCamera()->getCameraToViewportRay( static_cast<float>(event.x) / static_cast<float>(viewport->getActualWidth()), static_cast<float>(event.y) / static_cast<float>(viewport->getActualHeight())); position = mouse_ray.getPoint(1.0); } } // namespace tools } // namespace rviz_default_plugins #include <pluginlib/class_list_macros.hpp> // NOLINT PLUGINLIB_EXPORT_CLASS(rviz_default_plugins::tools::FocusTool, rviz_common::Tool)
4,379
1,537
/*========================================================================= Module: vtkPVOptionsXMLParser.cxx Copyright (c) Kitware, Inc. All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkPVOptionsXMLParser.h" #include "vtkObjectFactory.h" #include "vtkPVOptions.h" #include <vtksys/SystemTools.hxx> //---------------------------------------------------------------------------- vtkStandardNewMacro(vtkPVOptionsXMLParser); //---------------------------------------------------------------------------- void vtkPVOptionsXMLParser::SetProcessType(const char* ptype) { if (!ptype) { this->SetProcessTypeInt(vtkCommandOptions::EVERYBODY); return; } std::string type = vtksys::SystemTools::LowerCase((ptype ? ptype : "")); if (type == "client") { this->SetProcessTypeInt(vtkPVOptions::PVCLIENT); return; } if (type == "server") { this->SetProcessTypeInt(vtkPVOptions::PVSERVER); return; } if (type == "render-server" || type == "renderserver") { this->SetProcessTypeInt(vtkPVOptions::PVRENDER_SERVER); return; } if (type == "data-server" || type == "dataserver") { this->SetProcessTypeInt(vtkPVOptions::PVDATA_SERVER); return; } if (type == "paraview") { this->SetProcessTypeInt(vtkPVOptions::PARAVIEW); return; } this->Superclass::SetProcessType(ptype); } //---------------------------------------------------------------------------- void vtkPVOptionsXMLParser::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); }
1,899
604
/*********************************************************************************************************************** * OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC, and other contributors. 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. * * (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products * derived from this software without specific prior written permission from the respective party. * * (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works * may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior * written permission from Alliance for Sustainable Energy, LLC. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY 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(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED * STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, 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 <gtest/gtest.h> #include "EnergyPlusFixture.hpp" #include "../ErrorFile.hpp" #include "../ForwardTranslator.hpp" #include "../ReverseTranslator.hpp" // Objects of interest #include "../../model/GeneratorMicroTurbine.hpp" #include "../../model/GeneratorMicroTurbine_Impl.hpp" #include "../../model/GeneratorMicroTurbineHeatRecovery.hpp" #include "../../model/GeneratorMicroTurbineHeatRecovery_Impl.hpp" // Needed resources #include "../../model/PlantLoop.hpp" #include "../../model/PlantLoop_Impl.hpp" #include "../../model/Node.hpp" #include "../../model/Node_Impl.hpp" #include "../../model/Curve.hpp" #include "../../model/Curve_Impl.hpp" #include "../../model/CurveBiquadratic.hpp" #include "../../model/CurveBiquadratic_Impl.hpp" #include "../../model/CurveCubic.hpp" #include "../../model/CurveCubic_Impl.hpp" #include "../../model/CurveQuadratic.hpp" #include "../../model/CurveQuadratic_Impl.hpp" #include "../../model/StraightComponent.hpp" #include "../../model/StraightComponent_Impl.hpp" #include "../../model/Schedule.hpp" #include "../../model/Schedule_Impl.hpp" // For testing PlantEquipOperation #include "../../model/WaterHeaterMixed.hpp" #include "../../model/WaterHeaterMixed_Impl.hpp" #include "../../model/PlantEquipmentOperationHeatingLoad.hpp" #include "../../model/PlantEquipmentOperationHeatingLoad_Impl.hpp" #include "../../model/ElectricLoadCenterDistribution.hpp" #include "../../model/ElectricLoadCenterDistribution_Impl.hpp" // IDF FieldEnums #include <utilities/idd/Generator_MicroTurbine_FieldEnums.hxx> // #include <utilities/idd/OS_Generator_MicroTurbine_HeatRecovery_FieldEnums.hxx> #include <utilities/idd/PlantEquipmentList_FieldEnums.hxx> #include <utilities/idd/IddEnums.hxx> #include <utilities/idd/IddFactory.hxx> // Misc #include "../../model/Version.hpp" #include "../../model/Version_Impl.hpp" #include "../../utilities/core/Optional.hpp" #include "../../utilities/core/Checksum.hpp" #include "../../utilities/core/UUID.hpp" #include "../../utilities/sql/SqlFile.hpp" #include "../../utilities/idf/IdfFile.hpp" #include "../../utilities/idf/IdfObject.hpp" #include "../../utilities/idf/IdfExtensibleGroup.hpp" #include <boost/algorithm/string/predicate.hpp> #include <resources.hxx> #include <sstream> #include <vector> // Debug #include "../../utilities/core/Logger.hpp" using namespace openstudio::energyplus; using namespace openstudio::model; using namespace openstudio; /** * Tests whether the ForwarTranslator will handle the name of the GeneratorMicroTurbine correctly in the PlantEquipmentOperationHeatingLoad **/ TEST_F(EnergyPlusFixture,ForwardTranslatorGeneratorMicroTurbine_ELCD_PlantLoop) { // TODO: Temporarily output the Log in the console with the Trace (-3) level // for debug // openstudio::Logger::instance().standardOutLogger().enable(); // openstudio::Logger::instance().standardOutLogger().setLogLevel(Trace); // Create a model, a mchp, a mchpHR, a plantLoop and an electricalLoadCenter Model model; GeneratorMicroTurbine mchp = GeneratorMicroTurbine(model); GeneratorMicroTurbineHeatRecovery mchpHR = GeneratorMicroTurbineHeatRecovery(model, mchp); ASSERT_EQ(mchpHR, mchp.generatorMicroTurbineHeatRecovery().get()); PlantLoop plantLoop(model); // Add a supply branch for the mchpHR ASSERT_TRUE(plantLoop.addSupplyBranchForComponent(mchpHR)); // Create a WaterHeater:Mixed WaterHeaterMixed waterHeater(model); // Add it on the same branch as the chpHR, right after it Node mchpHROutletNode = mchpHR.outletModelObject()->cast<Node>(); ASSERT_TRUE(waterHeater.addToNode(mchpHROutletNode)); // Create a plantEquipmentOperationHeatingLoad PlantEquipmentOperationHeatingLoad operation(model); operation.setName(plantLoop.name().get() + " PlantEquipmentOperationHeatingLoad"); ASSERT_TRUE(plantLoop.setPlantEquipmentOperationHeatingLoad(operation)); ASSERT_TRUE(operation.addEquipment(mchpHR)); ASSERT_TRUE(operation.addEquipment(waterHeater)); // Create an ELCD ElectricLoadCenterDistribution elcd = ElectricLoadCenterDistribution(model); elcd.setName("Capstone C65 ELCD"); elcd.setElectricalBussType("AlternatingCurrent"); elcd.addGenerator(mchp); // Forward Translates ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::WaterHeater_Mixed).size()); ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Distribution).size()); // The MicroTurbine should have been forward translated since there is an ELCD WorkspaceObjectVector microTurbineObjects(workspace.getObjectsByType(IddObjectType::Generator_MicroTurbine)); EXPECT_EQ(1u, microTurbineObjects.size()); // Check that the HR nodes have been set WorkspaceObject idf_mchp(microTurbineObjects[0]); EXPECT_EQ(mchpHR.inletModelObject()->name().get(), idf_mchp.getString(Generator_MicroTurbineFields::HeatRecoveryWaterInletNodeName).get()); EXPECT_EQ(mchpHR.outletModelObject()->name().get(), idf_mchp.getString(Generator_MicroTurbineFields::HeatRecoveryWaterOutletNodeName).get()); OptionalWorkspaceObject idf_operation(workspace.getObjectByTypeAndName(IddObjectType::PlantEquipmentOperation_HeatingLoad,*(operation.name()))); ASSERT_TRUE(idf_operation); // Get the extensible ASSERT_EQ(1u, idf_operation->numExtensibleGroups()); // IdfExtensibleGroup eg = idf_operation.getExtensibleGroup(0); // idf_operation.targets[0] ASSERT_EQ(1u, idf_operation->targets().size()); WorkspaceObject plantEquipmentList(idf_operation->targets()[0]); ASSERT_EQ(2u, plantEquipmentList.extensibleGroups().size()); IdfExtensibleGroup eg(plantEquipmentList.extensibleGroups()[0]); ASSERT_EQ("Generator:MicroTurbine", eg.getString(PlantEquipmentListExtensibleFields::EquipmentObjectType).get()); // This fails EXPECT_EQ(mchp.name().get(), eg.getString(PlantEquipmentListExtensibleFields::EquipmentName).get()); IdfExtensibleGroup eg2(plantEquipmentList.extensibleGroups()[1]); ASSERT_EQ("WaterHeater:Mixed", eg2.getString(PlantEquipmentListExtensibleFields::EquipmentObjectType).get()); EXPECT_EQ(waterHeater.name().get(), eg2.getString(PlantEquipmentListExtensibleFields::EquipmentName).get()); // model.save(toPath("./ForwardTranslatorGeneratorMicroTurbine_ELCD_PlantLoop.osm"), true); // workspace.save(toPath("./ForwardTranslatorGeneratorMicroTurbine_ELCD_PlantLoop.idf"), true); } //test orphaning the generator before FT TEST_F(EnergyPlusFixture, ForwardTranslatorGeneratorMicroTurbine_ELCD_Orphan) { // Create a model, a mchp, a mchpHR, a plantLoop and an electricalLoadCenter Model model; GeneratorMicroTurbine mchp = GeneratorMicroTurbine(model); GeneratorMicroTurbineHeatRecovery mchpHR = GeneratorMicroTurbineHeatRecovery(model, mchp); ASSERT_EQ(mchpHR, mchp.generatorMicroTurbineHeatRecovery().get()); PlantLoop plantLoop(model); // Add a supply branch for the mchpHR ASSERT_TRUE(plantLoop.addSupplyBranchForComponent(mchpHR)); // Create a WaterHeater:Mixed WaterHeaterMixed waterHeater(model); // Add it on the same branch as the chpHR, right after it Node mchpHROutletNode = mchpHR.outletModelObject()->cast<Node>(); ASSERT_TRUE(waterHeater.addToNode(mchpHROutletNode)); EXPECT_TRUE(waterHeater.plantLoop()); // Create a plantEquipmentOperationHeatingLoad PlantEquipmentOperationHeatingLoad operation(model); operation.setName(plantLoop.name().get() + " PlantEquipmentOperationHeatingLoad"); ASSERT_TRUE(plantLoop.setPlantEquipmentOperationHeatingLoad(operation)); ASSERT_TRUE(operation.addEquipment(mchpHR)); ASSERT_TRUE(operation.addEquipment(waterHeater)); // Create an ELCD ElectricLoadCenterDistribution elcd = ElectricLoadCenterDistribution(model); elcd.setName("Capstone C65 ELCD"); elcd.setElectricalBussType("AlternatingCurrent"); elcd.addGenerator(mchp); // orphan the generator from the ELCD boost::optional<ElectricLoadCenterDistribution> elcd2 = mchp.electricLoadCenterDistribution(); elcd2.get().remove(); EXPECT_FALSE(mchp.electricLoadCenterDistribution()); // Forward Translates ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); //ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::WaterHeater_Mixed).size()); ASSERT_EQ(0u, workspace.getObjectsByType(IddObjectType::ElectricLoadCenter_Distribution).size()); // model.save(toPath("./ForwardTranslatorGeneratorMicroTurbine_ELCD_orhpan.osm"), true); // workspace.save(toPath("./ForwardTranslatorGeneratorMicroTurbine_ELCD_orphan.idf"), true); }
11,047
3,759
// Copyright 2018 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "init/file_attrs_cleaner.h" #include <errno.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/xattr.h> #include <linux/fs.h> #include <string> #include <base/files/file_path.h> #include <base/files/file_util.h> #include <base/files/scoped_temp_dir.h> #include <gtest/gtest.h> using file_attrs_cleaner::AttributeCheckStatus; using file_attrs_cleaner::CheckFileAttributes; using file_attrs_cleaner::ImmutableAllowed; using file_attrs_cleaner::RemoveURLExtendedAttributes; using file_attrs_cleaner::ScanDir; namespace { // Helper to create a test file. bool CreateFile(const base::FilePath& file_path, base::StringPiece content) { if (!base::CreateDirectory(file_path.DirName())) return false; return base::WriteFile(file_path, content.data(), content.size()) == content.size(); } } // namespace namespace { class CheckFileAttributesTest : public ::testing::Test { void SetUp() { ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); test_dir_ = scoped_temp_dir_.GetPath(); } protected: // Setting file attributes (like immutable) requires privileges. // If we don't have that, we can't validate these tests :/. bool CanSetFileAttributes() { const base::FilePath path = test_dir_.Append(".attrs.test"); base::ScopedFD fd(open(path.value().c_str(), O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0600)); if (!fd.is_valid()) abort(); long flags; // NOLINT(runtime/int) if (ioctl(fd.get(), FS_IOC_GETFLAGS, &flags) != 0) abort(); flags |= FS_IMMUTABLE_FL; if (ioctl(fd.get(), FS_IOC_SETFLAGS, &flags) != 0) { PLOG(WARNING) << "Unable to test immutable bit behavior"; if (errno != EPERM) abort(); return false; } return true; } base::FilePath test_dir_; base::ScopedTempDir scoped_temp_dir_; }; } // namespace TEST_F(CheckFileAttributesTest, BadFd) { const base::FilePath path = test_dir_.Append("asdf"); EXPECT_EQ(AttributeCheckStatus::ERROR, CheckFileAttributes(path, false, -1)); EXPECT_EQ(AttributeCheckStatus::ERROR, CheckFileAttributes(path, true, -1)); EXPECT_EQ(AttributeCheckStatus::ERROR, CheckFileAttributes(path, true, 1000)); EXPECT_EQ(AttributeCheckStatus::ERROR, CheckFileAttributes(path, false, 1000)); } // Accept paths w/out the immutable bit set. TEST_F(CheckFileAttributesTest, NormalPaths) { const base::FilePath path = test_dir_.Append("file"); ASSERT_TRUE(CreateFile(path, "")); base::ScopedFD fd(open(path.value().c_str(), O_RDONLY | O_CLOEXEC)); ASSERT_TRUE(fd.is_valid()); EXPECT_EQ(AttributeCheckStatus::NO_ATTR, CheckFileAttributes(path, false, fd.get())); const base::FilePath dir = test_dir_.Append("dir"); ASSERT_EQ(0, mkdir(dir.value().c_str(), 0700)); fd.reset(open(dir.value().c_str(), O_RDONLY | O_CLOEXEC)); ASSERT_TRUE(fd.is_valid()); EXPECT_EQ(AttributeCheckStatus::NO_ATTR, CheckFileAttributes(dir, false, fd.get())); } // Clear files w/the immutable bit set. TEST_F(CheckFileAttributesTest, ResetFile) { if (!CanSetFileAttributes()) { SUCCEED(); return; } const base::FilePath path = test_dir_.Append("file"); ASSERT_TRUE(CreateFile(path, "")); base::ScopedFD fd(open(path.value().c_str(), O_RDONLY | O_CLOEXEC)); ASSERT_TRUE(fd.is_valid()); long flags; // NOLINT(runtime/int) EXPECT_EQ(0, ioctl(fd.get(), FS_IOC_GETFLAGS, &flags)); flags |= FS_IMMUTABLE_FL; EXPECT_EQ(0, ioctl(fd.get(), FS_IOC_SETFLAGS, &flags)); EXPECT_EQ(AttributeCheckStatus::CLEARED, CheckFileAttributes(path, false, fd.get())); } // Clear dirs w/the immutable bit set. TEST_F(CheckFileAttributesTest, ResetDir) { if (!CanSetFileAttributes()) { SUCCEED(); return; } const base::FilePath dir = test_dir_.Append("dir"); ASSERT_EQ(0, mkdir(dir.value().c_str(), 0700)); base::ScopedFD fd(open(dir.value().c_str(), O_RDONLY | O_CLOEXEC)); ASSERT_TRUE(fd.is_valid()); long flags; // NOLINT(runtime/int) EXPECT_EQ(0, ioctl(fd.get(), FS_IOC_GETFLAGS, &flags)); flags |= FS_IMMUTABLE_FL; EXPECT_EQ(0, ioctl(fd.get(), FS_IOC_SETFLAGS, &flags)); EXPECT_EQ(AttributeCheckStatus::CLEARED, CheckFileAttributes(dir, false, fd.get())); } namespace { class RemoveURLExtendedAttributesTest : public ::testing::Test { void SetUp() { ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); test_dir_ = scoped_temp_dir_.GetPath(); } protected: base::FilePath test_dir_; base::ScopedTempDir scoped_temp_dir_; }; } // namespace // Don't fail when files don't have extended attributes. TEST_F(RemoveURLExtendedAttributesTest, NoAttributesSucceeds) { const base::FilePath path = test_dir_.Append("xattr"); ASSERT_TRUE(CreateFile(path, "")); EXPECT_EQ(AttributeCheckStatus::NO_ATTR, RemoveURLExtendedAttributes(path)); } // Clear files with the "xdg" xattrs set, see crbug.com/919486. TEST_F(RemoveURLExtendedAttributesTest, Success) { const base::FilePath path = test_dir_.Append("xattr"); ASSERT_TRUE(CreateFile(path, "")); const char* path_cstr = path.value().c_str(); EXPECT_EQ( 0, setxattr(path_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0, 0)); EXPECT_EQ( 0, setxattr(path_cstr, file_attrs_cleaner::xdg_referrer_url, NULL, 0, 0)); EXPECT_EQ(AttributeCheckStatus::CLEARED, RemoveURLExtendedAttributes(path)); // getxattr(2) call should fail now. EXPECT_GT(0, getxattr(path_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0)); EXPECT_GT(0, getxattr(path_cstr, file_attrs_cleaner::xdg_referrer_url, NULL, 0)); } // Leave other attributes alone. TEST_F(RemoveURLExtendedAttributesTest, OtherAttributesUnchanged) { const base::FilePath path = test_dir_.Append("xattr"); ASSERT_TRUE(CreateFile(path, "")); EXPECT_EQ(0, setxattr(path.value().c_str(), "user.test", NULL, 0, 0)); EXPECT_EQ(AttributeCheckStatus::NO_ATTR, RemoveURLExtendedAttributes(path)); // getxattr(2) call should succeed. EXPECT_EQ(0, getxattr(path.value().c_str(), "user.test", NULL, 0)); } namespace { class ScanDirTest : public ::testing::Test { void SetUp() { ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); test_dir_ = scoped_temp_dir_.GetPath(); url_xattrs_count_ = 0; } protected: base::FilePath test_dir_; base::ScopedTempDir scoped_temp_dir_; int url_xattrs_count_; }; } // namespace TEST_F(ScanDirTest, Empty) { EXPECT_TRUE(ScanDir(test_dir_, {}, &url_xattrs_count_)); } TEST_F(ScanDirTest, Leaf) { CreateFile(test_dir_.Append("file1"), ""); CreateFile(test_dir_.Append("file2"), ""); EXPECT_TRUE(ScanDir(test_dir_, {}, &url_xattrs_count_)); } TEST_F(ScanDirTest, Nested) { CreateFile(test_dir_.Append("file1"), ""); CreateFile(test_dir_.Append("file2"), ""); EXPECT_TRUE(base::CreateDirectory(test_dir_.Append("emptydir"))); const base::FilePath dir1(test_dir_.Append("dir1")); EXPECT_TRUE(base::CreateDirectory(dir1)); CreateFile(dir1.Append("file1"), ""); CreateFile(dir1.Append("file2"), ""); EXPECT_TRUE(base::CreateDirectory(dir1.Append("emptydir"))); const base::FilePath dir2(dir1.Append("dir1")); EXPECT_TRUE(base::CreateDirectory(dir2)); CreateFile(dir2.Append("file1"), ""); CreateFile(dir2.Append("file2"), ""); EXPECT_TRUE(base::CreateDirectory(dir2.Append("emptydir"))); EXPECT_TRUE(ScanDir(test_dir_, {}, &url_xattrs_count_)); } TEST_F(ScanDirTest, RecurseAndClearAttributes) { const base::FilePath file1 = test_dir_.Append("file1"); CreateFile(file1, ""); CreateFile(test_dir_.Append("file1"), ""); CreateFile(test_dir_.Append("file2"), ""); const base::FilePath subdir(test_dir_.Append("subdir")); EXPECT_TRUE(base::CreateDirectory(subdir)); const base::FilePath subfile1(subdir.Append("subfile1")); const base::FilePath subfile2(subdir.Append("subfile2")); const base::FilePath subfile3(subdir.Append("subfile3")); CreateFile(subfile1, ""); CreateFile(subfile2, ""); CreateFile(subfile3, ""); const char* file1_cstr = file1.value().c_str(); const char* subf1_cstr = subfile1.value().c_str(); const char* subf3_cstr = subfile3.value().c_str(); EXPECT_EQ( 0, setxattr(file1_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0, 0)); EXPECT_EQ( 0, setxattr(subf1_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0, 0)); EXPECT_EQ( 0, setxattr(subf3_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0, 0)); EXPECT_TRUE(ScanDir(test_dir_, {}, &url_xattrs_count_)); EXPECT_EQ(url_xattrs_count_, 3); EXPECT_GT(0, getxattr(file1_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0)); EXPECT_GT(0, getxattr(subf1_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0)); EXPECT_GT(0, getxattr(subf3_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0)); } TEST_F(ScanDirTest, SkipRecurse) { CreateFile(test_dir_.Append("file1"), ""); CreateFile(test_dir_.Append("file2"), ""); const base::FilePath subdir(test_dir_.Append("subdir")); EXPECT_TRUE(base::CreateDirectory(subdir)); const base::FilePath subfile(subdir.Append("subfile")); CreateFile(subfile, ""); const char* subf_cstr = subfile.value().c_str(); EXPECT_EQ( 0, setxattr(subf_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0, 0)); std::vector<std::string> skip = {"subdir"}; EXPECT_TRUE(ScanDir(test_dir_, skip, &url_xattrs_count_)); EXPECT_EQ(0, getxattr(subf_cstr, file_attrs_cleaner::xdg_origin_url, NULL, 0)); } TEST_F(ScanDirTest, InvalidDirSucceeds) { const base::FilePath subdir( test_dir_.Append("this_dir_definitely_does_not_exist")); EXPECT_TRUE(ScanDir(subdir, {}, &url_xattrs_count_)); }
9,889
3,828
#include <fstream> #include <streambuf> #include <gl_includes.h> #include <iostream> #include <cstdlib> #include "textures.h" #include "util.h" #define KONSTRUCTS_PATH_SIZE 256 namespace konstructs { void shtxt_path(const char *name, const char *type, char *path, size_t max_len) { snprintf(path, max_len, "%s/%s", type, name); if (!file_exist(path)) { if(const char* env_p = std::getenv("SNAP")) { snprintf(path, max_len, "%s/%s/%s", env_p, type, name); } } if (!file_exist(path)) { snprintf(path, max_len, "../%s/%s", type, name); } if (!file_exist(path)) { snprintf(path, max_len, "/usr/local/share/konstructs-client/%s/%s", type, name); } if (!file_exist(path)) { printf("Error, no %s for %s found.\n", type, name); exit(1); } } void texture_path(const char *name, char *path, size_t max_len) { shtxt_path(name, "textures", path, max_len); } void model_path(const char *name, char *path, size_t max_len) { shtxt_path(name, "models", path, max_len); } void shader_path(const char *name, char *path, size_t max_len) { shtxt_path(name, "shaders", path, max_len); } void load_textures() { char txtpth[KONSTRUCTS_PATH_SIZE]; GLuint sky; glGenTextures(1, &sky); glActiveTexture(GL_TEXTURE0 + SKY_TEXTURE); glBindTexture(GL_TEXTURE_2D, sky); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); texture_path("sky.png", txtpth, KONSTRUCTS_PATH_SIZE); load_png_texture(txtpth); GLuint font; glGenTextures(1, &font); glActiveTexture(GL_TEXTURE0 + FONT_TEXTURE); glBindTexture(GL_TEXTURE_2D, font); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); texture_path("font.png", txtpth, KONSTRUCTS_PATH_SIZE); load_png_texture(txtpth); GLuint inventory_texture; glGenTextures(1, &inventory_texture); glActiveTexture(GL_TEXTURE0 + INVENTORY_TEXTURE); glBindTexture(GL_TEXTURE_2D, inventory_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); texture_path("inventory.png", txtpth, KONSTRUCTS_PATH_SIZE); load_png_texture(txtpth); GLuint player_texture; glGenTextures(1, &player_texture); glActiveTexture(GL_TEXTURE0 + PLAYER_TEXTURE); glBindTexture(GL_TEXTURE_2D, player_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); texture_path("player.png", txtpth, KONSTRUCTS_PATH_SIZE); load_png_texture(txtpth); GLuint damage_texture; glGenTextures(1, &damage_texture); glActiveTexture(GL_TEXTURE0 + DAMAGE_TEXTURE); glBindTexture(GL_TEXTURE_2D, damage_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); texture_path("damage.png", txtpth, KONSTRUCTS_PATH_SIZE); load_png_texture(txtpth); GLuint health_bar_texture; glGenTextures(1, &health_bar_texture); glActiveTexture(GL_TEXTURE0 + HEALTH_BAR_TEXTURE); glBindTexture(GL_TEXTURE_2D, health_bar_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); texture_path("health_bar.png", txtpth, KONSTRUCTS_PATH_SIZE); load_png_texture(txtpth); // Set Active texture to GL_TEXTURE0, nanogui will use the active texture glActiveTexture(GL_TEXTURE0); } tinyobj::shape_t load_player() { char objpth[KONSTRUCTS_PATH_SIZE]; model_path("player.obj", objpth, KONSTRUCTS_PATH_SIZE); std::vector<tinyobj::shape_t> shapes; std::vector<tinyobj::material_t> materials; std::string err; tinyobj::LoadObj(shapes, materials, err, objpth); return shapes[0]; } std::string load_shader(const char* name) { char shader_pth[KONSTRUCTS_PATH_SIZE]; shader_path(name, shader_pth, KONSTRUCTS_PATH_SIZE); std::ifstream shader(shader_pth); std::string shader_str((std::istreambuf_iterator<char>(shader)), std::istreambuf_iterator<char>()); return shader_str; } std::string load_chunk_vertex_shader() { return load_shader("chunk.vert"); } std::string load_chunk_fragment_shader() { return load_shader("chunk.frag"); } };
5,129
1,922
// (C) Copyright Gennadiy Rozental 2005-2008. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/test for the library home page. // // File : $RCSfile$ // // Version : $Revision$ // // Description : implements framework API - main driver for the test // *************************************************************************** #ifndef BOOST_TEST_FRAMEWORK_IPP_021005GER #define BOOST_TEST_FRAMEWORK_IPP_021005GER // Boost.Test #include <boost/test/framework.hpp> #include <boost/test/execution_monitor.hpp> #include <boost/test/debug.hpp> #include <boost/test/unit_test_suite_impl.hpp> #include <boost/test/unit_test_log.hpp> #include <boost/test/unit_test_monitor.hpp> #include <boost/test/test_observer.hpp> #include <boost/test/results_collector.hpp> #include <boost/test/progress_monitor.hpp> #include <boost/test/results_reporter.hpp> #include <boost/test/test_tools.hpp> #include <boost/test/detail/unit_test_parameters.hpp> #include <boost/test/detail/global_typedef.hpp> #include <boost/test/utils/foreach.hpp> // Boost #include <boost/timer.hpp> // STL #include <map> #include <set> #include <cstdlib> #include <ctime> #ifdef BOOST_NO_STDC_NAMESPACE namespace std { using ::time; using ::srand; } #endif #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// namespace boost { namespace unit_test { // ************************************************************************** // // ************** test_start calls wrapper ************** // // ************************************************************************** // namespace ut_detail { struct test_start_caller { test_start_caller( test_observer* to, counter_t tc_amount ) : m_to( to ) , m_tc_amount( tc_amount ) {} int operator()() { m_to->test_start( m_tc_amount ); return 0; } private: // Data members test_observer* m_to; counter_t m_tc_amount; }; //____________________________________________________________________________// struct test_init_caller { explicit test_init_caller( init_unit_test_func init_func ) : m_init_func( init_func ) {} int operator()() { #ifdef BOOST_TEST_ALTERNATIVE_INIT_API if( !(*m_init_func)() ) throw std::runtime_error( "test module initialization failed" ); #else test_suite* manual_test_units = (*m_init_func)( framework::master_test_suite().argc, framework::master_test_suite().argv ); if( manual_test_units ) framework::master_test_suite().add( manual_test_units ); #endif return 0; } // Data members init_unit_test_func m_init_func; }; } // ************************************************************************** // // ************** framework ************** // // ************************************************************************** // class framework_impl : public test_tree_visitor { public: framework_impl() : m_master_test_suite( 0 ) , m_curr_test_case( INV_TEST_UNIT_ID ) , m_next_test_case_id( MIN_TEST_CASE_ID ) , m_next_test_suite_id( MIN_TEST_SUITE_ID ) , m_is_initialized( false ) , m_test_in_progress( false ) {} ~framework_impl() { clear(); } void clear() { while( !m_test_units.empty() ) { test_unit_store::value_type const& tu = *m_test_units.begin(); test_unit const* tu_ptr = tu.second; // the delete will erase this element from map if( ut_detail::test_id_2_unit_type( tu.second->p_id ) == tut_suite ) delete static_cast<test_suite const*>(tu_ptr); else delete static_cast<test_case const*>(tu_ptr); } } void set_tu_id( test_unit& tu, test_unit_id id ) { tu.p_id.value = id; } // test_tree_visitor interface implementation void visit( test_case const& tc ) { if( !tc.check_dependencies() ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_skipped( tc ); return; } BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_start( tc ); boost::timer tc_timer; test_unit_id bkup = m_curr_test_case; m_curr_test_case = tc.p_id; unit_test_monitor_t::error_level run_result = unit_test_monitor.execute_and_translate( tc ); unsigned long elapsed = static_cast<unsigned long>( tc_timer.elapsed() * 1e6 ); if( unit_test_monitor.is_critical_error( run_result ) ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_aborted(); } BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_finish( tc, elapsed ); m_curr_test_case = bkup; if( unit_test_monitor.is_critical_error( run_result ) ) throw test_being_aborted(); } bool test_suite_start( test_suite const& ts ) { if( !ts.check_dependencies() ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_skipped( ts ); return false; } BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_start( ts ); return true; } void test_suite_finish( test_suite const& ts ) { BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_finish( ts, 0 ); } ////////////////////////////////////////////////////////////////// struct priority_order { bool operator()( test_observer* lhs, test_observer* rhs ) const { return (lhs->priority() < rhs->priority()) || ((lhs->priority() == rhs->priority()) && (lhs < rhs)); } }; typedef std::map<test_unit_id,test_unit*> test_unit_store; typedef std::set<test_observer*,priority_order> observer_store; master_test_suite_t* m_master_test_suite; test_unit_id m_curr_test_case; test_unit_store m_test_units; test_unit_id m_next_test_case_id; test_unit_id m_next_test_suite_id; bool m_is_initialized; bool m_test_in_progress; observer_store m_observers; }; //____________________________________________________________________________// namespace { #if defined(__CYGWIN__) framework_impl& s_frk_impl() { static framework_impl* the_inst = 0; if(!the_inst) the_inst = new framework_impl; return *the_inst; } #else framework_impl& s_frk_impl() { static framework_impl the_inst; return the_inst; } #endif } // local namespace //____________________________________________________________________________// namespace framework { void init( init_unit_test_func init_func, int argc, char* argv[] ) { runtime_config::init( argc, argv ); // set the log level and format unit_test_log.set_threshold_level( runtime_config::log_level() ); unit_test_log.set_format( runtime_config::log_format() ); // set the report level and format results_reporter::set_level( runtime_config::report_level() ); results_reporter::set_format( runtime_config::report_format() ); register_observer( results_collector ); register_observer( unit_test_log ); if( runtime_config::show_progress() ) register_observer( progress_monitor ); if( runtime_config::detect_memory_leaks() > 0 ) { debug::detect_memory_leaks( true ); debug::break_memory_alloc( runtime_config::detect_memory_leaks() ); } // init master unit test suite master_test_suite().argc = argc; master_test_suite().argv = argv; try { boost::execution_monitor em; ut_detail::test_init_caller tic( init_func ); em.execute( tic ); } catch( execution_exception const& ex ) { throw setup_error( ex.what() ); } s_frk_impl().m_is_initialized = true; } //____________________________________________________________________________// bool is_initialized() { return s_frk_impl().m_is_initialized; } //____________________________________________________________________________// void register_test_unit( test_case* tc ) { BOOST_TEST_SETUP_ASSERT( tc->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test case already registered" ) ); test_unit_id new_id = s_frk_impl().m_next_test_case_id; BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_CASE_ID, BOOST_TEST_L( "too many test cases" ) ); typedef framework_impl::test_unit_store::value_type map_value_type; s_frk_impl().m_test_units.insert( map_value_type( new_id, tc ) ); s_frk_impl().m_next_test_case_id++; s_frk_impl().set_tu_id( *tc, new_id ); } //____________________________________________________________________________// void register_test_unit( test_suite* ts ) { BOOST_TEST_SETUP_ASSERT( ts->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test suite already registered" ) ); test_unit_id new_id = s_frk_impl().m_next_test_suite_id; BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_SUITE_ID, BOOST_TEST_L( "too many test suites" ) ); typedef framework_impl::test_unit_store::value_type map_value_type; s_frk_impl().m_test_units.insert( map_value_type( new_id, ts ) ); s_frk_impl().m_next_test_suite_id++; s_frk_impl().set_tu_id( *ts, new_id ); } //____________________________________________________________________________// void deregister_test_unit( test_unit* tu ) { s_frk_impl().m_test_units.erase( tu->p_id ); } //____________________________________________________________________________// void clear() { s_frk_impl().clear(); } //____________________________________________________________________________// void register_observer( test_observer& to ) { s_frk_impl().m_observers.insert( &to ); } //____________________________________________________________________________// void deregister_observer( test_observer& to ) { s_frk_impl().m_observers.erase( &to ); } //____________________________________________________________________________// void reset_observers() { s_frk_impl().m_observers.clear(); } //____________________________________________________________________________// master_test_suite_t& master_test_suite() { if( !s_frk_impl().m_master_test_suite ) s_frk_impl().m_master_test_suite = new master_test_suite_t; return *s_frk_impl().m_master_test_suite; } //____________________________________________________________________________// test_case const& current_test_case() { return get<test_case>( s_frk_impl().m_curr_test_case ); } //____________________________________________________________________________// test_unit& get( test_unit_id id, test_unit_type t ) { test_unit* res = s_frk_impl().m_test_units[id]; if( (res->p_type & t) == 0 ) throw internal_error( "Invalid test unit type" ); return *res; } //____________________________________________________________________________// void run( test_unit_id id, bool continue_test ) { if( id == INV_TEST_UNIT_ID ) id = master_test_suite().p_id; test_case_counter tcc; traverse_test_tree( id, tcc ); BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::test_to_run().is_empty() ? BOOST_TEST_L( "test tree is empty" ) : BOOST_TEST_L( "no test cases matching filter" ) ); bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress; bool was_in_progress = s_frk_impl().m_test_in_progress; s_frk_impl().m_test_in_progress = true; if( call_start_finish ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) { boost::execution_monitor em; try { em.execute( ut_detail::test_start_caller( to, tcc.p_count ) ); } catch( execution_exception const& ex ) { throw setup_error( ex.what() ); } } } switch( runtime_config::random_seed() ) { case 0: break; case 1: { unsigned int seed = static_cast<unsigned int>( std::time( 0 ) ); BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << seed ); std::srand( seed ); break; } default: BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << runtime_config::random_seed() ); std::srand( runtime_config::random_seed() ); } try { traverse_test_tree( id, s_frk_impl() ); } catch( test_being_aborted const& ) { // abort already reported } if( call_start_finish ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) to->test_finish(); } s_frk_impl().m_test_in_progress = was_in_progress; } //____________________________________________________________________________// void run( test_unit const* tu, bool continue_test ) { run( tu->p_id, continue_test ); } //____________________________________________________________________________// void assertion_result( bool passed ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) to->assertion_result( passed ); } //____________________________________________________________________________// void exception_caught( execution_exception const& ex ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) to->exception_caught( ex ); } //____________________________________________________________________________// void test_unit_aborted( test_unit const& tu ) { BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers ) to->test_unit_aborted( tu ); } //____________________________________________________________________________// } // namespace framework } // namespace unit_test } // namespace boost //____________________________________________________________________________// #include <boost/test/detail/enable_warnings.hpp> #endif // BOOST_TEST_FRAMEWORK_IPP_021005GER
14,334
4,706
#include "addspatialentitycommand.h" #include <QtWidgets/qcombobox.h> #include "GameData/Components/TransformComponent.generated.h" #include "GameData/World.h" AddSpatialEntityCommand::AddSpatialEntityCommand(const SpatialEntity& entity, const Vector2D& location) : EditorCommand(EffectBitset(EffectType::Entities)) , mEntity(entity) , mLocation(location) { } void AddSpatialEntityCommand::doCommand(World* world) { WorldCell& cell = world->getSpatialData().getOrCreateCell(mEntity.cell); EntityManager& cellEnttiyManager = cell.getEntityManager(); cellEnttiyManager.addExistingEntityUnsafe(mEntity.entity.getEntity()); TransformComponent* transform = cellEnttiyManager.addComponent<TransformComponent>(mEntity.entity.getEntity()); transform->setLocation(mLocation); } void AddSpatialEntityCommand::undoCommand(World* world) { if (WorldCell* cell = world->getSpatialData().getCell(mEntity.cell)) { EntityManager& cellEnttiyManager = cell->getEntityManager(); cellEnttiyManager.removeEntity(mEntity.entity.getEntity()); } }
1,043
336
#include <szen/System/Window.hpp> #include <szen/Game/Camera.hpp> #include <sstream> #ifdef SFML_SYSTEM_WINDOWS #include <Windows.h> #endif using namespace sz; namespace { sf::RenderWindow* m_window = NULL; float m_aspectRatio; sf::Uint32 m_virtualWidth = 1920; sf::View m_view; std::string m_title; sf::Uint32 m_antialiasing; } //////////////////////////////////////////////////// void Window::open(sf::VideoMode videomode, const std::string &title, const sf::Uint32 style, const sf::Uint32 antialias, const sf::Uint32 virtualWidth) { assert(!m_window && "Window is already open"); sf::ContextSettings settings; settings.antialiasingLevel = antialias; // Create new window instance m_window = new(std::nothrow) sf::RenderWindow(videomode, title, style, settings); assert(m_window && "Allocation failed"); m_title = title; m_antialiasing = antialias; m_aspectRatio = videomode.width / static_cast<float>(videomode.height); // Set virtual width m_virtualWidth = (virtualWidth == 0 ? videomode.width : virtualWidth); m_window->setVerticalSyncEnabled(true); m_window->clear(sf::Color::Black); m_window->display(); Camera::updateScreenSize(); } //////////////////////////////////////////////////// void Window::changeMode(sf::VideoMode videomode, const sf::Uint32 style) { if(!m_window) return; // Delete old window and create new instead delete m_window; sf::ContextSettings settings; settings.antialiasingLevel = m_antialiasing; m_window = new sf::RenderWindow(videomode, m_title, style, settings); m_aspectRatio = videomode.width / static_cast<float>(videomode.height); m_window->setVerticalSyncEnabled(true); m_window->clear(sf::Color::Black); m_window->display(); Camera::updateScreenSize(); } //////////////////////////////////////////////////// void Window::close() { if(m_window) { m_window->close(); delete m_window; m_window = NULL; } } //////////////////////////////////////////////////// sf::Vector2u Window::getSize() { return m_window->getSize(); } //////////////////////////////////////////////////// void Window::setVirtualWidth(const sf::Uint32 width) { m_virtualWidth = width; Camera::updateScreenSize(); } //////////////////////////////////////////////////// sf::Vector2u Window::getVirtualSize() { return sf::Vector2u( m_virtualWidth, static_cast<sf::Uint32>(ceil(m_virtualWidth * (1.f / m_aspectRatio)))); } //////////////////////////////////////////////////// sf::RenderWindow* Window::getRenderWindow() { return m_window; } //////////////////////////////////////////////////// bool Window::isActive() { // Windows implementation return m_window->getSystemHandle() == GetActiveWindow(); } //////////////////////////////////////////////////////////// sf::VideoMode Window::getOptimalResolution(const bool fullscreen) { sf::VideoMode native = sf::VideoMode::getDesktopMode(); std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes(); sf::VideoMode videomode = native; if(fullscreen && native == modes[0]) return videomode; float nativeRatio = native.width / static_cast<float>(native.height); float ratio; for(std::vector<sf::VideoMode>::iterator it = modes.begin(); it != modes.end(); ++it) { sf::VideoMode mode = *it; if(mode.bitsPerPixel != native.bitsPerPixel) continue; if(mode.width >= native.width) continue; ratio = mode.width / static_cast<float>(mode.height); if(fabs(nativeRatio - ratio) <= 0.001f) { videomode = mode; break; } } return videomode; } #include <iostream> //////////////////////////////////////////////////////////// int calculateGCD(int a, int b) { return (b == 0) ? a : calculateGCD (b, a%b); } //////////////////////////////////////////////////////////// std::vector<sf::VideoMode> Window::getSupportedResolutions(const bool fullscreen) { sf::VideoMode native = sf::VideoMode::getDesktopMode(); float nativeAspect = native.width / (float)native.height; std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes(); std::vector<sf::VideoMode> result; for(int i=0; i < modes.size(); ++i) { sf::VideoMode mode = modes[i]; bool cond = true; float ratio = mode.width / (float)mode.height; cond &= mode.bitsPerPixel == modes[0].bitsPerPixel; cond &= mode.width >= 1024; cond &= mode.width <= native.width && mode.height <= native.height; //cond &= nativeAspect == ratio; if(cond) { result.push_back(mode); } } std::sort(result.begin(), result.end(), [](sf::VideoMode& a, sf::VideoMode& b) -> bool { /*float ra = a.width / (float)a.height; float rb = b.width / (float)b.height; */ return (a.width * a.height) < (b.width * b.height); } ); std::cout << "============================================================\n"; for(int i=0; i < result.size(); ++i) { sf::VideoMode mode = result[i]; std::stringstream aspect; int gcd = calculateGCD(mode.width, mode.height); sf::Vector2i ratio(mode.width, mode.height); ratio /= gcd; if(ratio.x == 8 && ratio.y == 5) ratio *= 2; aspect << ratio.x << ":" << ratio.y; std::cout << mode.width << " x " << mode.height << " (" << aspect.str() << ")\n"; } return result; }
5,195
1,831
/* CatenaBase_NetSave.cpp Mon Dec 03 2018 13:21:28 chwon */ /* Module: CatenaBase_NetSave.cpp Function: Interface from LoRaWAN to FRAM. Version: V0.12.0 Mon Dec 03 2018 13:21:28 chwon Edit level 1 Copyright notice: This file copyright (C) 2018 by MCCI Corporation 3520 Krums Corners Road Ithaca, NY 14850 An unpublished work. All rights reserved. This file is proprietary information, and may not be disclosed or copied without the prior permission of MCCI Corporation Author: ChaeHee Won, MCCI Corporation December 2018 Revision history: 0.12.0 Mon Dec 03 2018 13:21:28 chwon Module created. */ #include <CatenaBase.h> #include <Catena_Fram.h> #include <Catena_Log.h> using namespace McciCatena; void CatenaBase::NetSaveFCntUp( uint32_t uFCntUp ) { auto const pFram = this->getFram(); if (pFram != nullptr) pFram->saveField(cFramStorage::kFCntUp, uFCntUp); } void CatenaBase::NetSaveFCntDown( uint32_t uFCntDown ) { auto const pFram = this->getFram(); if (pFram != nullptr) pFram->saveField(cFramStorage::kFCntDown, uFCntDown); } void CatenaBase::NetSaveSessionInfo( const Arduino_LoRaWAN::SessionInfo &Info, const uint8_t *pExtraInfo, size_t nExtraInfo ) { auto const pFram = this->getFram(); if (pFram != nullptr) { pFram->saveField(cFramStorage::kNetID, Info.V1.NetID); pFram->saveField(cFramStorage::kDevAddr, Info.V1.DevAddr); pFram->saveField(cFramStorage::kNwkSKey, Info.V1.NwkSKey); pFram->saveField(cFramStorage::kAppSKey, Info.V1.AppSKey); pFram->saveField(cFramStorage::kFCntUp, Info.V1.FCntUp); pFram->saveField(cFramStorage::kFCntDown, Info.V1.FCntDown); } gLog.printf( gLog.kAlways, "NwkID: %08x " "DevAddr: %08x\n", Info.V1.NetID, Info.V1.DevAddr ); } /**** end of CatenaBase_NetSave.cpp ****/
1,814
853
/* * Copyright (c) 2017, Ford Motor Company * 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 the Ford Motor Company 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 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. */ #include "config_profile/profile.h" #include "utils/helpers.h" #include "utils/logger.h" #include "utils/timer_task_impl.h" #include "transport_manager/transport_adapter/client_connection_listener.h" #include "transport_manager/transport_adapter/device_scanner.h" #include "transport_manager/transport_adapter/server_connection_factory.h" #include "transport_manager/transport_adapter/transport_adapter_impl.h" #include "transport_manager/transport_adapter/transport_adapter_listener.h" #ifdef WEBSOCKET_SERVER_TRANSPORT_SUPPORT #include "transport_manager/websocket_server/websocket_device.h" #endif namespace transport_manager { namespace transport_adapter { const char* tc_enabled = "enabled"; const char* tc_tcp_port = "tcp_port"; const char* tc_tcp_ip_address = "tcp_ip_address"; SDL_CREATE_LOG_VARIABLE("TransportManager") namespace { DeviceTypes devicesType = { std::make_pair(DeviceType::AOA, std::string("USB_AOA")), std::make_pair(DeviceType::BLUETOOTH, std::string("BLUETOOTH")), std::make_pair(DeviceType::IOS_BT, std::string("BLUETOOTH_IOS")), std::make_pair(DeviceType::IOS_USB, std::string("USB_IOS")), std::make_pair(DeviceType::TCP, std::string("WIFI")), std::make_pair(DeviceType::IOS_USB_HOST_MODE, std::string("USB_IOS_HOST_MODE")), std::make_pair(DeviceType::IOS_USB_DEVICE_MODE, std::string("USB_IOS_DEVICE_MODE")), std::make_pair(DeviceType::IOS_CARPLAY_WIRELESS, std::string("CARPLAY_WIRELESS_IOS")), std::make_pair(DeviceType::CLOUD_WEBSOCKET, std::string("CLOUD_WEBSOCKET")), std::make_pair(DeviceType::WEBENGINE_WEBSOCKET, std::string("WEBENGINE_WEBSOCKET"))}; } TransportAdapterImpl::TransportAdapterImpl( DeviceScanner* device_scanner, ServerConnectionFactory* server_connection_factory, ClientConnectionListener* client_connection_listener, resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings) : listeners_() , initialised_(0) , devices_() , devices_mutex_() , connections_() , connections_lock_() , #ifdef TELEMETRY_MONITOR metric_observer_(NULL) , #endif // TELEMETRY_MONITOR device_scanner_(device_scanner) , server_connection_factory_(server_connection_factory) , client_connection_listener_(client_connection_listener) , last_state_wrapper_(last_state_wrapper) , settings_(settings) { } TransportAdapterImpl::~TransportAdapterImpl() { listeners_.clear(); Terminate(); if (device_scanner_) { SDL_LOG_DEBUG("Deleting device_scanner_ " << device_scanner_); delete device_scanner_; SDL_LOG_DEBUG("device_scanner_ deleted."); } if (server_connection_factory_) { SDL_LOG_DEBUG("Deleting server_connection_factory " << server_connection_factory_); delete server_connection_factory_; SDL_LOG_DEBUG("server_connection_factory deleted."); } if (client_connection_listener_) { SDL_LOG_DEBUG("Deleting client_connection_listener_ " << client_connection_listener_); delete client_connection_listener_; SDL_LOG_DEBUG("client_connection_listener_ deleted."); } } void TransportAdapterImpl::Terminate() { if (device_scanner_) { device_scanner_->Terminate(); SDL_LOG_DEBUG("device_scanner_ " << device_scanner_ << " terminated."); } if (server_connection_factory_) { server_connection_factory_->Terminate(); SDL_LOG_DEBUG("server_connection_factory " << server_connection_factory_ << " terminated."); } if (client_connection_listener_) { client_connection_listener_->Terminate(); SDL_LOG_DEBUG("client_connection_listener_ " << client_connection_listener_ << " terminated."); } ConnectionMap connections; connections_lock_.AcquireForWriting(); std::swap(connections, connections_); connections_lock_.Release(); for (const auto& connection : connections) { auto& info = connection.second; if (info.connection) { info.connection->Terminate(); } } connections.clear(); SDL_LOG_DEBUG("Connections deleted"); DeviceMap devices; devices_mutex_.Acquire(); std::swap(devices, devices_); devices_mutex_.Release(); devices.clear(); SDL_LOG_DEBUG("Devices deleted"); } TransportAdapter::Error TransportAdapterImpl::Init() { SDL_LOG_TRACE("enter"); Error error = OK; if ((error == OK) && device_scanner_) { error = device_scanner_->Init(); } if ((error == OK) && server_connection_factory_) { error = server_connection_factory_->Init(); } if ((error == OK) && client_connection_listener_) { error = client_connection_listener_->Init(); } initialised_ = (error == OK); if (get_settings().use_last_state() && initialised_) { if (!Restore()) { SDL_LOG_WARN("could not restore transport adapter state"); } } SDL_LOG_TRACE("exit with error: " << error); return error; } TransportAdapter::Error TransportAdapterImpl::SearchDevices() { SDL_LOG_TRACE("enter"); if (device_scanner_ == NULL) { SDL_LOG_TRACE("exit with NOT_SUPPORTED"); return NOT_SUPPORTED; } else if (!device_scanner_->IsInitialised()) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } TransportAdapter::Error er = device_scanner_->Scan(); SDL_LOG_TRACE("exit with error: " << er); return er; } TransportAdapter::Error TransportAdapterImpl::Connect( const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_TRACE("enter. DeviceUID " << device_id << " ApplicationHandle " << app_handle); if (server_connection_factory_ == 0) { SDL_LOG_TRACE("exit with NOT_SUPPORTED"); return NOT_SUPPORTED; } if (!server_connection_factory_->IsInitialised()) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } if (!initialised_) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } connections_lock_.AcquireForWriting(); std::pair<DeviceUID, ApplicationHandle> connection_key = std::make_pair(device_id, app_handle); const bool already_exists = connections_.end() != connections_.find(connection_key); ConnectionInfo& info = connections_[connection_key]; if (!already_exists) { info.app_handle = app_handle; info.device_id = device_id; info.state = ConnectionInfo::NEW; } const bool pending_app = ConnectionInfo::PENDING == info.state; connections_lock_.Release(); if (already_exists && !pending_app) { SDL_LOG_TRACE("exit with ALREADY_EXISTS"); return ALREADY_EXISTS; } const TransportAdapter::Error err = server_connection_factory_->CreateConnection(device_id, app_handle); if (TransportAdapter::OK != err) { if (!pending_app) { RemoveConnection(device_id, app_handle); } } SDL_LOG_TRACE("exit with error: " << err); return err; } TransportAdapter::Error TransportAdapterImpl::ConnectDevice( const DeviceUID& device_handle) { SDL_LOG_TRACE("enter with device_handle: " << &device_handle); DeviceSptr device = FindDevice(device_handle); if (device) { TransportAdapter::Error err = ConnectDevice(device); if (FAIL == err && GetDeviceType() == DeviceType::CLOUD_WEBSOCKET) { SDL_LOG_TRACE("Error occurred while connecting cloud app: " << err); // Update retry count if (device->retry_count() >= get_settings().cloud_app_max_retry_attempts()) { device->reset_retry_count(); ConnectionStatusUpdated(device, ConnectionStatus::PENDING); return err; } else if (device->connection_status() == ConnectionStatus::PENDING) { ConnectionStatusUpdated(device, ConnectionStatus::RETRY); } device->next_retry(); // Start timer for next retry TimerSPtr retry_timer(std::make_shared<timer::Timer>( "RetryConnectionTimer", new timer::TimerTaskImpl<TransportAdapterImpl>( this, &TransportAdapterImpl::RetryConnection))); sync_primitives::AutoLock locker(retry_timer_pool_lock_); retry_timer_pool_.push(std::make_pair(retry_timer, device_handle)); retry_timer->Start(get_settings().cloud_app_retry_timeout(), timer::kSingleShot); } else if (OK == err) { ConnectionStatusUpdated(device, ConnectionStatus::CONNECTED); } SDL_LOG_TRACE("exit with error: " << err); return err; } else { SDL_LOG_TRACE("exit with BAD_PARAM"); return BAD_PARAM; } } void TransportAdapterImpl::RetryConnection() { ClearCompletedTimers(); const DeviceUID device_id = GetNextRetryDevice(); if (device_id.empty()) { SDL_LOG_ERROR("Unable to find timer, ignoring RetryConnection request"); return; } ConnectDevice(device_id); } void TransportAdapterImpl::ClearCompletedTimers() { // Cleanup any retry timers which have completed execution sync_primitives::AutoLock locker(completed_timer_pool_lock_); while (!completed_timer_pool_.empty()) { auto timer_entry = completed_timer_pool_.front(); if (timer_entry.first->is_completed()) { completed_timer_pool_.pop(); } } } DeviceUID TransportAdapterImpl::GetNextRetryDevice() { sync_primitives::AutoLock retry_locker(retry_timer_pool_lock_); if (retry_timer_pool_.empty()) { return std::string(); } auto timer_entry = retry_timer_pool_.front(); retry_timer_pool_.pop(); // Store reference for cleanup later sync_primitives::AutoLock completed_locker(completed_timer_pool_lock_); completed_timer_pool_.push(timer_entry); return timer_entry.second; } ConnectionStatus TransportAdapterImpl::GetConnectionStatus( const DeviceUID& device_handle) const { DeviceSptr device = FindDevice(device_handle); return device.use_count() == 0 ? ConnectionStatus::INVALID : device->connection_status(); } void TransportAdapterImpl::ConnectionStatusUpdated(DeviceSptr device, ConnectionStatus status) { device->set_connection_status(status); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnConnectionStatusUpdated(this); } } TransportAdapter::Error TransportAdapterImpl::Disconnect( const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", device_id: " << &device_id); if (!initialised_) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } ConnectionSPtr connection = FindEstablishedConnection(device_id, app_handle); if (connection) { TransportAdapter::Error err = connection->Disconnect(); SDL_LOG_TRACE("exit with error: " << err); return err; } else { SDL_LOG_TRACE("exit with BAD_PARAM"); return BAD_PARAM; } } TransportAdapter::Error TransportAdapterImpl::DisconnectDevice( const DeviceUID& device_id) { SDL_LOG_TRACE("enter. device_id: " << &device_id); if (!initialised_) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } Error error = OK; DeviceSptr device = FindDevice(device_id); if (!device) { SDL_LOG_WARN("Device with id: " << device_id << " Not found"); return BAD_PARAM; } ConnectionStatusUpdated(device, ConnectionStatus::CLOSING); std::vector<ConnectionInfo> to_disconnect; connections_lock_.AcquireForReading(); for (ConnectionMap::const_iterator i = connections_.begin(); i != connections_.end(); ++i) { ConnectionInfo info = i->second; if (info.device_id == device_id && info.state != ConnectionInfo::FINALISING) { to_disconnect.push_back(info); } } connections_lock_.Release(); for (std::vector<ConnectionInfo>::const_iterator j = to_disconnect.begin(); j != to_disconnect.end(); ++j) { ConnectionInfo info = *j; if (OK != info.connection->Disconnect()) { error = FAIL; SDL_LOG_ERROR("Error on disconnect " << error); } } return error; } TransportAdapter::Error TransportAdapterImpl::SendData( const DeviceUID& device_id, const ApplicationHandle& app_handle, const ::protocol_handler::RawMessagePtr data) { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle << ", data: " << data); if (!initialised_) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } ConnectionSPtr connection = FindEstablishedConnection(device_id, app_handle); if (connection) { TransportAdapter::Error err = connection->SendData(data); SDL_LOG_TRACE("exit with error: " << err); return err; } else { SDL_LOG_TRACE("exit with BAD_PARAM"); return BAD_PARAM; } } TransportAdapter::Error TransportAdapterImpl::ChangeClientListening( TransportAction required_change) { SDL_LOG_AUTO_TRACE(); if (client_connection_listener_ == 0) { SDL_LOG_TRACE("exit with NOT_SUPPORTED"); return NOT_SUPPORTED; } if (!client_connection_listener_->IsInitialised()) { SDL_LOG_TRACE("exit with BAD_STATE"); return BAD_STATE; } TransportAdapter::Error err = TransportAdapter::Error::UNKNOWN; switch (required_change) { case transport_manager::TransportAction::kVisibilityOn: err = client_connection_listener_->StartListening(); break; case transport_manager::TransportAction::kListeningOn: err = client_connection_listener_->ResumeListening(); break; case transport_manager::TransportAction::kListeningOff: err = client_connection_listener_->SuspendListening(); { sync_primitives::AutoLock locker(devices_mutex_); for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); ++it) { it->second->Stop(); } } break; case transport_manager::TransportAction::kVisibilityOff: err = client_connection_listener_->StopListening(); { sync_primitives::AutoLock locker(devices_mutex_); for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); ++it) { it->second->Stop(); } } break; default: NOTREACHED(); } SDL_LOG_TRACE("Exit with error: " << err); return err; } DeviceList TransportAdapterImpl::GetDeviceList() const { SDL_LOG_AUTO_TRACE(); DeviceList devices; sync_primitives::AutoLock locker(devices_mutex_); for (DeviceMap::const_iterator it = devices_.begin(); it != devices_.end(); ++it) { devices.push_back(it->first); } SDL_LOG_TRACE("exit with DeviceList. It's' size = " << devices.size()); return devices; } DeviceSptr TransportAdapterImpl::GetWebEngineDevice() const { #ifndef WEBSOCKET_SERVER_TRANSPORT_SUPPORT SDL_LOG_TRACE("Web engine support is disabled. Device does not exist"); return DeviceSptr(); #else SDL_LOG_AUTO_TRACE(); sync_primitives::AutoLock locker(devices_mutex_); auto web_engine_device = std::find_if(devices_.begin(), devices_.end(), [](const std::pair<DeviceUID, DeviceSptr> device) { return webengine_constants::kWebEngineDeviceName == device.second->name(); }); if (devices_.end() != web_engine_device) { return web_engine_device->second; } SDL_LOG_ERROR("WebEngine device not found!"); return std::make_shared<transport_adapter::WebSocketDevice>("", ""); #endif } DeviceSptr TransportAdapterImpl::AddDevice(DeviceSptr device) { SDL_LOG_AUTO_TRACE(); SDL_LOG_TRACE("enter. device: " << device); DeviceSptr existing_device; bool same_device_found = false; devices_mutex_.Acquire(); for (DeviceMap::const_iterator i = devices_.begin(); i != devices_.end(); ++i) { existing_device = i->second; if (device->IsSameAs(existing_device.get())) { same_device_found = true; SDL_LOG_DEBUG("Device " << device << " already exists"); break; } } if (!same_device_found) { devices_[device->unique_device_id()] = device; } devices_mutex_.Release(); if (same_device_found) { SDL_LOG_TRACE("Exit with TRUE. Condition: same_device_found"); return existing_device; } else { device->set_connection_status(ConnectionStatus::PENDING); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDeviceListUpdated(this); } if (ToBeAutoConnected(device)) { ConnectDevice(device); } SDL_LOG_TRACE("exit with DeviceSptr " << device); return device; } } void TransportAdapterImpl::SearchDeviceDone(const DeviceVector& devices) { SDL_LOG_TRACE("enter. devices: " << &devices); DeviceMap new_devices; for (DeviceVector::const_iterator it = devices.begin(); it != devices.end(); ++it) { DeviceSptr device = *it; bool device_found = false; devices_mutex_.Acquire(); for (DeviceMap::iterator iter = devices_.begin(); iter != devices_.end(); ++iter) { DeviceSptr existing_device = iter->second; if (device->IsSameAs(existing_device.get())) { existing_device->set_keep_on_disconnect(true); device_found = true; SDL_LOG_DEBUG("device found. DeviceSptr" << iter->second); break; } } devices_mutex_.Release(); if (!device_found) { SDL_LOG_INFO("Adding new device " << device->unique_device_id() << " (\"" << device->name() << "\")"); } device->set_keep_on_disconnect(true); new_devices[device->unique_device_id()] = device; } connections_lock_.AcquireForReading(); std::set<DeviceUID> connected_devices; for (ConnectionMap::const_iterator it = connections_.begin(); it != connections_.end(); ++it) { const ConnectionInfo& info = it->second; if (info.state != ConnectionInfo::FINALISING) { connected_devices.insert(info.device_id); } } connections_lock_.Release(); DeviceMap all_devices = new_devices; devices_mutex_.Acquire(); for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); ++it) { DeviceSptr existing_device = it->second; if (all_devices.end() == all_devices.find(it->first)) { if (connected_devices.end() != connected_devices.find(it->first)) { existing_device->set_keep_on_disconnect(false); all_devices[it->first] = existing_device; } } } devices_ = all_devices; devices_mutex_.Release(); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDeviceListUpdated(this); (*it)->OnSearchDeviceDone(this); } for (DeviceMap::iterator it = new_devices.begin(); it != new_devices.end(); ++it) { DeviceSptr device = it->second; if (ToBeAutoConnected(device)) { ConnectDevice(device); } } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::ApplicationListUpdated( const DeviceUID& device_handle) { // default implementation does nothing // and is reimplemented in MME transport adapter only } void TransportAdapterImpl::FindNewApplicationsRequest() { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator i = listeners_.begin(); i != listeners_.end(); ++i) { TransportAdapterListener* listener = *i; listener->OnFindNewApplicationsRequest(this); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::SearchDeviceFailed(const SearchDeviceError& error) { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnSearchDeviceFailed(this, error); } SDL_LOG_TRACE("exit"); } bool TransportAdapterImpl::IsSearchDevicesSupported() const { SDL_LOG_AUTO_TRACE(); return device_scanner_ != 0; } bool TransportAdapterImpl::IsServerOriginatedConnectSupported() const { SDL_LOG_AUTO_TRACE(); return server_connection_factory_ != 0; } bool TransportAdapterImpl::IsClientOriginatedConnectSupported() const { SDL_LOG_AUTO_TRACE(); return client_connection_listener_ != 0; } void TransportAdapterImpl::ConnectionCreated( ConnectionSPtr connection, const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); SDL_LOG_TRACE("enter connection:" << connection << ", device_id: " << &device_id << ", app_handle: " << &app_handle); connections_lock_.AcquireForReading(); ConnectionInfo& info = connections_[std::make_pair(device_id, app_handle)]; info.app_handle = app_handle; info.device_id = device_id; info.connection = connection; info.state = ConnectionInfo::NEW; connections_lock_.Release(); } void TransportAdapterImpl::DeviceDisconnected( const DeviceUID& device_handle, const DisconnectDeviceError& error) { SDL_LOG_AUTO_TRACE(); const DeviceUID device_uid = device_handle; SDL_LOG_TRACE("enter. device_handle: " << &device_uid << ", error: " << &error); ApplicationList app_list = GetApplicationList(device_uid); for (ApplicationList::const_iterator i = app_list.begin(); i != app_list.end(); ++i) { ApplicationHandle app_handle = *i; for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { TransportAdapterListener* listener = *it; listener->OnUnexpectedDisconnect( this, device_uid, app_handle, CommunicationError()); } } for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { TransportAdapterListener* listener = *it; listener->OnDisconnectDeviceDone(this, device_uid); } for (ApplicationList::const_iterator i = app_list.begin(); i != app_list.end(); ++i) { ApplicationHandle app_handle = *i; RemoveConnection(device_uid, app_handle); } RemoveDevice(device_uid); SDL_LOG_TRACE("exit"); } bool TransportAdapterImpl::IsSingleApplication( const DeviceUID& device_uid, const ApplicationHandle& app_uid) { SDL_LOG_AUTO_TRACE(); sync_primitives::AutoReadLock locker(connections_lock_); for (ConnectionMap::const_iterator it = connections_.begin(); it != connections_.end(); ++it) { const DeviceUID& current_device_id = it->first.first; const ApplicationHandle& current_app_handle = it->first.second; if (current_device_id == device_uid && current_app_handle != app_uid) { SDL_LOG_DEBUG( "break. Condition: current_device_id == device_id && " "current_app_handle != app_handle"); return false; } } return true; } void TransportAdapterImpl::DisconnectDone(const DeviceUID& device_handle, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); const DeviceUID device_uid = device_handle; const ApplicationHandle app_uid = app_handle; SDL_LOG_TRACE("enter. device_id: " << &device_uid << ", app_handle: " << &app_uid); DeviceSptr device = FindDevice(device_handle); if (!device) { SDL_LOG_WARN("Device: uid " << &device_uid << " not found"); return; } bool device_disconnected = ToBeAutoDisconnected(device) && IsSingleApplication(device_uid, app_uid); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { TransportAdapterListener* listener = *it; listener->OnDisconnectDone(this, device_uid, app_uid); if (device_disconnected) { listener->OnDisconnectDeviceDone(this, device_uid); } } RemoveConnection(device_uid, app_uid); if (device_disconnected) { SDL_LOG_DEBUG("Removing device..."); RemoveDevice(device_uid); } Store(); SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::DataReceiveDone( const DeviceUID& device_id, const ApplicationHandle& app_handle, ::protocol_handler::RawMessagePtr message) { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle << ", message: " << message); #ifdef TELEMETRY_MONITOR if (metric_observer_) { metric_observer_->StartRawMsg(message.get()); } #endif // TELEMETRY_MONITOR for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDataReceiveDone(this, device_id, app_handle, message); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::DataReceiveFailed( const DeviceUID& device_id, const ApplicationHandle& app_handle, const DataReceiveError& error) { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDataReceiveFailed(this, device_id, app_handle, error); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::DataSendDone( const DeviceUID& device_id, const ApplicationHandle& app_handle, ::protocol_handler::RawMessagePtr message) { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDataSendDone(this, device_id, app_handle, message); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::DataSendFailed( const DeviceUID& device_id, const ApplicationHandle& app_handle, ::protocol_handler::RawMessagePtr message, const DataSendError& error) { SDL_LOG_TRACE("enter"); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnDataSendFailed(this, device_id, app_handle, message, error); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::TransportConfigUpdated( const TransportConfig& new_config) { SDL_LOG_AUTO_TRACE(); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnTransportConfigUpdated(this); } } void TransportAdapterImpl::DoTransportSwitch() const { SDL_LOG_AUTO_TRACE(); std::for_each( listeners_.begin(), listeners_.end(), std::bind2nd( std::mem_fun(&TransportAdapterListener::OnTransportSwitchRequested), this)); } void TransportAdapterImpl::DeviceSwitched(const DeviceUID& device_handle) { SDL_LOG_DEBUG("Switching is not implemented for that adapter type " << GetConnectionType().c_str()); UNUSED(device_handle); } ConnectionSPtr TransportAdapterImpl::FindPendingConnection( const DeviceUID& device_id, const ApplicationHandle& app_handle) const { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle); ConnectionSPtr connection; connections_lock_.AcquireForReading(); ConnectionMap::const_iterator it = connections_.find(std::make_pair(device_id, app_handle)); if (it != connections_.end()) { const ConnectionInfo& info = it->second; if (info.state == ConnectionInfo::PENDING) { connection = info.connection; } } connections_lock_.Release(); SDL_LOG_TRACE("exit with Connection: " << connection); return connection; } DeviceSptr TransportAdapterImpl::FindDevice(const DeviceUID& device_id) const { SDL_LOG_TRACE("enter. device_id: " << &device_id); DeviceSptr ret; sync_primitives::AutoLock locker(devices_mutex_); SDL_LOG_DEBUG("devices_.size() = " << devices_.size()); DeviceMap::const_iterator it = devices_.find(device_id); if (it != devices_.end()) { ret = it->second; } else { SDL_LOG_WARN("Device " << device_id << " not found."); } SDL_LOG_TRACE("exit with DeviceSptr: " << ret); return ret; } void TransportAdapterImpl::ConnectPending(const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); connections_lock_.AcquireForWriting(); ConnectionMap::iterator it_conn = connections_.find(std::make_pair(device_id, app_handle)); if (it_conn != connections_.end()) { ConnectionInfo& info = it_conn->second; info.state = ConnectionInfo::PENDING; } connections_lock_.Release(); DeviceSptr device = FindDevice(device_id); if (device.use_count() == 0) { SDL_LOG_ERROR( "Unable to find device, cannot set connection pending status"); return; } else { device->set_connection_status(ConnectionStatus::PENDING); } for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnConnectPending(this, device_id, app_handle); } } void TransportAdapterImpl::ConnectDone(const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle); connections_lock_.AcquireForReading(); ConnectionMap::iterator it_conn = connections_.find(std::make_pair(device_id, app_handle)); if (it_conn != connections_.end()) { ConnectionInfo& info = it_conn->second; info.state = ConnectionInfo::ESTABLISHED; } connections_lock_.Release(); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnConnectDone(this, device_id, app_handle); } Store(); SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::ConnectFailed(const DeviceUID& device_handle, const ApplicationHandle& app_handle, const ConnectError& error) { const DeviceUID device_uid = device_handle; const ApplicationHandle app_uid = app_handle; SDL_LOG_TRACE("enter. device_id: " << &device_uid << ", app_handle: " << &app_uid << ", error: " << &error); RemoveConnection(device_uid, app_uid); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnConnectFailed(this, device_uid, app_uid, error); } SDL_LOG_TRACE("exit"); } void TransportAdapterImpl::RemoveFinalizedConnection( const DeviceUID& device_handle, const ApplicationHandle& app_handle) { const DeviceUID device_uid = device_handle; SDL_LOG_AUTO_TRACE(); { connections_lock_.AcquireForWriting(); auto it_conn = connections_.find(std::make_pair(device_uid, app_handle)); if (connections_.end() == it_conn) { SDL_LOG_WARN("Device_id: " << &device_uid << ", app_handle: " << &app_handle << " connection not found"); connections_lock_.Release(); return; } const ConnectionInfo& info = it_conn->second; if (ConnectionInfo::FINALISING != info.state) { SDL_LOG_WARN("Device_id: " << &device_uid << ", app_handle: " << &app_handle << " connection not finalized"); connections_lock_.Release(); return; } // By copying the info.connection shared pointer into this local variable, // we can delay the connection's destructor until after // connections_lock_.Release. SDL_LOG_DEBUG( "RemoveFinalizedConnection copying connection with Device_id: " << &device_uid << ", app_handle: " << &app_handle); ConnectionSPtr connection = info.connection; connections_.erase(it_conn); connections_lock_.Release(); SDL_LOG_DEBUG("RemoveFinalizedConnection Connections Lock Released"); } DeviceSptr device = FindDevice(device_handle); if (!device) { SDL_LOG_WARN("Device: uid " << &device_uid << " not found"); return; } if (ToBeAutoDisconnected(device) && IsSingleApplication(device_handle, app_handle)) { RemoveDevice(device_uid); } } void TransportAdapterImpl::RemoveConnection( const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); ConnectionSPtr connection; connections_lock_.AcquireForWriting(); ConnectionMap::const_iterator it = connections_.find(std::make_pair(device_id, app_handle)); if (it != connections_.end()) { // By copying the connection from the map to this shared pointer, // we can erase the object from the map without triggering the destructor SDL_LOG_DEBUG("Copying connection with Device_id: " << &device_id << ", app_handle: " << &app_handle); connection = it->second.connection; connections_.erase(it); } connections_lock_.Release(); SDL_LOG_DEBUG("Connections Lock Released"); // And now, "connection" goes out of scope, triggering the destructor outside // of the "connections_lock_" } void TransportAdapterImpl::AddListener(TransportAdapterListener* listener) { SDL_LOG_TRACE("enter"); listeners_.push_back(listener); SDL_LOG_TRACE("exit"); } ApplicationList TransportAdapterImpl::GetApplicationList( const DeviceUID& device_id) const { SDL_LOG_TRACE("enter. device_id: " << &device_id); DeviceSptr device = FindDevice(device_id); if (device.use_count() != 0) { ApplicationList lst = device->GetApplicationList(); SDL_LOG_TRACE("exit with ApplicationList. It's size = " << lst.size() << " Condition: device.use_count() != 0"); return lst; } SDL_LOG_TRACE( "exit with empty ApplicationList. Condition: NOT " "device.use_count() != 0"); return ApplicationList(); } void TransportAdapterImpl::ConnectionFinished( const DeviceUID& device_id, const ApplicationHandle& app_handle) { SDL_LOG_AUTO_TRACE(); SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle); connections_lock_.AcquireForReading(); ConnectionMap::iterator it = connections_.find(std::make_pair(device_id, app_handle)); if (it != connections_.end()) { ConnectionInfo& info = it->second; info.state = ConnectionInfo::FINALISING; } connections_lock_.Release(); } void TransportAdapterImpl::ConnectionAborted( const DeviceUID& device_id, const ApplicationHandle& app_handle, const CommunicationError& error) { SDL_LOG_AUTO_TRACE(); ConnectionFinished(device_id, app_handle); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { (*it)->OnUnexpectedDisconnect(this, device_id, app_handle, error); } } bool TransportAdapterImpl::IsInitialised() const { SDL_LOG_TRACE("enter"); if (!initialised_) { SDL_LOG_TRACE("exit with FALSE. Condition: !initialised_"); return false; } if (device_scanner_ && !device_scanner_->IsInitialised()) { SDL_LOG_TRACE( "exit with FALSE. Condition: device_scanner_ && " "!device_scanner_->IsInitialised()"); return false; } if (server_connection_factory_ && !server_connection_factory_->IsInitialised()) { SDL_LOG_TRACE( "exit with FALSE. Condition: server_connection_factory_ && " "!server_connection_factory_->IsInitialised()"); return false; } if (client_connection_listener_ && !client_connection_listener_->IsInitialised()) { SDL_LOG_TRACE( "exit with FALSE. Condition: client_connection_listener_ && " "!client_connection_listener_->IsInitialised()"); return false; } SDL_LOG_TRACE("exit with TRUE"); return true; } std::string TransportAdapterImpl::DeviceName(const DeviceUID& device_id) const { DeviceSptr device = FindDevice(device_id); if (device.use_count() != 0) { return device->name(); } else { return ""; } } void TransportAdapterImpl::StopDevice(const DeviceUID& device_id) const { SDL_LOG_AUTO_TRACE(); DeviceSptr device = FindDevice(device_id); if (device) { device->Stop(); } } std::string TransportAdapterImpl::GetConnectionType() const { return devicesType[GetDeviceType()]; } SwitchableDevices TransportAdapterImpl::GetSwitchableDevices() const { SDL_LOG_AUTO_TRACE(); SwitchableDevices devices; sync_primitives::AutoLock locker(devices_mutex_); for (DeviceMap::const_iterator it = devices_.begin(); it != devices_.end(); ++it) { const auto device_uid = it->first; const auto device = it->second; const auto transport_switch_id = device->transport_switch_id(); if (transport_switch_id.empty()) { SDL_LOG_DEBUG("Device is not suitable for switching: " << device_uid); continue; } SDL_LOG_DEBUG("Device is suitable for switching: " << device_uid); devices.insert(std::make_pair(device_uid, transport_switch_id)); } SDL_LOG_INFO("Found number of switchable devices: " << devices.size()); return devices; } #ifdef TELEMETRY_MONITOR void TransportAdapterImpl::SetTelemetryObserver(TMTelemetryObserver* observer) { metric_observer_ = observer; } #endif // TELEMETRY_MONITOR #ifdef TELEMETRY_MONITOR TMTelemetryObserver* TransportAdapterImpl::GetTelemetryObserver() { return metric_observer_; } #endif // TELEMETRY_MONITOR void TransportAdapterImpl::Store() const {} bool TransportAdapterImpl::Restore() { return true; } bool TransportAdapterImpl::ToBeAutoConnected(DeviceSptr device) const { return false; } bool TransportAdapterImpl::ToBeAutoDisconnected(DeviceSptr device) const { SDL_LOG_AUTO_TRACE(); return true; } ConnectionSPtr TransportAdapterImpl::FindEstablishedConnection( const DeviceUID& device_id, const ApplicationHandle& app_handle) const { SDL_LOG_TRACE("enter. device_id: " << &device_id << ", app_handle: " << &app_handle); ConnectionSPtr connection; connections_lock_.AcquireForReading(); ConnectionMap::const_iterator it = connections_.find(std::make_pair(device_id, app_handle)); if (it != connections_.end()) { const ConnectionInfo& info = it->second; if (info.state == ConnectionInfo::ESTABLISHED) { connection = info.connection; } } connections_lock_.Release(); SDL_LOG_TRACE("exit with Connection: " << connection); return connection; } TransportAdapter::Error TransportAdapterImpl::ConnectDevice(DeviceSptr device) { SDL_LOG_TRACE("enter. device: " << device); DeviceUID device_id = device->unique_device_id(); ApplicationList app_list = device->GetApplicationList(); SDL_LOG_INFO("Device " << device->name() << " has " << app_list.size() << " applications."); bool errors_occurred = false; for (ApplicationList::iterator it = app_list.begin(); it != app_list.end(); ++it) { const ApplicationHandle app_handle = *it; SDL_LOG_DEBUG("Attempt to connect device " << device_id << ", channel " << app_handle); const Error error = Connect(device_id, app_handle); switch (error) { case OK: SDL_LOG_DEBUG("error = OK"); break; case ALREADY_EXISTS: SDL_LOG_DEBUG("error = ALREADY_EXISTS"); break; default: SDL_LOG_ERROR("Connect to device " << device_id << ", channel " << app_handle << " failed with error " << error); errors_occurred = true; SDL_LOG_DEBUG("switch (error), default case"); break; } } if (errors_occurred) { SDL_LOG_TRACE("exit with error:FAIL"); return FAIL; } else { SDL_LOG_TRACE("exit with error:OK"); return OK; } } void TransportAdapterImpl::RunAppOnDevice(const DeviceUID& device_uid, const std::string& bundle_id) { SDL_LOG_AUTO_TRACE(); DeviceSptr device = FindDevice(device_uid); if (!device) { SDL_LOG_WARN("Device with id: " << device_uid << " Not found" << "withing list of connected deviced"); return; } device->LaunchApp(bundle_id); } void TransportAdapterImpl::RemoveDevice(const DeviceUID& device_handle) { SDL_LOG_AUTO_TRACE(); SDL_LOG_DEBUG("Remove Device_handle: " << &device_handle); sync_primitives::AutoLock locker(devices_mutex_); DeviceMap::iterator i = devices_.find(device_handle); if (i != devices_.end()) { DeviceSptr device = i->second; bool is_cloud_device = (GetDeviceType() == DeviceType::CLOUD_WEBSOCKET); if (!device->keep_on_disconnect() || is_cloud_device) { devices_.erase(i); for (TransportAdapterListenerList::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { TransportAdapterListener* listener = *it; listener->OnDeviceListUpdated(this); } } } } } // namespace transport_adapter } // namespace transport_manager
42,601
13,270
#include "inc/Core/Common/InstructionUtils.h" #include "inc/Core/Common.h" #ifndef _MSC_VER void cpuid(int info[4], int InfoType) { __cpuid_count(InfoType, 0, info[0], info[1], info[2], info[3]); } #endif namespace SPTAG { namespace COMMON { const InstructionSet::InstructionSet_Internal InstructionSet::CPU_Rep; bool InstructionSet::SSE(void) { return CPU_Rep.HW_SSE; } bool InstructionSet::SSE2(void) { return CPU_Rep.HW_SSE2; } bool InstructionSet::AVX(void) { return CPU_Rep.HW_AVX; } bool InstructionSet::AVX2(void) { return CPU_Rep.HW_AVX2; } void InstructionSet::PrintInstructionSet(void) { if (CPU_Rep.HW_AVX2) LOG(Helper::LogLevel::LL_Info, "Using AVX2 InstructionSet!\n"); else if (CPU_Rep.HW_AVX) LOG(Helper::LogLevel::LL_Info, "Using AVX InstructionSet!\n"); else if (CPU_Rep.HW_SSE2) LOG(Helper::LogLevel::LL_Info, "Using SSE2 InstructionSet!\n"); else if (CPU_Rep.HW_SSE) LOG(Helper::LogLevel::LL_Info, "Using SSE InstructionSet!\n"); else LOG(Helper::LogLevel::LL_Info, "Using NONE InstructionSet!\n"); } // from https://stackoverflow.com/a/7495023/5053214 InstructionSet::InstructionSet_Internal::InstructionSet_Internal() : HW_SSE{ false }, HW_SSE2{ false }, HW_AVX{ false }, HW_AVX2{ false } { int info[4]; cpuid(info, 0); int nIds = info[0]; // Detect Features if (nIds >= 0x00000001) { cpuid(info, 0x00000001); HW_SSE = (info[3] & ((int)1 << 25)) != 0; HW_SSE2 = (info[3] & ((int)1 << 26)) != 0; HW_AVX = (info[2] & ((int)1 << 28)) != 0; } if (nIds >= 0x00000007) { cpuid(info, 0x00000007); HW_AVX2 = (info[1] & ((int)1 << 5)) != 0; } if (HW_AVX2) LOG(Helper::LogLevel::LL_Info, "Using AVX2 InstructionSet!\n"); else if (HW_AVX) LOG(Helper::LogLevel::LL_Info, "Using AVX InstructionSet!\n"); else if (HW_SSE2) LOG(Helper::LogLevel::LL_Info, "Using SSE2 InstructionSet!\n"); else if (HW_SSE) LOG(Helper::LogLevel::LL_Info, "Using SSE InstructionSet!\n"); else LOG(Helper::LogLevel::LL_Info, "Using NONE InstructionSet!\n"); } } }
2,593
931
class Solution { public: string multiply(string num1, string num2) { vector<string> partial_result; string digit = ""; for_each(num2.rbegin(), num2.rend(), [&num1, &digit, &partial_result](const auto ch2) { const auto op2 = ch2 - '0'; auto carry = 0; string val = digit; for_each(num1.rbegin(), num1.rend(), [&carry, &val, &op2](const auto ch1){ const auto op1 = ch1 - '0'; const auto digit_result = op1 * op2 + carry; val = val + (char)(digit_result % 10 + '0'); carry = digit_result / 10; }); if (carry > 0) { val = val + (char)(carry + '0'); } partial_result.push_back(val); digit += "0"; }); string ret = partial_result[partial_result.size() - 1]; for (int i = partial_result.size() - 2; i >= 0; --i) { auto j = 0; auto carry = 0; while (j < ret.length() && j < partial_result[i].length()) { auto op1 = ret[j] - '0'; auto op2 = partial_result[i][j] - '0'; auto val = op1 + op2 + carry; carry = val / 10; ret[j++] = (char)(val % 10 + '0'); } while (carry > 0) { if (j == ret.length()) { ret.push_back((char)(carry + '0')); break; } else { auto op = ret[j] - '0'; auto val = op + carry; ret[j] = (char)(val % 10 + '0'); carry = val / 10; } ++j; } } reverse(ret.begin(), ret.end()); for (auto i = 0; i <= ret.length(); ++i) { if (i == ret.length()) { ret = "0"; break; } if (ret[i] != '0') { break; } } return ret; } };
2,099
631
#include "NL_GameManager.h" #include "NL_RenderingEngine.h" #include "NL_ScriptingEngine.h" #include "NL_ThreadLocal.h" #include "NL_GameObject.h" #include "NL_EngineServices.h" #include "NL_SharedData.h" #include "NL_IWindowManager.h" #include <fstream> namespace NLE { namespace GAME { GameManager::GameManager( EngineServices eServices, IWindowManagerSP windowManager, IO::IFileIOManagerSP file, SERIALIZATION::ISerializerSP serializer, GRAPHICS::IRenderingEngineSP renderingEngine, SCRIPT::IScriptingEngineSP scriptingEngine ) : _eServices(eServices), _windowManager(windowManager), _file(file), _serializer(serializer), _renderingEngine(renderingEngine), _scriptingEngine(scriptingEngine) { _execStatus = ExecStatus::CONTINUE; newGame(); /* _commandBuffer.addFunction(COMMAND::RESTART_GAME, [&](COMMAND::Data data) { _execStatus = RESTART; }); _commandBuffer.addFunction(COMMAND::ADD_OBJECT, [&](COMMAND::Data data) { _currentScene->addObject(new GameObject()); }); _commandBuffer.addFunction(COMMAND::UPDATE_OBJECT, [&](COMMAND::Data data) { _currentScene->addObject(data.gameObject); }); _commandBuffer.addFunction(COMMAND::LOAD_OBJECT, [&](COMMAND::Data data) { std::wstring path = TLS::strConverter.local().from_bytes(data.name); _file->readAsync(path + L".nleobject", [=](std::vector<char>* data) { GameObject* object = _serializer.deserialize<GameObject>(data); delete data; COMMAND::Data updateData; updateData.gameObject = object; _commandBuffer.queueCommand(COMMAND::UPDATE_OBJECT, updateData); }, [=]() { eServices.console->push(CONSOLE::ERR, L"Failed to load game object " + path); }); }); _commandBuffer.addFunction(COMMAND::SAVE_OBJECT, [&](COMMAND::Data data) { auto* objectData = _serializer.serialize<GameObject>(data.gameObject); _file->writeAsync(data.scene->getName() + L".nleobject", objectData, [=](std::vector<char>* serializedData) { delete serializedData; eServices.console->push(CONSOLE::STANDARD, L"Successfully saved game object " + data.gameObject->getName()); }, [=](std::vector<char>* serializedData) { delete serializedData; eServices.console->push(CONSOLE::ERR, L"Failed to save game object " + data.gameObject->getName()); }); });*/ } GameManager::~GameManager() { } void GameManager::update(SystemServices& sServices, double deltaT) { NLE::TLS::PerformanceTimer::reference timer = NLE::TLS::performanceTimer.local(); timer.deltaT(); auto& ex = TLS::scriptExecutor.local(); ex.executeContextScript(_game->getScriptingContext(), SCRIPT::ON_UPDATE); ex.executeContextScript(_currentScene->getScriptingContext(), SCRIPT::ON_UPDATE); DATA::SharedData& data = _eServices.data->getData(); data.sysExecutionTimes.set(GAME_MANAGER, timer.deltaT()); } bool GameManager::hasUnsavedChanges() { return true; } void GameManager::newGame() { /*_game = std::make_unique<Game>(_eServices.console); newScene(); _eServices.console->push(CONSOLE::STANDARD, "Starting new game.");*/ } void GameManager::newScene() { /*_currentScene = std::make_unique<Scene>(); _eServices.console->push(CONSOLE::STANDARD, "Starting new scene.");*/ } void GameManager::loadGame(std::string path) { /*std::vector<char>* data = _file->read(path); if (data) { Game* game = _serializer->deserialize<Game>(data); delete data; _eServices.console->push(CONSOLE::STANDARD, "Successfully loaded game: " + path); updateGame(game); } else { _eServices.console->push(CONSOLE::ERR, "Failed to load game: " + path); }*/ } void GameManager::loadScene(std::string path) { /*std::vector<char>* data = _file->read(path); if (data) { Scene* scene = _serializer->deserialize<Scene>(data); delete data; _eServices.console->push(CONSOLE::STANDARD, "Successfully loaded scene: " + path); updateScene(scene); } else { _eServices.console->push(CONSOLE::ERR, "Failed to load scene: " + path); }*/ } void GameManager::loadSceneByName(std::string name) { /*auto scenePath = _game->getScenePath(name); if (scenePath.compare("") != 0) { loadScene(scenePath); } else { _eServices.console->push(CONSOLE::ERR, "Failed to find scene by name: " + name); }*/ } void GameManager::updateGame(Game* game) { /*game->attachConsole(_eServices.console); auto& ex = TLS::scriptExecutor.local(); ex.executeContextScript(_game->getScriptingContext(), SCRIPT::ON_EXIT); _game = std::unique_ptr<Game>(game); ex.executeContextScript(_game->getScriptingContext(), SCRIPT::ON_INIT); std::string initialSceneName = game->getInitialScene(); if (initialSceneName.compare("") != 0) { loadSceneByName(initialSceneName); } */ } void GameManager::updateScene(Scene* scene) { auto& ex = TLS::scriptExecutor.local(); ex.executeContextScript(_currentScene->getScriptingContext(), SCRIPT::ON_EXIT); _currentScene = std::unique_ptr<Scene>(scene); ex.executeContextScript(_currentScene->getScriptingContext(), SCRIPT::ON_INIT); } void GameManager::saveGame(std::string name) { /*if (!name.empty()) { _game->setName(name); } auto* gameData = _serializer->serialize<Game>(_game.get()); if (_file->write(_game->getName() + ".nlegame", gameData)) { delete gameData; _eServices.console->push(CONSOLE::STANDARD, "Successfully saved game: " + _game->getName()); } else { delete gameData; _eServices.console->push(CONSOLE::ERR, "Failed to save game: " + _game->getName()); }*/ } void GameManager::saveScene(std::string name) { /*if (!name.empty()) { _currentScene->setName(name); } auto* sceneData = _serializer->serialize<Scene>(_currentScene.get()); if (_file->write(_currentScene->getName() + ".nlescene", sceneData)) { delete sceneData; _eServices.console->push(CONSOLE::STANDARD, "Successfully saved scene: " + _currentScene->getName()); } else { delete sceneData; _eServices.console->push(CONSOLE::ERR, "Failed to save scene: " + _currentScene->getName()); }*/ } void GameManager::quitGame() { auto& ex = TLS::scriptExecutor.local(); ex.executeContextScript(_currentScene->getScriptingContext(), SCRIPT::ON_EXIT); ex.executeContextScript(_game->getScriptingContext(), SCRIPT::ON_EXIT); _execStatus = TERMINATE; } ExecStatus GameManager::getExecutionStatus() { return _execStatus; } Game& GameManager::getGame() { return *_game; } Scene& GameManager::getCurrentScene() { return *_currentScene; } } }
6,771
2,704
#include <iostream> #include "Map.h" #include <vector> #include <stack> using namespace std; /* Quick instruction: If you want to see the third illustation being validated, the second one should be fixed. To do so, just remove the comment from line 88 (i.e. establish the brazil --> north africa connection). */ int main() { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ valid Map illustration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// Map *validMap = new Map(); //create the South America continent Continent *southAmerica = validMap->createContinent("South America", 10); Territory *venzuela = new Territory("Venzuela", southAmerica); Territory *brazil = new Territory("Brazil", southAmerica); Territory *argentina = new Territory("Argentina", southAmerica); Territory *peru = new Territory("Peru", southAmerica); validMap->insertAndConnectTwoTerritories(*venzuela, *brazil); // venzuela --> brazil validMap->insertAndConnectTwoTerritories(*argentina, *peru); // argentina --> peru validMap->connectTwoNodes(validMap->getV()[0], validMap->getV().end()[-1]); //venzuela --> peru validMap->connectTwoNodes(validMap->getV().end()[-1], validMap->getV()[1]); //peru --> brazil //create the Africa continent Continent *africa = validMap->createContinent("Africa", 10); Territory *northAfrica = new Territory("North Africa", africa); Territory *egypt = new Territory("Egypt", africa); Territory *eastAfrica = new Territory("East Africa", africa); Territory *congo = new Territory("Congo", africa); Territory *southAfrica = new Territory("South Africa", africa); Territory *mdagascar = new Territory("Mdagascar", africa); validMap->insertAndConnectTwoTerritories(*northAfrica, *egypt); //north africa --> egypt validMap->insertAndConnectTwoTerritories(*eastAfrica, *congo); //east africa --> congo validMap->insertAndConnectTwoTerritories(*southAfrica, *mdagascar); //south africa --> mdagascar validMap->connectTwoNodes(validMap->getV()[4], validMap->getV()[7]); //north africa --> congo validMap->connectTwoNodes(validMap->getV()[7], validMap->getV().end()[-2]); //congo --> south africa validMap->connectTwoNodes(validMap->getV()[5], validMap->getV()[6]); //egypt --> east africa //connect between south america and africa validMap->connectTwoNodes(validMap->getV()[1], validMap->getV()[4]); //brazil --> north africa // for(Node* territory : validMap->getV()){ // cout<<territory->getData().getTerritoryName() + " belongs to " + territory->getData().getContinent()->getContinentName() // + " has the following edges:"<<endl; // for(string edge : territory->getE()){ // cout<<edge<<"\t"; // } // cout<<endl; // } validMap->validate(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ invalid Map illustration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //Unconnected graph Map *invalidMap = new Map(); //create the South America continent Continent *southAmericaInvalid = invalidMap->createContinent("South America", 10); Territory *venzuelaInvalid = new Territory("Venzuela", southAmericaInvalid); Territory *brazilInvalid = new Territory("Brazil", southAmericaInvalid); Territory *argentinaInvalid = new Territory("Argentina", southAmericaInvalid); Territory *peruInvalid = new Territory("Peru", southAmericaInvalid); invalidMap->insertAndConnectTwoTerritories(*venzuelaInvalid, *brazilInvalid); // venzuela --> brazil invalidMap->insertAndConnectTwoTerritories(*argentinaInvalid, *peruInvalid); // argentina --> peru invalidMap->connectTwoNodes(invalidMap->getV()[0], invalidMap->getV().end()[-1]); //venzuela --> peru invalidMap->connectTwoNodes(invalidMap->getV().end()[-1], invalidMap->getV()[1]); //peru --> brazil //create the Africa continent Continent *africaInvalid = invalidMap->createContinent("Africa", 10); Territory *northAfricaInvalid = new Territory("North Africa", africaInvalid); Territory *egyptInvalid = new Territory("Egypt", africaInvalid); Territory *eastAfricaInvalid = new Territory("East Africa", africaInvalid); Territory *congoInvalid = new Territory("Congo", africaInvalid); Territory *southAfricaInvalid = new Territory("South Africa", africaInvalid); Territory *mdagascarInvalid = new Territory("Mdagascar", africaInvalid); invalidMap->insertAndConnectTwoTerritories(*northAfricaInvalid, *egyptInvalid); //north africa --> egypt invalidMap->insertAndConnectTwoTerritories(*eastAfricaInvalid, *congoInvalid); //east africa --> congo invalidMap->insertAndConnectTwoTerritories(*southAfricaInvalid, *mdagascarInvalid); //south africa --> mdagascar invalidMap->connectTwoNodes(invalidMap->getV()[4], invalidMap->getV()[7]); //north africa --> congo invalidMap->connectTwoNodes(invalidMap->getV()[7], invalidMap->getV().end()[-2]); //congo --> south africa invalidMap->connectTwoNodes(invalidMap->getV()[5], invalidMap->getV()[6]); //egypt --> east africa // No connection between south america and africa invalidMap->connectTwoNodes(invalidMap->getV()[1], invalidMap->getV()[4]); //brazil --> north africa // for(Node* territory : invalidMap->getV()){ // cout<<territory->getData().getTerritoryName() + " belongs to " + territory->getData().getContinent()->getContinentName() // + " has the following edges:"<<endl; // for(string edge : territory->getE()){ // cout<<edge<<"\t"; // } // cout<<endl; // } invalidMap->validate(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ invalid Map illustration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //Unconnected sub-graph Map *Invalid11Map = new Map(); //create the South America continent Continent *southAmericaInvalid1 = Invalid11Map->createContinent("South America", 10); Territory *venzuelaInvalid1 = new Territory("Venzuela", southAmericaInvalid1); Territory *brazilInvalid1 = new Territory("Brazil", southAmericaInvalid1); Territory *argentinaInvalid1 = new Territory("Argentina", southAmericaInvalid1); Territory *peruInvalid1 = new Territory("Peru", southAmericaInvalid1); Invalid11Map->insertAndConnectTwoTerritories(*venzuelaInvalid1, *brazilInvalid1); // venzuela --> brazil // Invalid11Map->insertATerritory(*venzuelaInvalid1); // Invalid11Map->insertATerritory(*brazilInvalid1); Invalid11Map->insertAndConnectTwoTerritories(*argentinaInvalid1, *peruInvalid1); // argentina --> peru Invalid11Map->connectTwoNodes(Invalid11Map->getV()[0], Invalid11Map->getV().end()[-1]); //venzuela --> peru Invalid11Map->connectTwoNodes(Invalid11Map->getV().end()[-1], Invalid11Map->getV()[1]); //peru --> brazil // for(Node* territory : Invalid11Map->getV()){ // cout<<territory->getData().getTerritoryName() + " belongs to " + territory->getData().getContinent()->getContinentName() // + " has the following edges:"<<endl; // for(string edge : territory->getE()){ // cout<<edge<<"\t"; // } // cout<<endl; // } Invalid11Map->validate(); delete validMap; validMap = nullptr; delete invalidMap; invalidMap = nullptr; delete Invalid11Map; Invalid11Map = nullptr; return 0; }
7,445
2,253
// // multimap.hpp // bit_array-test // // Created by Nick Fagan on 3/12/18. // #pragma once #include <unordered_map> #include <stdexcept> #include <vector> #include <cstdint> namespace util { template<typename K, typename V> class multimap; } template<typename K, typename V> class util::multimap { public: multimap() = default; ~multimap() = default; multimap(const util::multimap<K, V>& other); multimap(multimap&& rhs) noexcept; multimap& operator=(const multimap& other); multimap& operator=(multimap&& rhs) noexcept; auto find(const K& key) const; auto find(const V& key) const; auto endk() const; auto endv() const; std::vector<K> keys() const; std::vector<V> values() const; V at(const K& key) const; K at(const V& key) const; const V& ref_at(const K& key) const; const K& ref_at(const V& key) const; size_t erase(K key); size_t erase(V key); size_t size() const; bool contains(const K& key) const; bool contains(const V& key) const; void insert(K key, V value); private: std::unordered_map<K, V> m_kv; std::unordered_map<V, K> m_vk; }; // // impl // template<typename K, typename V> util::multimap<K, V>::multimap(const util::multimap<K, V>& rhs) : m_kv(rhs.m_kv), m_vk(rhs.m_vk) { // } template<typename K, typename V> util::multimap<K, V>& util::multimap<K, V>::operator=(const util::multimap<K, V>& rhs) { util::multimap<K, V> tmp(rhs); *this = std::move(tmp); return *this; } template<typename K, typename V> util::multimap<K, V>::multimap(util::multimap<K, V>&& rhs) noexcept : m_kv(std::move(rhs.m_kv)), m_vk(std::move(rhs.m_vk)) { // } template<typename K, typename V> util::multimap<K, V>& util::multimap<K, V>::operator=(util::multimap<K, V>&& rhs) noexcept { m_kv = std::move(rhs.m_kv); m_vk = std::move(rhs.m_vk); return *this; } template<typename K, typename V> V util::multimap<K, V>::at(const K& key) const { auto it = m_kv.find(key); if (it == m_kv.end()) { throw std::runtime_error("key does not exist."); } return it->second; } template<typename K, typename V> K util::multimap<K, V>::at(const V& key) const { auto it = m_vk.find(key); if (it == m_vk.end()) { throw std::runtime_error("key does not exist."); } return it->second; } template<typename K, typename V> const V& util::multimap<K, V>::ref_at(const K &key) const { const auto it = m_kv.find(key); if (it == m_kv.end()) { throw std::runtime_error("key does not exist."); } return it->second; } template<typename K, typename V> const K& util::multimap<K, V>::ref_at(const V &key) const { const auto it = m_vk.find(key); if (it == m_vk.end()) { throw std::runtime_error("key does not exist."); } return it->second; } template<typename K, typename V> void util::multimap<K, V>::insert(K key, V value) { auto ita = m_kv.find(key); auto itb = m_vk.find(value); if (ita != m_kv.end()) { m_vk.erase(ita->second); } if (itb != m_vk.end()) { m_kv.erase(itb->second); } m_kv[key] = value; m_vk[value] = key; } template<typename K, typename V> bool util::multimap<K, V>::contains(const K& key) const { return m_kv.find(key) != m_kv.end(); } template<typename K, typename V> bool util::multimap<K, V>::contains(const V& key) const { return m_vk.find(key) != m_vk.end(); } template<typename K, typename V> std::vector<K> util::multimap<K, V>::keys() const { std::vector<K> res; for (const auto& it : m_kv) { res.push_back(it.first); } return res; } template<typename K, typename V> std::vector<V> util::multimap<K, V>::values() const { std::vector<V> res; for (const auto& it : m_kv) { res.push_back(it.second); } return res; } template<typename K, typename V> size_t util::multimap<K, V>::erase(K key) { auto it = m_kv.find(key); if (it == m_kv.end()) { return 0; } m_vk.erase(it->second); m_kv.erase(key); return 1; } template<typename K, typename V> size_t util::multimap<K, V>::erase(V key) { auto it = m_vk.find(key); if (it == m_vk.end()) { return 0; } m_kv.erase(it->second); m_vk.erase(key); return 1; } template<typename K, typename V> size_t util::multimap<K, V>::size() const { return m_kv.size(); } template<typename K, typename V> auto util::multimap<K, V>::find(const K& key) const { return m_kv.find(key); } template<typename K, typename V> auto util::multimap<K, V>::find(const V& key) const { return m_vk.find(key); } template<typename K, typename V> auto util::multimap<K, V>::endk() const { return m_kv.end(); } template<typename K, typename V> auto util::multimap<K, V>::endv() const { return m_vk.end(); }
5,080
2,066
#include <catch2/catch.hpp> #include <rapidcheck/catch.h> #include <rapidcheck/state.h> #include "util/GenUtils.h" using namespace rc; using namespace rc::test; namespace { struct Bag { std::vector<int> items; bool open = false; }; using BagCommand = state::Command<Bag, Bag>; struct Open : public BagCommand { void checkPreconditions(const Model &s0) const override { RC_PRE(!s0.open); } void apply(Model &s0) const override { s0.open = true; } void run(const Model &s0, Sut &sut) const override { sut.open = true; } void show(std::ostream &os) const override { os << "Open"; } }; struct Close : public BagCommand { void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); } void apply(Model &s0) const override { s0.open = false; } void run(const Model &s0, Sut &sut) const override { sut.open = false; } void show(std::ostream &os) const override { os << "Close"; } }; struct Add : public BagCommand { int item = *gen::inRange<int>(0, 10); void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); } void apply(Model &s0) const override { s0.items.push_back(item); } void run(const Model &s0, Sut &sut) const override { sut.items.push_back(item); } void show(std::ostream &os) const override { os << "Add(" << item << ")"; } }; struct Del : public BagCommand { std::size_t index; explicit Del(const Bag &s0) { index = *gen::inRange<std::size_t>(0, s0.items.size()); } void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); RC_PRE(index < s0.items.size()); } void apply(Model &s0) const override { auto s1 = s0; s0.items.erase(begin(s0.items) + index); } void run(const Model &s0, Sut &sut) const override { sut.items.erase(begin(sut.items) + index); } void show(std::ostream &os) const override { os << "Del(" << index << ")"; } }; struct BuggyGet : public BagCommand { std::size_t index; explicit BuggyGet(const Bag &s0) { index = *gen::inRange<std::size_t>(0, s0.items.size()); } void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); RC_PRE(index < s0.items.size()); } void run(const Model &s0, Sut &sut) const override { RC_ASSERT(sut.items.size() < 2U); RC_ASSERT(sut.items[index] == s0.items[index]); } void show(std::ostream &os) const override { os << "BuggyGet(" << index << ")"; } }; struct BuggyDelAll : public BagCommand { int value; explicit BuggyDelAll(const Bag &s0) { value = *gen::elementOf(s0.items); } void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); RC_PRE(std::find(begin(s0.items), end(s0.items), value) != end(s0.items)); } void apply(Model &s0) const override { s0.items.erase(std::remove(begin(s0.items), end(s0.items), value), end(s0.items)); } void run(const Model &s0, Sut &sut) const override { RC_FAIL("Bug!"); } void show(std::ostream &os) const override { os << "BuggyDelAll(" << value << ")"; } }; struct SneakyBuggyGet : public BagCommand { int value; explicit SneakyBuggyGet(const Bag &s0) { value = *gen::elementOf(s0.items); } void checkPreconditions(const Model &s0) const override { RC_PRE(s0.open); RC_PRE(std::find(begin(s0.items), end(s0.items), value) != end(s0.items)); } void run(const Model &s0, Sut &sut) const override { RC_ASSERT(value != 2); } void show(std::ostream &os) const override { os << "SneakyBuggyGet(" << value << ")"; } }; template <typename Cmd> std::vector<std::string> showCommands(const state::Commands<Cmd> &commands) { std::vector<std::string> cmdStrings; cmdStrings.reserve(commands.size()); for (const auto &cmd : commands) { std::ostringstream ss; cmd->show(ss); cmdStrings.push_back(ss.str()); } return cmdStrings; } template <typename Cmd> state::Commands<Cmd> findMinCommands(const GenParams &params, const Gen<state::Commands<Cmd>> &gen, const typename Cmd::Model &s0) { return searchGen(params.random, params.size, gen, [=](const state::Commands<Cmd> &cmds) { try { typename Cmd::Sut sut; runAll(cmds, s0, sut); } catch (...) { return true; } return false; }); } } // namespace TEST_CASE("state integration tests") { prop( "should find minimum when some commands might fail to generate while " "shrinking", [](const GenParams &params) { Bag s0; const auto gen = state::gen::commands( s0, state::gen::execOneOfWithArgs<Open, Close, Add, Del, BuggyGet>()); const auto commands = findMinCommands(params, gen, s0); const auto cmdStrings = showCommands(commands); RC_ASSERT(cmdStrings.size() == 4U); RC_ASSERT(cmdStrings[0] == "Open"); RC_ASSERT(cmdStrings[1] == "Add(0)"); RC_ASSERT(cmdStrings[2] == "Add(0)"); RC_ASSERT((cmdStrings[3] == "BuggyGet(0)") || (cmdStrings[3] == "BuggyGet(1)")); }); prop( "should find minimum when later commands depend on the shrunk values of " "previous commands", [](const GenParams &params) { Bag s0; const auto gen = state::gen::commands( s0, state::gen:: execOneOfWithArgs<Open, Close, Add, Del, BuggyDelAll>()); const auto commands = findMinCommands(params, gen, s0); const auto cmdStrings = showCommands(commands); std::vector<std::string> expected{"Open", "Add(0)", "BuggyDelAll(0)"}; RC_ASSERT(cmdStrings == expected); }); prop( "should find minimum when later commands depend on the specific values " "of previous commands", [](const GenParams &params) { Bag s0; const auto gen = state::gen::commands( s0, state::gen:: execOneOfWithArgs<Open, Close, Add, Del, SneakyBuggyGet>()); const auto commands = findMinCommands(params, gen, s0); const auto cmdStrings = showCommands(commands); std::vector<std::string> expected{ "Open", "Add(2)", "SneakyBuggyGet(2)"}; RC_ASSERT(cmdStrings == expected); }); }
6,472
2,198
#pragma once #include "DataFileWriter.hpp" #include "GlobalAveragePointsGnuplotFileWriter.hpp" #include "GlobalEloRatingGnuplotFileWriter.hpp" #include "GlobalPlacePercentageGnuplotFileWriter.hpp" #include "IndividualAveragePointsGnuplotFileWriter.hpp" #include "IndividualEloRatingGnuplotFileWriter.hpp" #include "IndividualPlacePercentageGnuplotFileWriter.hpp" #include "LeaderboardGlobalFileWriter.hpp" #include "LeaderboardIndividualFileWriter.hpp" namespace CatanRanker { /// \brief Class that writes all leaderboard files given games and players data. class Leaderboard { public: Leaderboard(const std::experimental::filesystem::path& base_directory, const Games& games, const Players& players) { if (!base_directory.empty()) { create_directories(base_directory, players); write_data_files(base_directory, players); write_global_gnuplot_files(base_directory, players); write_player_gnuplot_files(base_directory, players); write_global_leaderboard_file(base_directory, games, players); write_player_leaderboard_files(base_directory, games, players); generate_global_plots(base_directory); generate_player_plots(base_directory, players); } } protected: void create_directories(const std::experimental::filesystem::path& base_directory, const Players& players) { create(base_directory); create(base_directory / Path::PlayersDirectoryName); create(base_directory / Path::MainPlotsDirectoryName); for (const Player& player : players) { create(base_directory / player.name().directory_name()); create(base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName); create(base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName); } } void write_data_files(const std::experimental::filesystem::path& base_directory, const Players& players) noexcept { for (const Player& player : players) { for (const GameCategory game_category : GameCategories) { if (!player[game_category].empty()) { DataFileWriter{ base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName / Path::player_data_file_name(game_category), player_table(player, game_category) }; } } } message("Wrote the data files."); } void write_global_gnuplot_files(const std::experimental::filesystem::path& base_directory, const Players& players) noexcept { for (const GameCategory game_category : GameCategories) { std::map<PlayerName, std::experimental::filesystem::path, PlayerName::sort> data_paths; for (const Player& player : players) { if (!player[game_category].empty() && !player.color().empty()) { data_paths.insert({ player.name(), base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName / Path::player_data_file_name(game_category) }); } } if (!data_paths.empty()) { GlobalEloRatingVsGameNumberGnuplotFileWriter{ base_directory / Path::MainPlotsDirectoryName / Path::global_elo_rating_vs_game_number_file_name(game_category), players, data_paths, game_category }; GlobalAveragePointsVsGameNumberGnuplotFileWriter{ base_directory / Path::MainPlotsDirectoryName / Path::global_average_points_vs_game_number_file_name(game_category), players, data_paths }; GlobalPlacePercentageVsGameNumberGnuplotFileWriter{ base_directory / Path::MainPlotsDirectoryName / Path::global_place_percentage_vs_game_number_file_name(game_category, {1}), players, data_paths, game_category, {1} }; } } message("Wrote the global Gnuplot files."); } void write_player_gnuplot_files(const std::experimental::filesystem::path& base_directory, const Players& players) noexcept { for (const Player& player : players) { std::map<GameCategory, std::experimental::filesystem::path> data_paths; for (const GameCategory game_category : GameCategories) { // Only generate a plot if this player has at least 2 games in this game category. if (player[game_category].size() >= 2) { data_paths.insert({ game_category, base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName / Path::player_data_file_name(game_category) }); } } if (!data_paths.empty()) { IndividualEloRatingVsGameNumberGnuplotFileWriter{ base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::PlayerEloRatingVsGameNumberFileName, data_paths, player.lowest_elo_rating(), player.highest_elo_rating() }; IndividualAveragePointsVsGameNumberGnuplotFileWriter{ base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::PlayerAveragePointsVsGameNumberFileName, data_paths }; } if (player[GameCategory::AnyNumberOfPlayers].size() >= 2) { IndividualPlacePercentageVsGameNumberGnuplotFileWriter{ base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::individual_place_percentage_vs_game_number_file_name(GameCategory::AnyNumberOfPlayers), base_directory / player.name().directory_name() / Path::PlayerDataDirectoryName / Path::player_data_file_name(GameCategory::AnyNumberOfPlayers), GameCategory::AnyNumberOfPlayers }; } } message("Wrote the individual player Gnuplot files."); } void write_global_leaderboard_file(const std::experimental::filesystem::path& base_directory, const Games& games, const Players& players) noexcept { LeaderboardGlobalFileWriter{base_directory, games, players}; message("Wrote the global leaderboard Markdown file."); } void write_player_leaderboard_files(const std::experimental::filesystem::path& base_directory, const Games& games, const Players& players) noexcept { for (const Player& player : players) { LeaderboardIndividualFileWriter{base_directory, games, player}; } message("Wrote the individual player leaderboard Markdown files."); } void generate_global_plots(const std::experimental::filesystem::path& base_directory) const { message("Generating the global plots..."); for (const GameCategory game_category : GameCategories) { generate_plot(base_directory / Path::MainPlotsDirectoryName / Path::global_elo_rating_vs_game_number_file_name(game_category)); generate_plot(base_directory / Path::MainPlotsDirectoryName / Path::global_average_points_vs_game_number_file_name(game_category)); for (const Place& place : PlacesFirstSecondThird) { generate_plot(base_directory / Path::MainPlotsDirectoryName / Path::global_place_percentage_vs_game_number_file_name(game_category, place)); } } message("Generated the global plots."); } void generate_player_plots(const std::experimental::filesystem::path& base_directory, const Players& players) const { message("Generating the individual player plots..."); for (const Player& player : players) { generate_plot(base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::PlayerAveragePointsVsGameNumberFileName); generate_plot(base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::PlayerEloRatingVsGameNumberFileName); for (const GameCategory game_category : GameCategories) { generate_plot(base_directory / player.name().directory_name() / Path::PlayerPlotsDirectoryName / Path::individual_place_percentage_vs_game_number_file_name(game_category)); } } message("Generated the individual player plots."); } /// \brief Generate a plot using Gnuplot. If the path points to a file that does not exist, no plot is generated. void generate_plot(const std::experimental::filesystem::path& path) const { if (std::experimental::filesystem::exists(path)) { const std::string command{"gnuplot " + path.string()}; const int outcome{std::system(command.c_str())}; if (outcome != 0) { error("Could not run the command: " + command); } } } Table player_table(const Player& player, const GameCategory game_category) const noexcept { Column game_number{"Game#"}; Column game_category_game_number{"GameCategory#"}; Column player_game_number{"PlayerGame#"}; Column player_game_category_game_number{"PlayerCategoryGame#"}; Column date{"Date"}; Column average_elo_rating{"AvgRating"}; Column elo_rating{"CurrentRating"}; Column average_points_per_game{"AvgPoints"}; Column first_place_percentage{"1stPlace%"}; Column second_place_percentage{"2ndPlace%"}; Column third_place_percentage{"3rdPlace%"}; Column first_or_second_place_percentage{"1stOr2ndPlace%"}; Column first_or_second_or_third_place_percentage{"1stOr2ndOr3rdPlace%"}; if (!player[game_category].empty()) { for (const PlayerProperties& properties : player[game_category]) { game_number.add_row(properties.game_number()); game_category_game_number.add_row(properties.game_category_game_number()); player_game_number.add_row(properties.player_game_number()); player_game_category_game_number.add_row(properties.player_game_category_game_number()); date.add_row(properties.date()); average_elo_rating.add_row(properties.average_elo_rating()); elo_rating.add_row(properties.elo_rating()); average_points_per_game.add_row(properties.average_points_per_game(), 7); first_place_percentage.add_row(properties.place_percentage({1}), 5); second_place_percentage.add_row(properties.place_percentage({2}), 5); third_place_percentage.add_row(properties.place_percentage({3}), 5); first_or_second_place_percentage.add_row(properties.place_percentage({1}) + properties.place_percentage({2}), 5); first_or_second_or_third_place_percentage.add_row(properties.place_percentage({1}) + properties.place_percentage({2}) + properties.place_percentage({3}), 5); } } return {{game_number, game_category_game_number, player_game_number, player_game_category_game_number, date, average_elo_rating, elo_rating, average_points_per_game, first_place_percentage, second_place_percentage, third_place_percentage, first_or_second_place_percentage, first_or_second_or_third_place_percentage}}; } }; } // namespace CatanRanker
10,608
3,055
#include "energy/soft_volume_constraint.h" #include "matrix_utils.h" #include "surface_derivatives.h" namespace rsurfaces { SoftVolumeConstraint::SoftVolumeConstraint(MeshPtr mesh_, GeomPtr geom_, double weight_) { mesh = mesh_; geom = geom_; weight = weight_; initialVolume = totalVolume(geom, mesh); } inline double volumeDeviation(MeshPtr mesh, GeomPtr geom, double initialValue) { return (totalVolume(geom, mesh) - initialValue) / initialValue; } // Returns the current value of the energy. double SoftVolumeConstraint::Value() { double volDev = volumeDeviation(mesh, geom, initialVolume); return weight * (volDev * volDev); } // Returns the current differential of the energy, stored in the given // V x 3 matrix, where each row holds the differential (a 3-vector) with // respect to the corresponding vertex. void SoftVolumeConstraint::Differential(Eigen::MatrixXd &output) { double volDev = volumeDeviation(mesh, geom, initialVolume); VertexIndices inds = mesh->getVertexIndices(); for (size_t i = 0; i < mesh->nVertices(); i++) { GCVertex v_i = mesh->vertex(i); // Derivative of local volume is just the area weighted normal Vector3 deriv_v = areaWeightedNormal(geom, v_i); // Derivative of V^2 = 2 V (dV/dx) deriv_v = 2 * volDev * deriv_v / initialVolume; MatrixUtils::addToRow(output, inds[v_i], weight * deriv_v); } } // Get the exponents of this energy; only applies to tangent-point energies. Vector2 SoftVolumeConstraint::GetExponents() { return Vector2{1, 0}; } // Get a pointer to the current BVH for this energy. // Return 0 if the energy doesn't use a BVH. OptimizedClusterTree *SoftVolumeConstraint::GetBVH() { return 0; } // Return the separation parameter for this energy. // Return 0 if this energy doesn't do hierarchical approximation. double SoftVolumeConstraint::GetTheta() { return 0; } } // namespace rsurfaces
2,160
646
/* Copyright (c) 2020 vesoft inc. All rights reserved. * * This source code is licensed under Apache 2.0 License, * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ #include "planner/Query.h" #include <folly/String.h> #include "common/interface/gen-cpp2/graph_types.h" #include "util/ToJson.h" using folly::stringPrintf; namespace nebula { namespace graph { std::unique_ptr<cpp2::PlanNodeDescription> Explore::explain() const { auto desc = SingleInputNode::explain(); addDescription("space", folly::to<std::string>(space_), desc.get()); addDescription("dedup", util::toJson(dedup_), desc.get()); addDescription("limit", folly::to<std::string>(limit_), desc.get()); auto filter = filter_.empty() ? filter_ : Expression::decode(filter_)->toString(); addDescription("filter", filter, desc.get()); addDescription("orderBy", folly::toJson(util::toJson(orderBy_)), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> GetNeighbors::explain() const { auto desc = Explore::explain(); addDescription("src", src_ ? src_->toString() : "", desc.get()); addDescription("edgeTypes", folly::toJson(util::toJson(edgeTypes_)), desc.get()); addDescription("edgeDirection", storage::cpp2::_EdgeDirection_VALUES_TO_NAMES.at(edgeDirection_), desc.get()); addDescription( "vertexProps", vertexProps_ ? folly::toJson(util::toJson(*vertexProps_)) : "", desc.get()); addDescription( "edgeProps", edgeProps_ ? folly::toJson(util::toJson(*edgeProps_)) : "", desc.get()); addDescription( "statProps", statProps_ ? folly::toJson(util::toJson(*statProps_)) : "", desc.get()); addDescription("exprs", exprs_ ? folly::toJson(util::toJson(*exprs_)) : "", desc.get()); addDescription("random", util::toJson(random_), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> GetVertices::explain() const { auto desc = Explore::explain(); addDescription("src", src_ ? src_->toString() : "", desc.get()); addDescription("props", folly::toJson(util::toJson(props_)), desc.get()); addDescription("exprs", folly::toJson(util::toJson(exprs_)), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> GetEdges::explain() const { auto desc = Explore::explain(); addDescription("src", src_ ? src_->toString() : "", desc.get()); addDescription("type", util::toJson(type_), desc.get()); addDescription("ranking", ranking_ ? ranking_->toString() : "", desc.get()); addDescription("dst", dst_ ? dst_->toString() : "", desc.get()); addDescription("props", folly::toJson(util::toJson(props_)), desc.get()); addDescription("exprs", folly::toJson(util::toJson(exprs_)), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> IndexScan::explain() const { auto desc = Explore::explain(); // TODO return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Filter::explain() const { auto desc = SingleInputNode::explain(); addDescription("condition", condition_ ? condition_->toString() : "", desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Project::explain() const { auto desc = SingleInputNode::explain(); addDescription("columns", cols_ ? cols_->toString() : "", desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Sort::explain() const { auto desc = SingleInputNode::explain(); addDescription("factors", folly::toJson(util::toJson(factors_)), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Limit::explain() const { auto desc = SingleInputNode::explain(); addDescription("offset", folly::to<std::string>(offset_), desc.get()); addDescription("count", folly::to<std::string>(count_), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> Aggregate::explain() const { auto desc = SingleInputNode::explain(); addDescription("groupKeys", folly::toJson(util::toJson(groupKeys_)), desc.get()); folly::dynamic itemArr = folly::dynamic::array(); for (const auto &item : groupItems_) { folly::dynamic itemObj = folly::dynamic::object(); itemObj.insert("distinct", util::toJson(item.distinct)); itemObj.insert("funcType", static_cast<uint8_t>(item.func)); itemObj.insert("expr", item.expr ? item.expr->toString() : ""); itemArr.push_back(itemObj); } addDescription("groupItems", folly::toJson(itemArr), desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> SwitchSpace::explain() const { auto desc = SingleInputNode::explain(); addDescription("space", spaceName_, desc.get()); return desc; } std::unique_ptr<cpp2::PlanNodeDescription> DataCollect::explain() const { auto desc = SingleDependencyNode::explain(); addDescription("inputVars", folly::toJson(util::toJson(inputVars_)), desc.get()); switch (collectKind_) { case CollectKind::kSubgraph: { addDescription("kind", "subgraph", desc.get()); break; } case CollectKind::kRowBasedMove: { addDescription("kind", "row", desc.get()); break; } case CollectKind::kMToN: { addDescription("kind", "m to n", desc.get()); break; } } return desc; } std::unique_ptr<cpp2::PlanNodeDescription> DataJoin::explain() const { auto desc = SingleDependencyNode::explain(); addDescription("leftVar", folly::toJson(util::toJson(leftVar_)), desc.get()); addDescription("rightVar", folly::toJson(util::toJson(rightVar_)), desc.get()); addDescription("hashKeys", folly::toJson(util::toJson(hashKeys_)), desc.get()); addDescription("probeKeys", folly::toJson(util::toJson(probeKeys_)), desc.get()); return desc; } } // namespace graph } // namespace nebula
5,934
1,854
/* * CreatureTemplateReference.cpp * * Created on: 29/04/2012 * Author: victor */ #include "CreatureTemplateReference.h" #include "server/zone/managers/creature/CreatureTemplateManager.h" bool CreatureTemplateReference::toBinaryStream(ObjectOutputStream* stream) { #ifdef ODB_SERIALIZATION templateString.toBinaryStream(stream); #else CreatureTemplate* obj = get(); if (obj != nullptr) { obj->getTemplateName().toBinaryStream(stream); } else stream->writeShort(0); #endif return true; } bool CreatureTemplateReference::parseFromBinaryStream(ObjectInputStream* stream) { #ifdef ODB_SERIALIZATION templateString.parseFromBinaryStream(stream); return true; #else String templateName; templateName.parseFromBinaryStream(stream); CreatureTemplate* obj = CreatureTemplateManager::instance()->getTemplate(templateName); if (obj != nullptr) { updateObject(obj); return true; } updateObject(obj); return false; #endif } CreatureTemplate* CreatureTemplateReference::operator=(CreatureTemplate* obj) { updateObject(obj); return obj; } void to_json(nlohmann::json& j, const CreatureTemplateReference& r) { #ifdef ODB_SERIALIZATION j = r.templateString; #else CreatureTemplate* obj = r.get(); if (obj != nullptr) { j = obj->getTemplateName(); } else j = ""; #endif }
1,312
448
// Copyright 2017 Open Source Robotics Foundation, Inc. // // 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 "gtest/gtest.h" #include "./allocator_testing_utils.h" #include "rcutils/error_handling.h" #include "rcutils/split.h" #include "rcutils/types/string_array.h" #define ENABLE_LOGGING 1 #if ENABLE_LOGGING #define LOG(expected, actual) { \ printf("Expected: %s Actual: %s\n", expected, actual);} #else #define LOG(X, arg) {} #endif rcutils_string_array_t test_split(const char * str, char delimiter, size_t expected_token_size) { rcutils_string_array_t tokens = rcutils_get_zero_initialized_string_array(); rcutils_ret_t ret = rcutils_split( str, delimiter, rcutils_get_default_allocator(), &tokens); EXPECT_EQ(RCUTILS_RET_OK, ret); fprintf(stderr, "Received %zu tokens\n", tokens.size); EXPECT_EQ(expected_token_size, tokens.size); for (size_t i = 0; i < tokens.size; ++i) { EXPECT_NE((size_t)0, strlen(tokens.data[i])); } return tokens; } rcutils_string_array_t test_split_last( const char * str, char delimiter, size_t expected_token_size) { rcutils_string_array_t tokens = rcutils_get_zero_initialized_string_array(); rcutils_ret_t ret = rcutils_split_last( str, delimiter, rcutils_get_default_allocator(), &tokens); EXPECT_EQ(RCUTILS_RET_OK, ret); EXPECT_EQ(expected_token_size, tokens.size); for (size_t i = 0; i < tokens.size; ++i) { EXPECT_NE((size_t)0, strlen(tokens.data[i])); } return tokens; } TEST(test_split, split) { rcutils_ret_t ret = RCUTILS_RET_OK; rcutils_string_array_t tokens_fail; EXPECT_EQ( RCUTILS_RET_INVALID_ARGUMENT, rcutils_split("Test", '/', rcutils_get_default_allocator(), NULL)); EXPECT_EQ( RCUTILS_RET_ERROR, rcutils_split("Test", '/', get_failing_allocator(), &tokens_fail)); rcutils_string_array_t tokens0 = test_split("", '/', 0); ret = rcutils_string_array_fini(&tokens0); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens00 = test_split(NULL, '/', 0); ret = rcutils_string_array_fini(&tokens00); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens1 = test_split("hello_world", '/', 1); EXPECT_STREQ("hello_world", tokens1.data[0]); ret = rcutils_string_array_fini(&tokens1); ASSERT_EQ(RCUTILS_RET_OK, ret) << rcutils_get_error_string().str; rcutils_string_array_t tokens2 = test_split("hello/world", '/', 2); EXPECT_STREQ("hello", tokens2.data[0]); EXPECT_STREQ("world", tokens2.data[1]); ret = rcutils_string_array_fini(&tokens2); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens3 = test_split("/hello/world", '/', 2); EXPECT_STREQ("hello", tokens3.data[0]); EXPECT_STREQ("world", tokens3.data[1]); ret = rcutils_string_array_fini(&tokens3); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens4 = test_split("hello/world/", '/', 2); EXPECT_STREQ("hello", tokens4.data[0]); EXPECT_STREQ("world", tokens4.data[1]); ret = rcutils_string_array_fini(&tokens4); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens5 = test_split("hello//world", '/', 2); EXPECT_STREQ("hello", tokens5.data[0]); EXPECT_STREQ("world", tokens5.data[1]); ret = rcutils_string_array_fini(&tokens5); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens6 = test_split("/hello//world", '/', 2); EXPECT_STREQ("hello", tokens6.data[0]); EXPECT_STREQ("world", tokens6.data[1]); ret = rcutils_string_array_fini(&tokens6); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens7 = test_split("my/hello/world", '/', 3); EXPECT_STREQ("my", tokens7.data[0]); EXPECT_STREQ("hello", tokens7.data[1]); EXPECT_STREQ("world", tokens7.data[2]); ret = rcutils_string_array_fini(&tokens7); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens8 = test_split("/my/hello/world", '/', 3); EXPECT_STREQ("my", tokens8.data[0]); EXPECT_STREQ("hello", tokens8.data[1]); EXPECT_STREQ("world", tokens8.data[2]); ret = rcutils_string_array_fini(&tokens8); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens9 = test_split("/my/hello/world/", '/', 3); EXPECT_STREQ("my", tokens9.data[0]); EXPECT_STREQ("hello", tokens9.data[1]); EXPECT_STREQ("world", tokens9.data[2]); ret = rcutils_string_array_fini(&tokens9); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens10 = test_split("/my//hello//world//", '/', 3); EXPECT_STREQ("my", tokens10.data[0]); EXPECT_STREQ("hello", tokens10.data[1]); EXPECT_STREQ("world", tokens10.data[2]); ret = rcutils_string_array_fini(&tokens10); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens11 = test_split("///my//hello//world/////", '/', 3); EXPECT_STREQ("my", tokens11.data[0]); EXPECT_STREQ("hello", tokens11.data[1]); EXPECT_STREQ("world", tokens11.data[2]); ret = rcutils_string_array_fini(&tokens11); ASSERT_EQ(RCUTILS_RET_OK, ret); } TEST(test_split, split_last) { rcutils_ret_t ret = RCUTILS_RET_OK; rcutils_string_array_t tokens_fail; EXPECT_EQ( RCUTILS_RET_BAD_ALLOC, rcutils_split_last("Test", '/', get_failing_allocator(), &tokens_fail)); rcutils_string_array_t tokens0 = test_split_last("", '/', 0); ret = rcutils_string_array_fini(&tokens0); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens00 = test_split_last(NULL, '/', 0); ret = rcutils_string_array_fini(&tokens00); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens1 = test_split_last("hello_world", '/', 1); LOG("hello_world", tokens1.data[0]); EXPECT_STREQ("hello_world", tokens1.data[0]); ret = rcutils_string_array_fini(&tokens1); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens2 = test_split_last("hello/world", '/', 2); EXPECT_STREQ("hello", tokens2.data[0]); LOG("hello", tokens2.data[0]); EXPECT_STREQ("world", tokens2.data[1]); LOG("world", tokens2.data[1]); ret = rcutils_string_array_fini(&tokens2); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens3 = test_split_last("/hello/world", '/', 2); EXPECT_STREQ("hello", tokens3.data[0]); LOG("hello", tokens3.data[0]); EXPECT_STREQ("world", tokens3.data[1]); ret = rcutils_string_array_fini(&tokens3); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens4 = test_split_last("hello/world/", '/', 2); EXPECT_STREQ("hello", tokens4.data[0]); EXPECT_STREQ("world", tokens4.data[1]); ret = rcutils_string_array_fini(&tokens4); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens5 = test_split_last("hello//world/", '/', 2); EXPECT_STREQ("hello", tokens5.data[0]); LOG("hello", tokens5.data[0]); EXPECT_STREQ("world", tokens5.data[1]); LOG("world", tokens5.data[1]); ret = rcutils_string_array_fini(&tokens5); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens6 = test_split_last("/hello//world", '/', 2); EXPECT_STREQ("hello", tokens6.data[0]); EXPECT_STREQ("world", tokens6.data[1]); ret = rcutils_string_array_fini(&tokens6); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens7 = test_split_last("my/hello//world", '/', 2); EXPECT_STREQ("my/hello", tokens7.data[0]); EXPECT_STREQ("world", tokens7.data[1]); ret = rcutils_string_array_fini(&tokens7); ASSERT_EQ(RCUTILS_RET_OK, ret); rcutils_string_array_t tokens8 = test_split_last("/my/hello//world/", '/', 2); EXPECT_STREQ("my/hello", tokens8.data[0]); EXPECT_STREQ("world", tokens8.data[1]); ret = rcutils_string_array_fini(&tokens8); ASSERT_EQ(RCUTILS_RET_OK, ret); }
8,034
3,445
/** * @file * * Unless noted otherwise, the portions of Isis written by the USGS are public * domain. See individual third-party library and package descriptions for * intellectual property information,user agreements, and related information. * * Although Isis has been used by the USGS, no warranty, expressed or implied, * is made by the USGS as to the accuracy and functioning of such software * and related material nor shall the fact of distribution constitute any such * warranty, and no responsibility is assumed by the USGS in connection * therewith. * * For additional information, launch * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see * the Privacy &amp; Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on * http://www.usgs.gov/privacy.html. */ #include "KaguyaMiCamera.h" #include <iomanip> #include <QString> #include "CameraFocalPlaneMap.h" #include "IException.h" #include "IString.h" #include "iTime.h" #include "LineScanCameraDetectorMap.h" #include "LineScanCameraGroundMap.h" #include "LineScanCameraSkyMap.h" #include "KaguyaMiCameraDistortionMap.h" #include "NaifStatus.h" using namespace std; namespace Isis { /** * Constructor for the Kaguya MI Camera Model * * @param lab Pvl Label to create the camera model from * * @internal * @history 2012-06-14 Orrin Thomas - original version */ KaguyaMiCamera::KaguyaMiCamera(Cube &cube) : LineScanCamera(cube) { m_spacecraftNameLong = "Kaguya"; m_spacecraftNameShort = "Kaguya"; int ikCode = naifIkCode(); // https://darts.isas.jaxa.jp/pub/spice/SELENE/kernels/ik/SEL_MI_V01.TI // MI-VIS instrument kernel codes -131331 through -131335 if (ikCode <= -131331 && ikCode >= -131335) { m_instrumentNameLong = "Multi Band Imager Visible"; m_instrumentNameShort = "MI-VIS"; } // MI-NIR instrument kernel codes -131341 through -131344 else if (ikCode <= -131341 && ikCode >= -131344) { m_instrumentNameLong = "Multi Band Imager Infrared"; m_instrumentNameShort = "MI-NIR"; } else { QString msg = QString::number(ikCode); msg += " is not a supported instrument kernel code for Kaguya."; throw IException(IException::Programmer, msg, _FILEINFO_); } NaifStatus::CheckErrors(); // Set up the camera info from ik/iak kernels SetFocalLength(); //Kaguya IK kernal uses INS-131???_PIXEL_SIZE instead of PIXEL_PITCH QString ikernKey = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE"; SetPixelPitch(getDouble(ikernKey)); // Get the start time from labels Pvl &lab = *cube.label(); PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse); QString stime = (QString)inst["StartTime"]; SpiceDouble etStart=0; if(stime != "NULL") { etStart = iTime(stime).Et(); } else { //TODO throw an error if "StartTime" keyword is absent } NaifStatus::CheckErrors(); // Get other info from labels double lineRate = (double) inst["CorrectedSamplingInterval"] / 1000.0; setTime(etStart); // Setup detector map LineScanCameraDetectorMap *detectorMap = new LineScanCameraDetectorMap(this, etStart, lineRate); detectorMap->SetDetectorSampleSumming(1.0); detectorMap->SetStartingDetectorSample(1.0); // Setup focal plane map CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode()); // Retrieve boresight location from instrument kernel (IK) (addendum?) ikernKey = "INS" + toString(naifIkCode()) + "_CENTER"; double sampleBoreSight = getDouble(ikernKey,0); double lineBoreSight = getDouble(ikernKey,1)-1.0; focalMap->SetDetectorOrigin(sampleBoreSight, lineBoreSight); focalMap->SetDetectorOffset(0.0, 0.0); KaguyaMiCameraDistortionMap *distMap = new KaguyaMiCameraDistortionMap(this); //LroNarrowAngleDistortionMap *distMap = new LroNarrowAngleDistortionMap(this); distMap->SetDistortion(naifIkCode()); // Setup the ground and sky map new LineScanCameraGroundMap(this); new LineScanCameraSkyMap(this); LoadCache(); NaifStatus::CheckErrors(); } } /** * This is the function that is called in order to instantiate a * KaguyaMi object. * * @param lab Cube labels * * @return Isis::Camera* KaguyaMiCamera * @internal * @history 2012-06-14 Orrin Thomas - original version */ extern "C" Isis::Camera *KaguyaMiCameraPlugin(Isis::Cube &cube) { return new Isis::KaguyaMiCamera(cube); }
4,594
1,613
/* See LICENSE for license details */ /* */ #include <appl_status.h> #include <appl_types.h> #include <thread/appl_thread_descriptor.h> #include <object/appl_object.h> #include <buf/appl_buf.h> #include <thread/appl_thread_descriptor_impl.h> #include <heap/appl_heap_handle.h> // // // enum appl_status appl_thread_descriptor_create( struct appl_context * const p_context, struct appl_thread_descriptor * * const r_thread_descriptor) { enum appl_status e_status; e_status = appl_new( p_context, r_thread_descriptor); return e_status; } // _create() // // // enum appl_status appl_thread_descriptor_destroy( struct appl_thread_descriptor * const p_thread_descriptor) { enum appl_status e_status; struct appl_context * const p_context = p_thread_descriptor->get_context(); e_status = appl_delete( p_context, p_thread_descriptor); return e_status; } // _destroy() /* */ void appl_thread_descriptor_set_callback( struct appl_thread_descriptor * const p_thread_descriptor, void (* const p_entry)( void * const p_thread_context), void * const p_context) { struct appl_thread_callback o_callback; o_callback.p_entry = p_entry; o_callback.p_context = p_context; p_thread_descriptor->f_set_callback( &( o_callback)); } /* appl_thread_descriptor_set_callback() */ // // // void appl_thread_descriptor_set_name( struct appl_thread_descriptor * const p_thread_descriptor, unsigned char const * const p_name_min, unsigned char const * const p_name_max) { struct appl_buf o_name; o_name.o_min.pc_uchar = p_name_min; o_name.o_max.pc_uchar = p_name_max; p_thread_descriptor->f_set_name( &( o_name)); } // _set_name() // // // char appl_thread_descriptor_get_callback( struct appl_thread_descriptor const * const p_thread_descriptor, struct appl_thread_callback * const p_thread_callback) { return p_thread_descriptor->f_get_callback( p_thread_callback) ? 1 : 0; } // _get_callback() // // // char appl_thread_descriptor_get_name( struct appl_thread_descriptor const * const p_thread_descriptor, struct appl_buf * const p_name) { return p_thread_descriptor->f_get_name( p_name) ? 1 : 0; } // _get_name() /* end-of-file: appl_thread_descriptor.cpp */
2,743
951
struct Cartridge { #include "memory.hpp" auto pathID() const -> uint { return information.pathID; } auto hash() const -> string { return information.sha256; } auto manifest() const -> string { return information.manifest; } auto title() const -> string { return information.title; } struct Information { uint pathID = 0; string sha256; string manifest; string title; } information; Cartridge(); ~Cartridge(); auto load() -> bool; auto save() -> void; auto unload() -> void; auto power() -> void; auto read(uint mode, uint32 addr) -> uint32; auto write(uint mode, uint32 addr, uint32 word) -> void; auto serialize(serializer&) -> void; private: bool hasSRAM = false; bool hasEEPROM = false; bool hasFLASH = false; }; extern Cartridge cartridge;
806
262
/* * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "webrtc/modules/audio_coding/main/acm2/codec_owner.h" #include "webrtc/base/checks.h" #include "webrtc/base/logging.h" #include "webrtc/engine_configurations.h" #include "webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h" #include "webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h" #ifdef WEBRTC_CODEC_G722 #include "webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h" #endif #ifdef WEBRTC_CODEC_ILBC #include "webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h" #endif #ifdef WEBRTC_CODEC_ISACFX #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_decoder_isacfix.h" #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_encoder_isacfix.h" #endif #ifdef WEBRTC_CODEC_ISAC #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_decoder_isac.h" #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_isac.h" #endif #ifdef WEBRTC_CODEC_OPUS #include "webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h" #endif #include "webrtc/modules/audio_coding/codecs/pcm16b/include/audio_encoder_pcm16b.h" #ifdef WEBRTC_CODEC_RED #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h" #endif namespace webrtc { namespace acm2 { CodecOwner::CodecOwner() : external_speech_encoder_(nullptr) { } CodecOwner::~CodecOwner() = default; namespace { rtc::scoped_ptr<AudioDecoder> CreateIsacDecoder( LockedIsacBandwidthInfo* bwinfo) { #if defined(WEBRTC_CODEC_ISACFX) return rtc_make_scoped_ptr(new AudioDecoderIsacFix(bwinfo)); #elif defined(WEBRTC_CODEC_ISAC) return rtc_make_scoped_ptr(new AudioDecoderIsac(bwinfo)); #else FATAL() << "iSAC is not supported."; return rtc::scoped_ptr<AudioDecoder>(); #endif } // Returns a new speech encoder, or null on error. // TODO(kwiberg): Don't handle errors here (bug 5033) rtc::scoped_ptr<AudioEncoder> CreateSpeechEncoder( const CodecInst& speech_inst, LockedIsacBandwidthInfo* bwinfo) { #if defined(WEBRTC_CODEC_ISACFX) if (STR_CASE_CMP(speech_inst.plname, "isac") == 0) return rtc_make_scoped_ptr(new AudioEncoderIsacFix(speech_inst, bwinfo)); #endif #if defined(WEBRTC_CODEC_ISAC) if (STR_CASE_CMP(speech_inst.plname, "isac") == 0) return rtc_make_scoped_ptr(new AudioEncoderIsac(speech_inst, bwinfo)); #endif #ifdef WEBRTC_CODEC_OPUS if (STR_CASE_CMP(speech_inst.plname, "opus") == 0) return rtc_make_scoped_ptr(new AudioEncoderOpus(speech_inst)); #endif if (STR_CASE_CMP(speech_inst.plname, "pcmu") == 0) return rtc_make_scoped_ptr(new AudioEncoderPcmU(speech_inst)); if (STR_CASE_CMP(speech_inst.plname, "pcma") == 0) return rtc_make_scoped_ptr(new AudioEncoderPcmA(speech_inst)); if (STR_CASE_CMP(speech_inst.plname, "l16") == 0) return rtc_make_scoped_ptr(new AudioEncoderPcm16B(speech_inst)); #ifdef WEBRTC_CODEC_ILBC if (STR_CASE_CMP(speech_inst.plname, "ilbc") == 0) return rtc_make_scoped_ptr(new AudioEncoderIlbc(speech_inst)); #endif #ifdef WEBRTC_CODEC_G722 if (STR_CASE_CMP(speech_inst.plname, "g722") == 0) return rtc_make_scoped_ptr(new AudioEncoderG722(speech_inst)); #endif LOG_F(LS_ERROR) << "Could not create encoder of type " << speech_inst.plname; return rtc::scoped_ptr<AudioEncoder>(); } AudioEncoder* CreateRedEncoder(int red_payload_type, AudioEncoder* encoder, rtc::scoped_ptr<AudioEncoder>* red_encoder) { #ifdef WEBRTC_CODEC_RED if (red_payload_type != -1) { AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type; config.speech_encoder = encoder; red_encoder->reset(new AudioEncoderCopyRed(config)); return red_encoder->get(); } #endif red_encoder->reset(); return encoder; } void CreateCngEncoder(int cng_payload_type, ACMVADMode vad_mode, AudioEncoder* encoder, rtc::scoped_ptr<AudioEncoder>* cng_encoder) { if (cng_payload_type == -1) { cng_encoder->reset(); return; } AudioEncoderCng::Config config; config.num_channels = encoder->NumChannels(); config.payload_type = cng_payload_type; config.speech_encoder = encoder; switch (vad_mode) { case VADNormal: config.vad_mode = Vad::kVadNormal; break; case VADLowBitrate: config.vad_mode = Vad::kVadLowBitrate; break; case VADAggr: config.vad_mode = Vad::kVadAggressive; break; case VADVeryAggr: config.vad_mode = Vad::kVadVeryAggressive; break; default: FATAL(); } cng_encoder->reset(new AudioEncoderCng(config)); } } // namespace bool CodecOwner::SetEncoders(const CodecInst& speech_inst, int cng_payload_type, ACMVADMode vad_mode, int red_payload_type) { speech_encoder_ = CreateSpeechEncoder(speech_inst, &isac_bandwidth_info_); if (!speech_encoder_) return false; external_speech_encoder_ = nullptr; ChangeCngAndRed(cng_payload_type, vad_mode, red_payload_type); return true; } void CodecOwner::SetEncoders(AudioEncoder* external_speech_encoder, int cng_payload_type, ACMVADMode vad_mode, int red_payload_type) { external_speech_encoder_ = external_speech_encoder; speech_encoder_.reset(); ChangeCngAndRed(cng_payload_type, vad_mode, red_payload_type); } void CodecOwner::ChangeCngAndRed(int cng_payload_type, ACMVADMode vad_mode, int red_payload_type) { AudioEncoder* speech_encoder = SpeechEncoder(); if (cng_payload_type != -1 || red_payload_type != -1) { // The RED and CNG encoders need to be in sync with the speech encoder, so // reset the latter to ensure its buffer is empty. speech_encoder->Reset(); } AudioEncoder* encoder = CreateRedEncoder(red_payload_type, speech_encoder, &red_encoder_); CreateCngEncoder(cng_payload_type, vad_mode, encoder, &cng_encoder_); RTC_DCHECK_EQ(!!speech_encoder_ + !!external_speech_encoder_, 1); } AudioDecoder* CodecOwner::GetIsacDecoder() { if (!isac_decoder_) isac_decoder_ = CreateIsacDecoder(&isac_bandwidth_info_); return isac_decoder_.get(); } AudioEncoder* CodecOwner::Encoder() { const auto& const_this = *this; return const_cast<AudioEncoder*>(const_this.Encoder()); } const AudioEncoder* CodecOwner::Encoder() const { if (cng_encoder_) return cng_encoder_.get(); if (red_encoder_) return red_encoder_.get(); return SpeechEncoder(); } AudioEncoder* CodecOwner::SpeechEncoder() { const auto* const_this = this; return const_cast<AudioEncoder*>(const_this->SpeechEncoder()); } const AudioEncoder* CodecOwner::SpeechEncoder() const { RTC_DCHECK(!speech_encoder_ || !external_speech_encoder_); return external_speech_encoder_ ? external_speech_encoder_ : speech_encoder_.get(); } } // namespace acm2 } // namespace webrtc
7,518
2,856
/* * (C) Copyright 2009-2016 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation nor * does it submit to any jurisdiction. */ #include "lorenz95/ObservationL95.h" #include <string> #include <vector> #include "eckit/config/Configuration.h" #include "lorenz95/GomL95.h" #include "lorenz95/LocsL95.h" #include "lorenz95/ObsBias.h" #include "lorenz95/ObsDiags1D.h" #include "lorenz95/ObsVec1D.h" #include "oops/base/Variables.h" #include "oops/util/Logger.h" // ----------------------------------------------------------------------------- namespace lorenz95 { // ----------------------------------------------------------------------------- ObservationL95::ObservationL95(const ObsTable & ot, const eckit::Configuration &) : obsdb_(ot), inputs_(std::vector<std::string>{"x"}) {} // ----------------------------------------------------------------------------- ObservationL95::~ObservationL95() {} // ----------------------------------------------------------------------------- void ObservationL95::simulateObs(const GomL95 & gom, ObsVec1D & ovec, const ObsBias & bias, ObsDiags1D &) const { for (size_t jj = 0; jj < gom.size(); ++jj) { ovec[jj] = gom[jj] + bias.value(); } } // ----------------------------------------------------------------------------- std::unique_ptr<LocsL95> ObservationL95::locations() const { return std::unique_ptr<LocsL95>(new LocsL95(obsdb_.locations(), obsdb_.times())); } // ----------------------------------------------------------------------------- void ObservationL95::print(std::ostream & os) const { os << "Lorenz 95: Identity obs operator"; } // ----------------------------------------------------------------------------- } // namespace lorenz95
2,019
642
#include <stdio.h> #include <xtime_l.h> #include "test.h" void test_cls_hls_polling_pre() { // Disable interrupt interrupt_enable(false); } unsigned int test_cls_hls_polling() { XTime tick[4], perf[3] = {0, 0, 0}; unsigned int err = 0; int *label = &testDataLabel[0]; int16_t *x = &testDataI[0][0]; for (size_t ix = ASIZE(testDataLabel); ix != 0; ix--) { XTime_GetTime(&tick[0]); XClassifier_Set_x_V(&cls, *(XClassifier_X_v *)x); XTime_GetTime(&tick[1]); XClassifier_Start(&cls); XTime_GetTime(&tick[2]); while (!XClassifier_IsReady(&cls)); XTime_GetTime(&tick[3]); err += (!XClassifier_Get_output_r(&cls)) != (!*label++); perf[0] += tick[1] - tick[0]; perf[1] += tick[2] - tick[1]; perf[2] += tick[3] - tick[2]; x += N; } printf("Data %llu, starting %llu, result %llu\r\n", perf[0], perf[1], perf[2]); return err; }
853
404
/* Name: Rehannah Baptiste Program Title: Memory vs Gender Analysis Game Program description: This program visualises statistics to determine which gender has better memory (recall) and allows users to play a memory game which adds to the data. Version 1.0: December 5th 2020 Current version: 1.5 (2022) */ #include <iostream> #include <iomanip> #include <conio.h> #include<windows.h> #include <fstream> #include <cmath> using namespace std; #define QUIT 10 // QUIT constant #define filename "highscores.txt" #define wordlist "words.txt" #define newfile "newhighscores.txt" struct Player { int score; //player highscore string name; //Player name char gender; //player gender int attempt; //number of games played }; //Menu function int menu () { int choice; bool validChoice; validChoice = false; while (!validChoice) { system("cls"); cout << " M E N U" << endl; cout << endl; cout << " 1. Sum and average words remembered by males vs. females." << endl; cout << " 2. Percentage of attempts made by males vs. females" << endl; cout << " 3. List the top player(s) - highest number of words recalled in the least attempts." << endl; cout << " 4. Male and female players with the highest and lowest number of words." << endl; cout << " 5. Rename a player and save new data to file." << endl; cout << " 6. Search for the number of occurrences where players remembered x words or more." << endl; cout << " 7. Generate a graph showing all players' scores." << endl; cout << " 8. Surprise feature: Play the memory game and add new data to file." << endl; cout << " 9. Highscores" << endl; cout << " 10. Quit" << endl; cout << endl; cout << " Please choose an option or " << QUIT << " to quit: "; cin >> choice; if (choice >= 1 && choice <= QUIT) // Ensures choice is within the range of menu options validChoice = true; else cout << "Invalid selection. Try again." <<endl; Sleep(2500); system("cls"); if (choice==QUIT) { exit(1); } } return choice; } //end of menu function //printStars function void printStars (int numStars) { int i; for(i = 1; i<= numStars; i= i+1) cout << "*"; cout << endl; }//end of printStars function //Countdown Timer void Timer(string timermsg, int numOfseconds) { int t; system("CLS"); for (t=numOfseconds;t>0;t--) { cout << timermsg << t <<endl; Sleep(1000); system("CLS"); } } //end of Timer function //Memory Game Menu int MG () { int choice; bool validChoice; validChoice = false; while (!validChoice) { system("cls"); cout << "Please make a selection from the menu below." <<endl <<endl; cout << " MEMORY GAME" << endl; cout << endl; cout << " 1. Play game and save your score." << endl; cout << " 2. How to play?" << endl; cout << " 3. Return to Main Menu." << endl; cout << endl; cin >> choice; if (choice >= 1 && choice <=4) // Ensures choice is within the range of menu options validChoice = true; else while (validChoice==false) { cout << "Invalid selection. Try again: "; cin >> choice; cout << endl; if (choice >= 1 && choice <=4) validChoice = true; } Sleep(2500); system("cls"); } return choice; } //end of Memory Game menu function void Rename(Player player, string newName) { // renames a player bool found = false; int i=0; ofstream out; out.open (newfile); cout << "Changing name..." <<endl; cout << player.score << " " << newName << " " << player.gender << " " << player.attempt << endl; player.name=newName; cout << "Saving changes..." <<endl; Sleep(1000); cout << "Successfully changed player name. " <<endl; } //initialises data values upon each new game void Init(Player player[], int stars[]) { //Initialising Highscore struct int i=0; for (i=0;i<100;i++) { player[i].score = 0; player[i].name =" "; player[i].gender =' '; player[i].attempt=0; } for (i=0;i<100;i++) { stars[i]=0; } } //read player data from the high scores list int readPlayer (Player player[]) { //opening files: cout << "Opening file..." << endl<<endl; ifstream in; in.open(filename); if (!in.is_open()) { Sleep(500); cout << "Input file could not open - No highscores found." << endl <<endl; return 404; //ERROR 404 - File not found } else { Sleep(500); cout << "Input file opened - Highscores retrieved." << endl<<endl; } int i=0; int score=0; in >> score; //while not -1 and within range while (score>=0 && i<100) { player[i].score = score; in >>player[i].name; in >>player[i].gender; in >>player[i].attempt; i++; in >> score; }//end of While storing data in the array cout << i << " players' data stored in array." <<endl <<endl; return i; } //read player data from the high scores list int readWords (string Words[]) { //Word lists ifstream wordsin; wordsin.open(wordlist); if (!wordsin.is_open()) { Sleep(500); cout << "Word list could not be retrieved!" << endl <<endl; return 404; //ERROR 404 - File not found } else { cout << "Word list retrieved." << endl<<endl; } int i=0; string w; wordsin >> w; while (w!="END") { //words list Words[i]=w; // store it in array wordsin >> w; i++; } cout << i << " words retrieved." <<endl; return i; } //Main function int main() { //Variables: int i, sel; int icurrent; // position in the array of the current player; bool found=false; string searchName=" "; string name=" ", word=" ", ans; int score=0, check=0; char gender=' '; int numOfdata=0; //Data Structures: Player player[100]; string words[20]; int stars[9]; ofstream out; out.open(newfile); //Program execution cout << " \t\tMEMORY GAME" << endl; cout << " ================================================" << endl; cout << endl; //Initialise data structures and arrays Init(player,stars); //Storing data cout << "Storing data..." <<endl <<endl; numOfdata = readPlayer(player); cout << "Launching main menu..."<<endl <<endl; Sleep(2000); //Main Menu options while (sel!=QUIT) { sel = menu(); //Selection 1 - Sum and Average words remembered by each gender if (sel==1) { //variables for this selection 1 int sum_males=0, sum_females=0; int numOfmales=0, numOffemales=0; float avgscore_males,avgscore_females; //traversing array to find the sum of males and sum of female players for (i=0;i<numOfdata;i++) { if (player[i].gender=='M') { numOfmales++; sum_males+= player[i].score; } else { if (player[i].gender=='F') { numOffemales++; sum_females+=player[i].score; } } } //Calculating averages avgscore_males=ceil (sum_males*1.0/numOfmales); avgscore_females=ceil (sum_females*1.0/numOffemales); //Outputs cout << "Total sum of words remembered by men = " << sum_males << " words." <<endl; cout << "Total sum of words remembered by women = " << sum_females << " words." <<endl <<endl; cout << "Average number of words remembered by men = " << avgscore_males << " out of 20"<<endl; cout << "Average number of words remembered by women = " << avgscore_females << " out of 20"<< endl <<endl; //Which gender remembered more words if (avgscore_males > avgscore_females) { cout << "Men remembered more words than Women." <<endl <<endl; } else { if (avgscore_males < avgscore_females) { cout << "Women remembered more words than Men." <<endl <<endl; } else { if (avgscore_males = avgscore_females) { cout << "Men and Women remembered approx. the same amount of words." <<endl <<endl; } } } system("pause"); } //end of selection 1 //Selection 2 - Percentage of attempts of males to females if (sel==2) { //Variables for this section int attempts_males=0, attempts_females=0; //sum of the attempts for males and females respectively float pAttempts_males=0, pAttempts_females=0; //percentage of those attempts for each gender //traversing the array to find the sum of all the attempts for both genders for (i=0;i<numOfdata;i++) { if (player[i].gender=='M') { attempts_males+= player[i].attempt; } else { if (player[i].gender=='F') { attempts_females+= player[i].attempt; } } } //calculating the percentage of attempts for each gender pAttempts_males=attempts_males*100.0/(attempts_males+attempts_females); pAttempts_females = 100 - pAttempts_males; cout << "Total attempts by all players: " << (attempts_females+attempts_males) <<endl; cout << fixed << setprecision(2) << "Percentage of attempts taken by males = " << pAttempts_males << "%" << endl <<endl; cout << fixed << setprecision(2) << "Percentage of attempts taken by females = " << pAttempts_females << "%" <<endl <<endl; //who played more attempts if (pAttempts_males>pAttempts_females){ cout << "Therefore the males took more attempts." <<endl <<endl; } else { if (pAttempts_males<pAttempts_females){ cout << "Therefore the females took more attempts." <<endl <<endl; } else { if (pAttempts_males==pAttempts_females){ cout << "Therefore the males and females took the same amount of attempts." <<endl <<endl; } } } system("pause"); } //end of Selection 2 //Selection 3 - Top players if (sel==3) { //Variables for this selection int topScore=player[0].score; int min_attempts = player[0].attempt; cout << "The top player is the player who remembered the most words with the least attempts: " <<endl; cout << "Top player(s): " <<endl; //Finding the top player(s) for (i=0;i<numOfdata;i++) { if ((player[i].score>topScore) && (player[i].attempt<min_attempts)) { topScore=player[i].score; min_attempts = player[i].attempt; } } //taking into account who has the least number of attempts as well as the highest number of words recalled for (i=0;i<numOfdata;i++) { if ((player[i].score==topScore) && (player[i].attempt==min_attempts)) { cout << player[i].name << " remembered " << topScore << " words in " <<min_attempts << " attempts." <<endl; } } system("pause"); } //end of Selection 3 //Selection 4 - Highest and lowest word count by both genders if (sel==4) { //Variables for this selection int max_males, max_females; int min_males, min_females; max_males = max_females= min_males = min_females = player[0].score; //finding the highest and lowest score for males and females for (i=0;i<numOfdata;i++) { if (player[i].score>=max_males && player[i].gender=='M') { max_males=player[i].score; } else{ if (player[i].score>=max_females && player[i].gender=='F') { max_females=player[i].score; } } if (player[i].score<min_males && player[i].gender=='M') { min_males=player[i].score; } else { if (player[i].score<min_females && player[i].gender=='F') { min_females=player[i].score; } } } cout << "The highest number of words recalled by a woman is: " << max_females << endl; cout << "The highest number of words recalled by a man is: " << max_males << endl<<endl; cout << "The lowest number of words recalled by a woman is: " << min_females << endl; cout << "The lowest number of words recalled by a man is: " << min_males << endl<<endl; system("pause"); } //end of Selection 4 //Selection 5 - Renaming a player and saving it to the output file if (sel==5) { //Variables for this selection string OGname=" ",newName=" "; cout << "Renaming process..."<<endl; cout << "Please enter the original player name which you would like to change: "; cin >> OGname; bool found=false; i=0; while (found == false && i<numOfdata) { if (OGname==player[i].name) { found = true; break; } found = false; if (i>=numOfdata&&found==false) { i=0; cout << "No player found with that name."<<endl; cout << "Please enter the original player name which you would like to change: "; cin >> OGname; } i++; } cout << "Please enter the new player name to replace " << OGname << ": "; cin >> newName; Rename(player[i],newName); //using Rename function to change the player name //Saving changes for (i=0;i<numOfdata;i++) { out << player[i].score << " " << player[i].name << " " << player[i].gender << " " << player[i].attempt << endl; } out << "-1" <<endl; system("pause"); }//end of selection 5 //Selection 6 - Number of players who remembered x words or more if (sel==6) { //Variables for this selection i=0; //resetting i int x=0, xCount=0; cout << "Please enter a number, x. This will check the number of players who scored x or more." <<endl; cin >> x; while (x>=numOfdata) { cout << "Sorry. Only up to " << numOfdata << " were tested. Enter a valid number: "; cin >> x; } //counting the number of players who scored above the user-enetered variable, x for (i=0;i<numOfdata;i++) { if (player[i].score>=x) { xCount++; } } cout << xCount << " players scored " << x << " or more." <<endl; system("pause"); } //end of Selection 6 //Selection 7 - Graph of all player's scores if (sel==7) { for (i=0;i<9;i++) { stars[i]=0; } for (i=0;i<numOfdata;i++) { //Finding values for graph if (player[i].score<=4) { stars[0]++; } if (player[i].score>=5 && player[i].score<=6) { stars[1]++; } if (player[i].score>=7 && player[i].score<=8) { stars[2]++; } if (player[i].score>=9 && player[i].score<=10) { stars[3]++; } if (player[i].score>=11 && player[i].score<=12) { stars[4]++; } if (player[i].score>=13 && player[i].score<=14) { stars[5]++; } if (player[i].score>=15 && player[i].score<=16) { stars[6]++; } if (player[i].score>=17 && player[i].score<=18) { stars[7]++; } if (player[i].score>=19 && player[i].score<=20) { stars[8]++; } }//end of for loop //Outputting the graph cout << "~ Graph showing the number of words (scores) for all players: ~ "<< endl <<endl; cout << "Words | Stars"<<endl; cout << "19-20:\t|"; printStars(stars[8]); cout << "17-18:\t|"; printStars(stars[7]); cout << "15-16:\t|"; printStars(stars[6]); cout << "13-14:\t|"; printStars(stars[5]); cout << "11-12:\t|"; printStars(stars[4]); cout << "9-10:\t|"; printStars(stars[3]); cout << "7-8:\t|"; printStars(stars[2]); cout << "5-6:\t|"; printStars(stars[1]); cout << "<=4:\t|"; printStars(stars[0]); cout << endl << endl; system("pause"); }//end of selection 7 //Selection 8 - Surprise Feature! - Memory Game if (sel==8) { sel=MG (); //launches game menu for the Memory Game if (sel==1) { //first selection in game menu found=false; cout << "Please enter your name in lowercase letters only: "; cin >> name; cout << "Please enter your gender using capital M/F: "; cin >>gender; //Faulty code - it is correct because I ran it before and it was fully functioning but i dont know why it doesnt work now //The code works but the program does not :( //search to see if it is a previous player. if it is, it adds an attempt to their file while (!found && i<numOfdata) { for (i=0;i<numOfdata;i++) { if (name==player[i].name && gender==player[i].gender){ // accounts for unisex names. eg:Alex (M) is stored differently from Alex (F) found=true; player[i].attempt++;//add attempt icurrent=i; } } if (!found) { //if not found it searches for a new location in the array to store the data if (player[i].name==" ") { icurrent=i; player[icurrent].name=name; player[icurrent].gender=gender; player[icurrent].attempt=1; i=0; } } }//end of while int numOfwords = readWords(words); //game start cout << "Try to remember as much words as you can!"; Sleep(2500); Timer("Game starts in: ", 3); //Timer function for (i=0;i<numOfwords;i++) { cout << endl; cout << "\t" << words[i]; Sleep(3000); system("CLS"); } cout << "What words do you remember? Type them here in any order.\n Type 0 to check your answers!" <<endl <<endl; cin >>ans; check = 0; //checking how many you got correct while (check <=20 && ans!="0") { for (i=0;i<20;i++) { if (ans==words[i]) { words[i]="correct"; score++; check++; } } if (i>20) { i=0; } cin>>ans; }//end of while cout << "You remembered " <<score <<" words!" <<endl; cout << "Saving game data to file..." <<endl; //saving new data out << player[icurrent].score << " " << player[icurrent].name << " " << player[icurrent].gender << " " << player[icurrent].attempt <<endl; Sleep (1500); cout << "Saved!" <<endl; system("pause"); }//end of sel2 ==1 if (sel==2) { cout << "\t How to play the memory game: " <<endl; cout << "When you start the game, words will flash on screen one by one." << endl; cout << "After all " << numOfdata << " words have been displayed, type as many as you can remember in any order." <<endl; cout << "Your score is the number of words remembered out of the " << numOfdata << "." << endl; cout << "Enjoy. Your game data is automatically saved after each attempt." <<endl; system("pause"); sel=MG(); } //end of 2nd selection in game menu else { //return to main menu }//end of 3rd selection from game menu }//end of selection 8 if (sel==9) { //save data to files & view data cout << "Data saved to '" << newfile << endl; for (i=0;i<numOfdata;i++) { out << player[i].score << " " << player[i].name << " " << player[i].gender << " " << player[i].attempt <<endl; cout << player[i].score << " " << player[i].name << " " << player[i].gender << " " << player[i].attempt <<endl; } out << -1; system("pause"); }//end of selection 9 } //end of all Selections }
19,125
8,022
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /***************************************************************************************** ******************** This file was generated by sksllex. Do not edit. ******************* *****************************************************************************************/ #include "src/sksl/SkSLLexer.h" namespace SkSL { using State = uint16_t; static const uint8_t INVALID_CHAR = 18; static const int8_t kMappings[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 4, 3, 5, 6, 7, 8, 3, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 22, 22, 23, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 32, 33, 34, 31, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 37, 35, 38, 35, 35, 39, 35, 35, 40, 3, 41, 42, 43, 3, 44, 45, 46, 47, 48, 49, 50, 51, 52, 35, 53, 54, 55, 56, 57, 58, 35, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71}; struct IndexEntry { uint16_t type : 2; uint16_t pos : 14; }; struct FullEntry { State data[72]; }; struct CompactEntry { State v0 : 6; State v1 : 9; State v2 : 9; uint8_t data[18]; }; static constexpr FullEntry kFull[] = { { 0, 2, 3, 4, 5, 7, 9, 14, 16, 19, 20, 21, 23, 26, 27, 30, 35, 41, 60, 60, 60, 60, 60, 60, 62, 63, 64, 68, 70, 74, 75, 84, 84, 84, 84, 84, 84, 84, 84, 84, 85, 86, 87, 84, 90, 100, 105, 121, 141, 153, 169, 174, 182, 84, 206, 216, 223, 249, 254, 270, 276, 348, 365, 381, 393, 84, 84, 84, 398, 399, 402, 403, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 50, 50, 50, 50, 50, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 58, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 50, 50, 50, 50, 50, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 51, 51, 51, 51, 51, 51, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 61, 61, 61, 61, 61, 61, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 106, 10, 10, 10, 10, 10, 10, 10, 10, 10, 109, 10, 10, 112, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 10, 10, 10, 10, 122, 10, 10, 10, 128, 10, 10, 10, 10, 134, 10, 10, 10, 10, 10, 138, 10, 10, 10, 10, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 142, 10, 145, 10, 10, 10, 10, 10, 10, 10, 10, 147, 10, 10, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 154, 10, 10, 10, 10, 10, 10, 10, 158, 10, 161, 10, 10, 164, 10, 10, 10, 10, 10, 166, 10, 10, 10, 10, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 185, 10, 10, 189, 192, 10, 10, 194, 10, 200, 10, 10, 10, 10, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 255, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 259, 10, 10, 266, 10, 10, 10, 10, 10, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 277, 10, 10, 10, 10, 10, 10, 10, 309, 313, 10, 10, 10, 10, 10, 10, 10, 331, 339, 10, 343, 10, 10, 10, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 283, 290, 301, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 306, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 10, 10, 10, 10, 10, 349, 10, 10, 355, 10, 10, 10, 10, 10, 10, 10, 357, 10, 10, 10, 10, 10, 10, 360, 10, 0, 0, 0, 0, }, }; static constexpr CompactEntry kCompact[] = { {0, 0, 3, { 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 6, { 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 8, { 0, 0, 0, 0, 0, 0, 0, 192, 255, 255, 192, 255, 255, 255, 255, 255, 255, 0, }}, {0, 0, 8, { 0, 0, 0, 0, 252, 255, 0, 192, 255, 255, 192, 255, 255, 255, 255, 255, 255, 0, }}, {0, 10, 11, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 0, 10, { 0, 0, 0, 0, 252, 255, 0, 192, 255, 255, 192, 255, 255, 255, 255, 255, 255, 0, }}, {0, 10, 12, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 13, { 0, 0, 0, 0, 168, 171, 0, 128, 170, 170, 128, 170, 170, 170, 170, 170, 170, 0, }}, {0, 0, 15, { 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 17, 18, { 0, 0, 2, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 22, { 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 24, 25, { 0, 0, 0, 2, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 28, 29, { 0, 0, 0, 32, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 31, { 0, 0, 0, 0, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 31, 32, { 0, 0, 0, 0, 168, 170, 0, 0, 48, 0, 0, 0, 3, 0, 0, 0, 0, 0, }}, {0, 33, 34, { 0, 0, 0, 34, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 34, { 0, 0, 0, 0, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {36, 39, 40, { 0, 0, 64, 0, 2, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 36, 37, { 168, 170, 234, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, }}, {0, 36, 38, { 168, 170, 170, 170, 171, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, }}, {0, 0, 39, { 204, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, }}, {0, 43, 47, { 0, 0, 0, 0, 168, 170, 0, 0, 48, 0, 0, 0, 3, 0, 0, 0, 0, 0, }}, {0, 43, 44, { 0, 0, 0, 0, 168, 170, 0, 0, 48, 0, 0, 0, 3, 0, 0, 0, 0, 0, }}, {0, 45, 46, { 0, 0, 0, 34, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 46, { 0, 0, 0, 0, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 48, 49, { 0, 0, 0, 34, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 49, { 0, 0, 0, 0, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 53, 54, { 0, 0, 0, 34, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 54, { 0, 0, 0, 0, 252, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 59, { 0, 0, 0, 0, 252, 255, 0, 192, 63, 0, 0, 255, 15, 0, 0, 0, 0, 0, }}, {0, 57, 59, { 0, 0, 0, 0, 252, 255, 0, 192, 63, 32, 0, 255, 15, 0, 0, 32, 0, 0, }}, {0, 65, 67, { 0, 0, 0, 0, 0, 0, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 66, { 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 69, { 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 71, 72, { 0, 0, 0, 0, 0, 0, 128, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 0, 73, { 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }}, {0, 76, 78, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 0, }}, {0, 0, 77, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, }}, {0, 0, 79, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, }}, {0, 0, 80, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, }}, {0, 0, 81, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, }}, {0, 0, 82, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, }}, {0, 0, 83, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, }}, {0, 88, 89, { 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, }}, {10, 91, 93, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 85, 85, 85, 94, 85, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 234, 170, 170, 170, 0, }}, {0, 10, 94, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 95, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 96, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 97, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 174, 170, 170, 170, 170, 170, 0, }}, {0, 10, 98, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 99, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 101, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 102, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 103, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 104, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 174, 170, 170, 170, 0, }}, {0, 10, 107, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {10, 92, 108, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 87, 85, 85, 89, 85, 0, }}, {0, 10, 110, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 111, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 113, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {10, 114, 116, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 85, 85, 85, 94, 85, 0, }}, {0, 10, 115, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 117, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 118, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 119, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 120, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 123, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 174, 170, 170, 170, 170, 0, }}, {0, 10, 124, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 125, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 126, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 127, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 129, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 130, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 131, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 132, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 133, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 234, 170, 170, 170, 170, 170, 0, }}, {0, 10, 135, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 136, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 174, 170, 170, 170, 170, 170, 0, }}, {0, 10, 137, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 139, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 140, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 232, 175, 0, 128, 170, 170, 128, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 143, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 144, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 146, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 148, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 149, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 150, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 151, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 152, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 155, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 156, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 157, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 159, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 170, 174, 0, }}, {0, 10, 160, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 234, 170, 170, 170, 170, 170, 0, }}, {0, 10, 162, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 163, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 165, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 167, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 168, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {10, 170, 172, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 85, 101, 93, 85, 85, 0, }}, {0, 10, 171, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 192, 170, 170, 170, 170, 170, 170, 0, }}, {0, 0, 171, { 0, 0, 0, 0, 252, 255, 0, 192, 255, 255, 192, 255, 255, 255, 255, 255, 255, 0, }}, {0, 10, 173, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 174, 170, 170, 0, }}, {10, 175, 179, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 85, 86, 85, 213, 85, 0, }}, {0, 10, 176, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 186, 170, 170, 170, 170, 0, }}, {0, 10, 177, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 234, 170, 170, 170, 170, 0, }}, {0, 10, 178, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 180, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 181, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {10, 183, 184, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 89, 85, 87, 85, 85, 0, }}, {0, 10, 186, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 187, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 188, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 190, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 191, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 193, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 195, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 196, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 197, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 174, 170, 170, 170, 170, 0, }}, {0, 10, 198, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 199, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 201, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 202, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 203, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 204, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 205, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {10, 207, 212, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 86, 85, 85, 93, 85, 85, 0, }}, {0, 10, 208, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 170, 186, 0, }}, {0, 10, 209, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 174, 170, 170, 0, }}, {0, 10, 210, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 211, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {10, 213, 214, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 85, 85, 86, 85, 87, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 186, 170, 170, 170, 170, 0, }}, {0, 10, 215, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 217, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 218, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 234, 170, 170, 170, 170, 170, 0, }}, {0, 10, 219, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 220, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 221, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 234, 170, 170, 170, 0, }}, {0, 10, 222, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {10, 224, 231, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 86, 85, 85, 93, 85, 85, 0, }}, {0, 10, 225, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 234, 170, 170, 170, 0, }}, {0, 10, 226, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 227, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 228, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 229, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 230, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {10, 232, 238, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 85, 86, 117, 85, 85, 0, }}, {0, 10, 233, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 234, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 235, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 236, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 237, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 239, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 240, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 241, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 242, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 243, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 244, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 245, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 246, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 247, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 234, 170, 0, }}, {0, 10, 248, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 250, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 251, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 252, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 253, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 256, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 257, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 174, 170, 170, 170, 0, }}, {0, 10, 258, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 260, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 261, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 262, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 263, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 264, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 265, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 174, 170, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 267, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 174, 170, 170, 170, 170, 170, 0, }}, {0, 10, 268, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 269, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 271, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 272, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 273, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 274, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 275, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 278, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 234, 170, 170, 170, 0, }}, {0, 10, 279, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 280, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 281, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 282, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 284, { 0, 0, 0, 0, 168, 170, 0, 128, 174, 170, 128, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 285, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 174, 128, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 286, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 234, 170, 170, 170, 170, 0, }}, {0, 10, 287, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 288, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 234, 170, 170, 170, 170, 170, 0, }}, {0, 10, 289, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 174, 170, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 170, 171, 0, }}, {0, 10, 291, { 0, 0, 0, 0, 168, 170, 0, 128, 174, 170, 128, 170, 170, 170, 170, 170, 170, 0, }}, {10, 285, 292, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 91, 64, 85, 85, 85, 85, 85, 85, 0, }}, {0, 10, 293, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 294, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 295, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 296, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 174, 128, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 297, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 234, 170, 170, 170, 170, 0, }}, {0, 10, 298, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 299, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 234, 170, 170, 170, 170, 170, 0, }}, {0, 10, 300, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 174, 170, 170, 0, }}, {0, 10, 302, { 0, 0, 0, 0, 168, 170, 0, 128, 174, 170, 128, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 303, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 171, 128, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 304, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 305, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 307, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 308, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 174, 170, 170, 170, 170, 170, 0, }}, {0, 10, 310, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 170, 234, 0, }}, {0, 10, 311, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 312, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 174, 170, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 174, 170, 170, 170, 170, 0, }}, {0, 10, 314, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 192, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 315, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 234, 170, 170, 170, 170, 0, }}, {0, 10, 316, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 317, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 318, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 192, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 319, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {0, 10, 320, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 321, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 234, 170, 170, 170, 170, 170, 0, }}, {0, 10, 322, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 323, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 192, 170, 170, 170, 170, 170, 170, 0, }}, {0, 10, 324, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 325, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 174, 170, 170, 170, 170, 0, }}, {0, 10, 326, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 174, 170, 170, 170, 170, 0, }}, {0, 10, 327, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 328, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 329, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 330, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 171, 170, 0, }}, {10, 332, 335, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 86, 85, 85, 213, 85, 85, 0, }}, {0, 10, 333, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 334, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 336, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 337, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 338, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 340, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 341, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 342, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 92, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 344, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 345, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 346, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 186, 170, 170, 170, 170, 170, 0, }}, {0, 10, 347, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 234, 170, 170, 170, 170, 0, }}, {0, 10, 350, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 234, 170, 170, 170, 0, }}, {0, 10, 351, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 352, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 353, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 354, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 356, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 358, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 186, 170, 0, }}, {0, 10, 359, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 361, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 186, 170, 170, 0, }}, {0, 10, 362, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 363, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 234, 170, 170, 170, 170, 170, 0, }}, {0, 10, 364, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {10, 366, 378, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 85, 85, 86, 87, 85, 0, }}, {10, 367, 373, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 85, 86, 85, 87, 85, 0, }}, {10, 368, 372, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 85, 89, 85, 93, 85, 85, 0, }}, {0, 10, 369, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 174, 170, 170, 0, }}, {0, 10, 370, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 371, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 234, 170, 170, 170, 0, }}, {0, 10, 374, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 375, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 186, 170, 170, 170, 170, 0, }}, {0, 10, 376, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 377, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 10, 379, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 380, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {10, 382, 387, { 0, 0, 0, 0, 84, 85, 0, 64, 85, 85, 64, 86, 85, 85, 93, 85, 85, 0, }}, {0, 10, 383, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 234, 170, 170, 0, }}, {0, 10, 384, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 170, 186, 0, }}, {0, 10, 385, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 386, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 171, 170, 170, 0, }}, {0, 10, 388, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 389, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 171, 170, 170, 170, 170, 170, 0, }}, {0, 10, 390, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 170, 170, 174, 170, 0, }}, {0, 10, 391, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 392, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 394, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 234, 170, 170, 170, 170, 0, }}, {0, 10, 395, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 171, 170, 170, 170, 0, }}, {0, 10, 396, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 170, 186, 170, 170, 170, 0, }}, {0, 10, 397, { 0, 0, 0, 0, 168, 170, 0, 128, 170, 170, 128, 170, 171, 170, 170, 170, 170, 0, }}, {0, 400, 401, { 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, }}, }; static constexpr IndexEntry kIndices[] = { {0, 0}, {1, 0}, {2, 0}, {2, 0}, {0, 0}, {2, 1}, {0, 0}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 5}, {2, 8}, {0, 0}, {2, 9}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {2, 10}, {0, 0}, {2, 11}, {0, 0}, {0, 0}, {0, 0}, {2, 12}, {0, 0}, {0, 0}, {2, 13}, {2, 14}, {2, 15}, {2, 16}, {2, 16}, {2, 17}, {2, 18}, {2, 19}, {0, 0}, {2, 20}, {0, 0}, {1, 1}, {2, 21}, {2, 22}, {2, 23}, {2, 24}, {2, 24}, {2, 25}, {2, 26}, {2, 26}, {1, 2}, {1, 3}, {2, 27}, {2, 28}, {2, 28}, {0, 0}, {0, 0}, {0, 0}, {2, 29}, {2, 30}, {1, 4}, {1, 4}, {0, 0}, {0, 0}, {2, 31}, {2, 32}, {0, 0}, {0, 0}, {2, 33}, {0, 0}, {2, 34}, {0, 0}, {2, 35}, {0, 0}, {0, 0}, {2, 36}, {2, 37}, {0, 0}, {2, 38}, {2, 39}, {2, 40}, {2, 41}, {2, 42}, {0, 0}, {2, 5}, {0, 0}, {0, 0}, {2, 43}, {0, 0}, {0, 0}, {2, 44}, {2, 45}, {2, 5}, {2, 46}, {2, 47}, {2, 48}, {2, 49}, {2, 50}, {2, 51}, {2, 52}, {2, 53}, {2, 54}, {2, 55}, {2, 56}, {2, 5}, {1, 5}, {2, 57}, {2, 58}, {2, 5}, {2, 59}, {2, 60}, {2, 61}, {2, 62}, {2, 63}, {2, 64}, {2, 5}, {2, 65}, {2, 66}, {2, 67}, {2, 68}, {2, 5}, {1, 6}, {2, 69}, {2, 70}, {2, 71}, {2, 72}, {2, 73}, {2, 5}, {2, 74}, {2, 75}, {2, 76}, {2, 77}, {2, 78}, {2, 5}, {2, 79}, {2, 80}, {2, 81}, {2, 52}, {2, 82}, {2, 83}, {2, 84}, {1, 7}, {2, 85}, {2, 86}, {2, 5}, {2, 87}, {2, 45}, {2, 88}, {2, 89}, {2, 90}, {2, 91}, {2, 92}, {2, 93}, {1, 8}, {2, 94}, {2, 95}, {2, 96}, {2, 5}, {2, 97}, {2, 98}, {2, 99}, {2, 100}, {2, 101}, {2, 5}, {2, 102}, {2, 5}, {2, 103}, {2, 104}, {2, 84}, {2, 105}, {2, 106}, {2, 107}, {2, 108}, {2, 109}, {2, 110}, {2, 111}, {2, 112}, {2, 113}, {2, 5}, {2, 114}, {2, 115}, {2, 84}, {2, 116}, {2, 5}, {1, 9}, {2, 117}, {2, 118}, {2, 119}, {2, 5}, {2, 120}, {2, 121}, {2, 5}, {2, 122}, {2, 123}, {2, 124}, {2, 125}, {2, 126}, {2, 127}, {2, 128}, {2, 52}, {2, 129}, {2, 130}, {2, 131}, {2, 132}, {2, 133}, {2, 123}, {2, 134}, {2, 135}, {2, 136}, {2, 137}, {2, 138}, {2, 5}, {2, 139}, {2, 140}, {2, 141}, {2, 5}, {2, 142}, {2, 143}, {2, 144}, {2, 145}, {2, 146}, {2, 147}, {2, 5}, {2, 148}, {2, 149}, {2, 150}, {2, 151}, {2, 152}, {2, 153}, {2, 154}, {2, 52}, {2, 155}, {2, 156}, {2, 157}, {2, 158}, {2, 159}, {2, 160}, {2, 5}, {2, 161}, {2, 162}, {2, 163}, {2, 164}, {2, 165}, {2, 166}, {2, 167}, {2, 168}, {2, 169}, {2, 170}, {2, 5}, {2, 171}, {2, 172}, {2, 173}, {2, 174}, {2, 123}, {1, 10}, {2, 175}, {2, 176}, {2, 177}, {2, 99}, {2, 178}, {2, 179}, {2, 180}, {2, 181}, {2, 182}, {2, 183}, {2, 184}, {2, 185}, {2, 186}, {2, 187}, {2, 188}, {2, 189}, {2, 190}, {2, 191}, {2, 192}, {2, 193}, {2, 5}, {1, 11}, {2, 194}, {2, 195}, {2, 196}, {2, 197}, {2, 198}, {1, 12}, {2, 199}, {2, 200}, {2, 201}, {2, 202}, {2, 203}, {2, 204}, {2, 205}, {2, 206}, {2, 207}, {2, 208}, {2, 209}, {2, 210}, {2, 211}, {2, 212}, {2, 213}, {2, 214}, {2, 215}, {2, 205}, {2, 216}, {2, 217}, {2, 218}, {2, 219}, {2, 123}, {2, 220}, {2, 221}, {2, 52}, {2, 222}, {2, 223}, {2, 224}, {2, 225}, {2, 226}, {2, 227}, {2, 228}, {2, 229}, {2, 230}, {2, 231}, {2, 232}, {2, 233}, {2, 234}, {2, 235}, {2, 236}, {2, 237}, {2, 238}, {2, 239}, {2, 240}, {2, 241}, {2, 242}, {2, 5}, {2, 243}, {2, 244}, {2, 245}, {2, 188}, {2, 246}, {2, 247}, {2, 248}, {2, 5}, {2, 249}, {2, 250}, {2, 251}, {2, 252}, {2, 253}, {2, 254}, {2, 255}, {2, 256}, {2, 5}, {1, 13}, {2, 257}, {2, 258}, {2, 259}, {2, 260}, {2, 261}, {2, 52}, {2, 262}, {2, 61}, {2, 263}, {2, 264}, {2, 5}, {2, 265}, {2, 266}, {2, 267}, {2, 268}, {2, 225}, {2, 269}, {2, 270}, {2, 271}, {2, 272}, {2, 273}, {2, 274}, {2, 5}, {2, 184}, {2, 275}, {2, 276}, {2, 277}, {2, 278}, {2, 99}, {2, 279}, {2, 280}, {2, 140}, {2, 281}, {2, 282}, {2, 283}, {2, 284}, {2, 285}, {2, 140}, {2, 286}, {2, 287}, {2, 288}, {2, 289}, {2, 290}, {2, 52}, {2, 291}, {2, 292}, {2, 293}, {2, 294}, {2, 5}, {0, 0}, {2, 295}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, }; State get_transition(int transition, int state) { IndexEntry index = kIndices[state]; if (index.type == 0) { return 0; } if (index.type == 1) { return kFull[index.pos].data[transition]; } const CompactEntry& entry = kCompact[index.pos]; int value = entry.data[transition >> 2]; value >>= 2 * (transition & 3); value &= 3; State table[] = {0, entry.v0, entry.v1, entry.v2}; return table[value]; } static const int8_t kAccepts[404] = { -1, -1, 84, 84, 87, 63, 68, 87, 38, 37, 37, 37, 37, 35, 53, 77, 58, 62, 82, 39, 40, 51, 75, 49, 47, 73, 46, 50, 48, 74, 45, 1, -1, -1, 1, 52, -1, -1, 86, 85, 76, 2, 1, 1, -1, -1, 1, -1, -1, 1, 2, 3, -1, -1, 1, 3, 2, 2, -1, 2, 2, 2, 65, 83, 70, 54, 78, 72, 66, 67, 69, 71, 55, 79, 64, 87, -1, 7, -1, -1, -1, -1, -1, 13, 37, 43, 44, 57, 81, 61, 37, 37, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 16, 37, 37, 37, 14, 37, 37, 37, 37, 37, 37, 24, 37, 37, 37, 37, 17, 37, 37, 37, 37, 37, 37, 15, 37, 37, 37, 37, 37, 18, 11, 37, 37, 37, 37, 37, 37, 37, 37, 37, 8, 37, 37, 37, 37, 37, 37, 36, 37, 37, 37, 37, 37, 5, 37, 37, 37, 37, 37, 25, 37, 9, 37, 37, 37, 37, 37, 36, 37, 37, 37, 37, 37, 37, 32, 37, 37, 37, 37, 6, 20, 37, 37, 37, 27, 37, 37, 22, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 31, 37, 37, 37, 34, 37, 37, 37, 37, 37, 37, 33, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 28, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 26, 37, 37, 21, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 19, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 29, 37, 37, 37, 37, 37, 37, 37, 30, 37, 37, 37, 37, 37, 37, 37, 37, 12, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 4, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 23, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 10, 41, 56, 80, 60, 42, 59, }; Token Lexer::next() { // note that we cheat here: normally a lexer needs to worry about the case // where a token has a prefix which is not itself a valid token - for instance, // maybe we have a valid token 'while', but 'w', 'wh', etc. are not valid // tokens. Our grammar doesn't have this property, so we can simplify the logic // a bit. int32_t startOffset = fOffset; if (startOffset == (int32_t)fText.length()) { return Token(Token::Kind::TK_END_OF_FILE, startOffset, 0); } State state = 1; for (;;) { if (fOffset >= (int32_t)fText.length()) { if (kAccepts[state] == -1) { return Token(Token::Kind::TK_END_OF_FILE, startOffset, 0); } break; } uint8_t c = (uint8_t)fText[fOffset]; if (c <= 8 || c >= 127) { c = INVALID_CHAR; } State newState = get_transition(kMappings[c], state); if (!newState) { break; } state = newState; ++fOffset; } Token::Kind kind = (Token::Kind)kAccepts[state]; return Token(kind, startOffset, fOffset - startOffset); } } // namespace SkSL
61,160
39,466
// // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Official repository: https://github.com/boostorg/beast // #ifndef BOOST_BEAST_HTTP_FILE_BODY_HPP #define BOOST_BEAST_HTTP_FILE_BODY_HPP #include <boost/beast/core/file.hpp> #include <boost/beast/http/basic_file_body.hpp> #include <boost/assert.hpp> #include <boost/optional.hpp> #include <algorithm> #include <cstdio> #include <cstdint> #include <utility> namespace boost { namespace beast { namespace http { /// A message body represented by a file on the filesystem. using file_body = basic_file_body<file>; } // http } // beast } // boost #include <boost/beast/http/impl/file_body_win32.ipp> #endif
885
344
//===- CVSymbolVisitor.cpp --------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h" #include "llvm/DebugInfo/CodeView/CodeViewError.h" #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" using namespace llvm; using namespace llvm::codeview; CVSymbolVisitor::CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks) : Callbacks(Callbacks) {} template <typename T> static Error visitKnownRecord(CVSymbol &Record, SymbolVisitorCallbacks &Callbacks) { SymbolRecordKind RK = static_cast<SymbolRecordKind>(Record.Type); T KnownRecord(RK); if (auto EC = Callbacks.visitKnownRecord(Record, KnownRecord)) return EC; return Error::success(); } static Error finishVisitation(CVSymbol &Record, SymbolVisitorCallbacks &Callbacks) { switch (Record.Type) { default: if (auto EC = Callbacks.visitUnknownSymbol(Record)) return EC; break; #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ case EnumName: { \ if (auto EC = visitKnownRecord<Name>(Record, Callbacks)) \ return EC; \ break; \ } #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) \ SYMBOL_RECORD(EnumVal, EnumVal, AliasName) #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" } if (auto EC = Callbacks.visitSymbolEnd(Record)) return EC; return Error::success(); } Error CVSymbolVisitor::visitSymbolRecord(CVSymbol &Record) { if (auto EC = Callbacks.visitSymbolBegin(Record)) return EC; return finishVisitation(Record, Callbacks); } Error CVSymbolVisitor::visitSymbolRecord(CVSymbol &Record, uint32_t Offset) { if (auto EC = Callbacks.visitSymbolBegin(Record, Offset)) return EC; return finishVisitation(Record, Callbacks); } Error CVSymbolVisitor::visitSymbolStream(const CVSymbolArray &Symbols) { for (auto I : Symbols) { if (auto EC = visitSymbolRecord(I)) return EC; } return Error::success(); } Error CVSymbolVisitor::visitSymbolStream(const CVSymbolArray &Symbols, uint32_t InitialOffset) { for (auto I : Symbols) { if (auto EC = visitSymbolRecord(I, InitialOffset)) return EC; InitialOffset += I.length(); } return Error::success(); }
2,797
821
//===----------------------------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03 // <tuple> // template <class... Types> class tuple; // ~tuple(); // C++17 added: // The destructor of tuple shall be a trivial destructor // if (is_trivially_destructible_v<Types> && ...) is true. #include <tuple> #include <string> #include <cassert> #include <type_traits> #include "test_macros.h" int main(int, char**) { static_assert(std::is_trivially_destructible< std::tuple<> >::value, ""); static_assert(std::is_trivially_destructible< std::tuple<void*> >::value, ""); static_assert(std::is_trivially_destructible< std::tuple<int, float> >::value, ""); static_assert(!std::is_trivially_destructible< std::tuple<std::string> >::value, ""); static_assert(!std::is_trivially_destructible< std::tuple<int, std::string> >::value, ""); return 0; }
1,198
402
//********************************************************* // // Copyright (c) Microsoft. All rights reserved. // This code is licensed under the MIT License (MIT). // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //********************************************************* #include "pch.h" #include "Scenario2_CardioidSound.xaml.h" using namespace SDKTemplate; using namespace Platform; using namespace Windows::Foundation; using namespace Windows::Foundation::Collections; using namespace Windows::UI::Xaml; using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Controls::Primitives; using namespace Windows::UI::Xaml::Data; using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media; using namespace Windows::UI::Xaml::Navigation; Scenario2_CardioidSound::Scenario2_CardioidSound() : _rootPage(MainPage::Current) { InitializeComponent(); auto hr = _cardioidSound.Initialize(L"assets//MonoSound.wav"); if (SUCCEEDED(hr)) { _timer = ref new DispatcherTimer(); _timerEventToken = _timer->Tick += ref new EventHandler<Platform::Object^>(this, &Scenario2_CardioidSound::OnTimerTick); TimeSpan timespan; timespan.Duration = 10000 / 30; _timer->Interval = timespan; EnvironmentComboBox->SelectedIndex = static_cast<int>(_cardioidSound.GetEnvironment()); _rootPage->NotifyUser("Stopped", NotifyType::StatusMessage); } else { if (hr == E_NOTIMPL) { _rootPage->NotifyUser("HRTF API is not supported on this platform. Use X3DAudio API instead - https://code.msdn.microsoft.com/XAudio2-Win32-Samples-024b3933", NotifyType::ErrorMessage); } else { throw ref new COMException(hr); } } _initialized = SUCCEEDED(hr); } Scenario2_CardioidSound::~Scenario2_CardioidSound() { if (_timerEventToken.Value != 0) { _timer->Tick -= _timerEventToken; } } void SDKTemplate::Scenario2_CardioidSound::EnvironmentComboBox_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e) { if (_initialized) { _cardioidSound.SetEnvironment(static_cast<HrtfEnvironment>(EnvironmentComboBox->SelectedIndex)); } } void SDKTemplate::Scenario2_CardioidSound::ScalingSlider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) { UpdateScalingAndOrder(); } void SDKTemplate::Scenario2_CardioidSound::OrderSlider_ValudChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) { UpdateScalingAndOrder(); } void SDKTemplate::Scenario2_CardioidSound::YawSlider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) { _yaw = static_cast<float>(e->NewValue); } void SDKTemplate::Scenario2_CardioidSound::PitchSlider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) { _pitch = static_cast<float>(e->NewValue); } void SDKTemplate::Scenario2_CardioidSound::RollSlider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) { _roll = static_cast<float>(e->NewValue); } void SDKTemplate::Scenario2_CardioidSound::PlayButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { if (_initialized) { _cardioidSound.Start(); _state = PlayState::Playing; _rootPage->NotifyUser("Playing", NotifyType::StatusMessage); } } void SDKTemplate::Scenario2_CardioidSound::StopButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { if (_initialized) { _cardioidSound.Stop(); _state = PlayState::Stopped; _rootPage->NotifyUser("Stopped", NotifyType::StatusMessage); } } void SDKTemplate::Scenario2_CardioidSound::OnTimerTick(Object^ sender, Object^ e) { // Update the sound position and orientation on every dispatcher timer tick. _cardioidSound.OnUpdate(_x, _y, _z, _pitch, _yaw, _roll); } void SDKTemplate::Scenario2_CardioidSound::UpdateScalingAndOrder() { if (_initialized) { _timer->Stop(); _cardioidSound.ConfigureApo(static_cast<float>(ScalingSlider->Value), static_cast<float>(OrderSlider->Value)); _timer->Start(); if (_state == PlayState::Playing) { _cardioidSound.Start(); } } } void SDKTemplate::Scenario2_CardioidSound::SourcePositionX_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) { _x = static_cast<float>(e->NewValue); } void SDKTemplate::Scenario2_CardioidSound::SourcePositionY_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) { _y = static_cast<float>(e->NewValue); } void SDKTemplate::Scenario2_CardioidSound::SourcePositionZ_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) { _z = static_cast<float>(e->NewValue); }
5,538
1,741
// boost::compressed_pair test program // (C) Copyright John Maddock 2000. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt). // standalone test program for <boost/call_traits.hpp> // 18 Mar 2002: // Changed some names to prevent conflicts with some new type_traits additions. // 03 Oct 2000: // Enabled extra tests for VC6. #include <iostream> #include <iomanip> #include <algorithm> #include <typeinfo> #include <boost/call_traits.hpp> #include <libs/type_traits/test/test.hpp> #include <libs/type_traits/test/check_type.hpp> #ifdef BOOST_MSVC #pragma warning(disable:4181) // : warning C4181: qualifier applied to reference type; ignored #endif // a way prevent warnings for unused variables template<class T> inline void unused_variable(const T&) {} // // struct contained models a type that contains a type (for example std::pair) // arrays are contained by value, and have to be treated as a special case: // template <class T> struct contained { // define our typedefs first, arrays are stored by value // so value_type is not the same as result_type: typedef typename boost::call_traits<T>::param_type param_type; typedef typename boost::call_traits<T>::reference reference; typedef typename boost::call_traits<T>::const_reference const_reference; typedef T value_type; typedef typename boost::call_traits<T>::value_type result_type; // stored value: value_type v_; // constructors: contained() {} contained(param_type p) : v_(p){} // return byval: result_type value()const { return v_; } // return by_ref: reference get() { return v_; } const_reference const_get()const { return v_; } // pass value: void call(param_type){} private: contained& operator=(const contained&); }; #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template <class T, std::size_t N> struct contained<T[N]> { typedef typename boost::call_traits<T[N]>::param_type param_type; typedef typename boost::call_traits<T[N]>::reference reference; typedef typename boost::call_traits<T[N]>::const_reference const_reference; typedef T value_type[N]; typedef typename boost::call_traits<T[N]>::value_type result_type; value_type v_; contained(param_type p) { std::copy(p, p+N, v_); } // return byval: result_type value()const { return v_; } // return by_ref: reference get() { return v_; } const_reference const_get()const { return v_; } void call(param_type){} private: contained& operator=(const contained&); }; #endif template <class T> contained<typename boost::call_traits<T>::value_type> test_wrap_type(const T& t) { typedef typename boost::call_traits<T>::value_type ct; return contained<ct>(t); } namespace test{ template <class T1, class T2> std::pair< typename boost::call_traits<T1>::value_type, typename boost::call_traits<T2>::value_type> make_pair(const T1& t1, const T2& t2) { return std::pair< typename boost::call_traits<T1>::value_type, typename boost::call_traits<T2>::value_type>(t1, t2); } } // namespace test using namespace std; // // struct call_traits_checker: // verifies behaviour of contained example: // template <class T> struct call_traits_checker { typedef typename boost::call_traits<T>::param_type param_type; void operator()(param_type); }; template <class T> void call_traits_checker<T>::operator()(param_type p) { T t(p); contained<T> c(t); cout << "checking contained<" << typeid(T).name() << ">..." << endl; BOOST_CHECK(t == c.value()); BOOST_CHECK(t == c.get()); BOOST_CHECK(t == c.const_get()); #ifndef __ICL //cout << "typeof contained<" << typeid(T).name() << ">::v_ is: " << typeid(&contained<T>::v_).name() << endl; cout << "typeof contained<" << typeid(T).name() << ">::value() is: " << typeid(&contained<T>::value).name() << endl; cout << "typeof contained<" << typeid(T).name() << ">::get() is: " << typeid(&contained<T>::get).name() << endl; cout << "typeof contained<" << typeid(T).name() << ">::const_get() is: " << typeid(&contained<T>::const_get).name() << endl; cout << "typeof contained<" << typeid(T).name() << ">::call() is: " << typeid(&contained<T>::call).name() << endl; cout << endl; #endif } #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template <class T, std::size_t N> struct call_traits_checker<T[N]> { typedef typename boost::call_traits<T[N]>::param_type param_type; void operator()(param_type t) { contained<T[N]> c(t); cout << "checking contained<" << typeid(T[N]).name() << ">..." << endl; unsigned int i = 0; for(i = 0; i < N; ++i) BOOST_CHECK(t[i] == c.value()[i]); for(i = 0; i < N; ++i) BOOST_CHECK(t[i] == c.get()[i]); for(i = 0; i < N; ++i) BOOST_CHECK(t[i] == c.const_get()[i]); cout << "typeof contained<" << typeid(T[N]).name() << ">::v_ is: " << typeid(&contained<T[N]>::v_).name() << endl; cout << "typeof contained<" << typeid(T[N]).name() << ">::value is: " << typeid(&contained<T[N]>::value).name() << endl; cout << "typeof contained<" << typeid(T[N]).name() << ">::get is: " << typeid(&contained<T[N]>::get).name() << endl; cout << "typeof contained<" << typeid(T[N]).name() << ">::const_get is: " << typeid(&contained<T[N]>::const_get).name() << endl; cout << "typeof contained<" << typeid(T[N]).name() << ">::call is: " << typeid(&contained<T[N]>::call).name() << endl; cout << endl; } }; #endif // // check_wrap: template <class W, class U> void check_wrap(const W& w, const U& u) { cout << "checking " << typeid(W).name() << "..." << endl; BOOST_CHECK(w.value() == u); } // // check_make_pair: // verifies behaviour of "make_pair": // template <class T, class U, class V> void check_make_pair(T c, U u, V v) { cout << "checking std::pair<" << typeid(c.first).name() << ", " << typeid(c.second).name() << ">..." << endl; BOOST_CHECK(c.first == u); BOOST_CHECK(c.second == v); cout << endl; } struct comparible_UDT { int i_; comparible_UDT() : i_(2){} comparible_UDT(const comparible_UDT& other) : i_(other.i_){} comparible_UDT& operator=(const comparible_UDT& other) { i_ = other.i_; return *this; } bool operator == (const comparible_UDT& v){ return v.i_ == i_; } }; int main() { call_traits_checker<comparible_UDT> c1; comparible_UDT u; c1(u); call_traits_checker<int> c2; call_traits_checker<enum_UDT> c2b; int i = 2; c2(i); c2b(one); int* pi = &i; int a[2] = {1,2}; #if defined(BOOST_MSVC6_MEMBER_TEMPLATES) && !defined(__ICL) call_traits_checker<int*> c3; c3(pi); call_traits_checker<int&> c4; c4(i); call_traits_checker<const int&> c5; c5(i); #if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__MWERKS__) && !defined(__SUNPRO_CC) call_traits_checker<int[2]> c6; c6(a); #endif #endif check_wrap(test_wrap_type(2), 2); #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC) check_wrap(test_wrap_type(a), a); check_make_pair(test::make_pair(a, a), a, a); #endif // cv-qualifiers applied to reference types should have no effect // declare these here for later use with is_reference and remove_reference: typedef int& r_type; typedef const r_type cr_type; BOOST_CHECK_TYPE(comparible_UDT, boost::call_traits<comparible_UDT>::value_type); BOOST_CHECK_TYPE(comparible_UDT&, boost::call_traits<comparible_UDT>::reference); BOOST_CHECK_TYPE(const comparible_UDT&, boost::call_traits<comparible_UDT>::const_reference); BOOST_CHECK_TYPE(const comparible_UDT&, boost::call_traits<comparible_UDT>::param_type); BOOST_CHECK_TYPE(int, boost::call_traits<int>::value_type); BOOST_CHECK_TYPE(int&, boost::call_traits<int>::reference); BOOST_CHECK_TYPE(const int&, boost::call_traits<int>::const_reference); BOOST_CHECK_TYPE(const int, boost::call_traits<int>::param_type); BOOST_CHECK_TYPE(int*, boost::call_traits<int*>::value_type); BOOST_CHECK_TYPE(int*&, boost::call_traits<int*>::reference); BOOST_CHECK_TYPE(int*const&, boost::call_traits<int*>::const_reference); BOOST_CHECK_TYPE(int*const, boost::call_traits<int*>::param_type); #if defined(BOOST_MSVC6_MEMBER_TEMPLATES) BOOST_CHECK_TYPE(int&, boost::call_traits<int&>::value_type); BOOST_CHECK_TYPE(int&, boost::call_traits<int&>::reference); BOOST_CHECK_TYPE(const int&, boost::call_traits<int&>::const_reference); BOOST_CHECK_TYPE(int&, boost::call_traits<int&>::param_type); #if !(defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC__ == 3) && (__GNUC_MINOR__ < 1))) BOOST_CHECK_TYPE(int&, boost::call_traits<cr_type>::value_type); BOOST_CHECK_TYPE(int&, boost::call_traits<cr_type>::reference); BOOST_CHECK_TYPE(const int&, boost::call_traits<cr_type>::const_reference); BOOST_CHECK_TYPE(int&, boost::call_traits<cr_type>::param_type); #else std::cout << "Your compiler cannot instantiate call_traits<int&const>, skipping four tests (4 errors)" << std::endl; #endif BOOST_CHECK_TYPE(const int&, boost::call_traits<const int&>::value_type); BOOST_CHECK_TYPE(const int&, boost::call_traits<const int&>::reference); BOOST_CHECK_TYPE(const int&, boost::call_traits<const int&>::const_reference); BOOST_CHECK_TYPE(const int&, boost::call_traits<const int&>::param_type); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_CHECK_TYPE(const int*, boost::call_traits<int[3]>::value_type); BOOST_CHECK_TYPE(int(&)[3], boost::call_traits<int[3]>::reference); BOOST_CHECK_TYPE(const int(&)[3], boost::call_traits<int[3]>::const_reference); BOOST_CHECK_TYPE(const int*const, boost::call_traits<int[3]>::param_type); BOOST_CHECK_TYPE(const int*, boost::call_traits<const int[3]>::value_type); BOOST_CHECK_TYPE(const int(&)[3], boost::call_traits<const int[3]>::reference); BOOST_CHECK_TYPE(const int(&)[3], boost::call_traits<const int[3]>::const_reference); BOOST_CHECK_TYPE(const int*const, boost::call_traits<const int[3]>::param_type); // test with abstract base class: BOOST_CHECK_TYPE(test_abc1, boost::call_traits<test_abc1>::value_type); BOOST_CHECK_TYPE(test_abc1&, boost::call_traits<test_abc1>::reference); BOOST_CHECK_TYPE(const test_abc1&, boost::call_traits<test_abc1>::const_reference); BOOST_CHECK_TYPE(const test_abc1&, boost::call_traits<test_abc1>::param_type); #else std::cout << "You're compiler does not support partial template specialiation, skipping 8 tests (8 errors)" << std::endl; #endif #else std::cout << "You're compiler does not support partial template specialiation, skipping 20 tests (20 errors)" << std::endl; #endif // test with an incomplete type: BOOST_CHECK_TYPE(incomplete_type, boost::call_traits<incomplete_type>::value_type); BOOST_CHECK_TYPE(incomplete_type&, boost::call_traits<incomplete_type>::reference); BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits<incomplete_type>::const_reference); BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits<incomplete_type>::param_type); // test enum: BOOST_CHECK_TYPE(enum_UDT, boost::call_traits<enum_UDT>::value_type); BOOST_CHECK_TYPE(enum_UDT&, boost::call_traits<enum_UDT>::reference); BOOST_CHECK_TYPE(const enum_UDT&, boost::call_traits<enum_UDT>::const_reference); BOOST_CHECK_TYPE(const enum_UDT, boost::call_traits<enum_UDT>::param_type); return 0; } // // define call_traits tests to check that the assertions in the docs do actually work // this is an compile-time only set of tests: // template <typename T, bool isarray = false> struct call_traits_test { typedef ::boost::call_traits<T> ct; typedef typename ct::param_type param_type; typedef typename ct::reference reference; typedef typename ct::const_reference const_reference; typedef typename ct::value_type value_type; static void assert_construct(param_type val); }; template <typename T, bool isarray> void call_traits_test<T, isarray>::assert_construct(typename call_traits_test<T, isarray>::param_type val) { // // this is to check that the call_traits assertions are valid: T t(val); value_type v(t); reference r(t); const_reference cr(t); param_type p(t); value_type v2(v); value_type v3(r); value_type v4(p); reference r2(v); reference r3(r); const_reference cr2(v); const_reference cr3(r); const_reference cr4(cr); const_reference cr5(p); param_type p2(v); param_type p3(r); param_type p4(p); unused_variable(v2); unused_variable(v3); unused_variable(v4); unused_variable(r2); unused_variable(r3); unused_variable(cr2); unused_variable(cr3); unused_variable(cr4); unused_variable(cr5); unused_variable(p2); unused_variable(p3); unused_variable(p4); } #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template <typename T> struct call_traits_test<T, true> { typedef ::boost::call_traits<T> ct; typedef typename ct::param_type param_type; typedef typename ct::reference reference; typedef typename ct::const_reference const_reference; typedef typename ct::value_type value_type; static void assert_construct(param_type val); }; template <typename T> void call_traits_test<T, true>::assert_construct(typename boost::call_traits<T>::param_type val) { // // this is to check that the call_traits assertions are valid: T t; value_type v(t); value_type v5(val); reference r = t; const_reference cr = t; reference r2 = r; #ifndef __BORLANDC__ // C++ Builder buglet: const_reference cr2 = r; #endif param_type p(t); value_type v2(v); const_reference cr3 = cr; value_type v3(r); value_type v4(p); param_type p2(v); param_type p3(r); param_type p4(p); unused_variable(v2); unused_variable(v3); unused_variable(v4); unused_variable(v5); #ifndef __BORLANDC__ unused_variable(r2); unused_variable(cr2); #endif unused_variable(cr3); unused_variable(p2); unused_variable(p3); unused_variable(p4); } #endif //BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // // now check call_traits assertions by instantiating call_traits_test: template struct call_traits_test<int>; template struct call_traits_test<const int>; template struct call_traits_test<int*>; #if defined(BOOST_MSVC6_MEMBER_TEMPLATES) template struct call_traits_test<int&>; template struct call_traits_test<const int&>; #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC) template struct call_traits_test<int[2], true>; #endif #endif
14,906
5,546
// ----------------- BEGIN LICENSE BLOCK --------------------------------- // // Copyright (C) 2017-2020 Intel Corporation // // SPDX-License-Identifier: MIT // // ----------------- END LICENSE BLOCK ----------------------------------- #include "ad/map/maker/test_helper/StringTestHelper.hpp" #include <stdio.h> namespace ad { namespace map { namespace maker { namespace test_helper { static bool useColorForComparison{false}; /* the color mode has to be set at least once * Either this was done by user-code (which called setColorMode) * or from testStringAndPrintDifference */ static bool colorModeInitiallySet{false}; static void setInitialColorMode() { if (!colorModeInitiallySet) { setColorMode(ColorMode::On); } } static void adustColorModeForConsole() { if (useColorForComparison) { const char *term = getenv("TERM"); if (term) { // if it starts with 'xterm' we assume that is supports color if ((term[0] == 'x') && (term[1] == 't') && (term[2] == 'e') && (term[3] == 'r') && (term[4] == 'm')) { return; } } // turn off coloring if the console doesn't support this useColorForComparison = false; } } void setColorMode(ColorMode mode) { colorModeInitiallySet = true; useColorForComparison = (mode == ColorMode::On); adustColorModeForConsole(); } void turnColorOn(const char *const color) { if (useColorForComparison) { printf("%s", color); // turn color on } } void turnColorOff() { if (useColorForComparison) { printf("\x1b[0m"); // turn to normal } } size_t getMaxLengthOfStrings(std::string const &s1, std::string const &s2) { size_t len = s1.length(); if (s2.length() < len) { len = s2.length(); } return len; } void printDifferenceOfString(std::string const &toPrint, std::string const &toCompare, const char *const color, size_t const len) { for (size_t i = 0; i < len; i++) { if (toPrint[i] != toCompare[i]) { turnColorOn(color); } printf("%c", toPrint[i]); if (toPrint[i] != toCompare[i]) { turnColorOff(); } } } void printStringDifferences(std::string const &expected, std::string const &actual) { const size_t len = getMaxLengthOfStrings(expected, actual); if (expected == actual) { return; } if (len > 0) { printf("Expected:\n"); printDifferenceOfString(expected, actual, "\x1b[32m", len); printf("\nActual:\n"); printDifferenceOfString(actual, expected, "\x1b[31m", len); } else { printf("Either exected (size: %lu) or actual (size: %lu) is empty\n", expected.size(), actual.size()); } } // make this a macro similar to gtest ASSERT_STREQ, maybe ASSERT_STREQ_PRINT_DIFF bool testStringAndPrintDifference(std::string const &expected, std::string const &actual) { if (expected != actual) { setInitialColorMode(); printStringDifferences(expected, actual); // print missing parts if strings have different sizes if (expected.length() != actual.length()) { if (expected.size() > actual.size()) { printf("\nMissing part from expected:\n"); turnColorOn("\x1b[32m"); if (actual.size() > 0) { printf("%s", &expected.c_str()[actual.size()]); } else { printf("%s", expected.c_str()); } turnColorOff(); } else { printf("\nAdditional part from actual:\n"); turnColorOn("\x1b[31m"); if (expected.size() > 0) { printf("%s", &actual.c_str()[expected.size()]); } else { printf("%s", actual.c_str()); } turnColorOff(); } printf("\n"); } return false; } return true; } bool readFile(char const *fileName, std::string &fileContent) { FILE *input = fopen(fileName, "r"); if (input == nullptr) { return false; } if (fseek(input, 0, SEEK_END) != 0) { return false; } size_t fileSize = static_cast<size_t>(ftell(input)); rewind(input); char *content = new char[fileSize + 1]; size_t readCount = fread(content, sizeof(char), fileSize, input); if (readCount != fileSize) { delete[] content; content = nullptr; return false; } content[fileSize] = 0; fileContent.assign(content); return true; } } // namespace test_helper } // namespace maker } // namespace map } // namespace ad
4,499
1,519
#ifndef _FONTHANDLER_ #define _FONTHANDLER_ #include <cstring> #include "Types.hpp" #include "Color.hpp" #include "BaseRenderTarget.hpp" #include "Utilities/FileHandler.hpp" #ifdef _PC_ #include <SFML/Graphics.hpp> #endif /** * Class used to draw fonts. * The FontHandler is designed to use only one font, * if more fonts are needed then separate FontHandlers * should be initialized. */ class FontHandler{ private: /** Name of font. */ char fontName[25]; /** Is the font loaded and ready to use. */ bool initialized; /** Size of font. */ byte fontSize; /** Font color. */ Color color; public: #ifdef _PC_ /** SFML Font implementation. */ sf::Font font; #endif FontHandler(); bool loadFont(const char* name); unsigned short getStringWidth(const char* str); void setFontSize(byte size); void setFontColor(Color color); #ifdef _PC_ void drawString(sf::RenderTarget& dst, RenderObject& obj, const char* str); #endif }; #endif
1,003
330
/* ESP8266 Simple Service Discovery Copyright (c) 2015 Hristo Gochkov Original (Arduino) version by Filippo Sallemi, July 23, 2014. Can be found at: https://github.com/nomadnt/uSSDP License (MIT license): 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. */ // #define LWIP_OPEN_SRC #ifndef LWIP_OPEN_SRC #define LWIP_OPEN_SRC #endif #include <functional> #include "SSDP.h" #include <WiFiUdp.h> #include <functional> #include <WiFiUdp.h> #include "ArduinoOTA.h" #include "MD5Builder.h" #include "StreamString.h" extern "C" { #include "osapi.h" #include "ets_sys.h" #include "user_interface.h" } #include "lwip/opt.h" #include "lwip/udp.h" #include "lwip/inet.h" #include "lwip/igmp.h" #include "lwip/mem.h" #include "include/UdpContext.h" //#define DEBUG_SSDP Serial #define SSDP_INTERVAL 1200 #define SSDP_PORT 1900 #define SSDP_METHOD_SIZE 10 #define SSDP_URI_SIZE 2 #define SSDP_BUFFER_SIZE 64 #define SSDP_MULTICAST_TTL 2 static const IPAddress SSDP_MULTICAST_ADDR(239, 255, 255, 250); static const char* _ssdp_response_template = "HTTP/1.1 200 OK\r\n" "HOST: 239.255.255.250:1900\r\n" "EXT:\r\n"; static const char* _ssdp_notify_template = "NOTIFY * HTTP/1.1\r\n" "HOST: 239.255.255.250:1900\r\n" "NTS: ssdp:alive\r\n"; struct SSDPTimer { ETSTimer timer; }; SSDPClass::SSDPClass() : _server(0), _timer(new SSDPTimer), _port(80), _ttl(SSDP_MULTICAST_TTL), _respondToPort(0), _pending(false), _delay(0), _process_time(0), _notify_time(0) { _uuid[0] = '\0'; _modelNumber[0] = '\0'; sprintf(_deviceType, "urn:schemas-upnp-org:device:Basic:1"); _friendlyName[0] = '\0'; _presentationURL[0] = '\0'; _serialNumber[0] = '\0'; _modelName[0] = '\0'; _modelURL[0] = '\0'; _manufacturer[0] = '\0'; _manufacturerURL[0] = '\0'; sprintf(_schemaURL, "ssdp/schema.xml"); } SSDPClass::~SSDPClass() { delete _timer; } bool SSDPClass::begin() { _pending = false; String mac = WiFi.macAddress(); mac.replace(":", ""); mac.toLowerCase(); sprintf(_uuid, "2f402f80-da50-11e1-9b23-%s", mac.c_str()); #ifdef DEBUG_SSDP DEBUG_SSDP.printf("SSDP UUID: %s\r\n", (char *)_uuid); #endif if (_server) { _server->unref(); _server = 0; } _server = new UdpContext; _server->ref(); ip_addr_t ifaddr; ifaddr.addr = WiFi.localIP(); ip_addr_t multicast_addr; multicast_addr.addr = (uint32_t)SSDP_MULTICAST_ADDR; if (igmp_joingroup(&ifaddr, &multicast_addr) != ERR_OK) { DEBUGV("SSDP failed to join igmp group"); return false; } if (!_server->listen(*IP_ADDR_ANY, SSDP_PORT)) { return false; } _server->setMulticastInterface(ifaddr); _server->setMulticastTTL(_ttl); _server->onRx(std::bind(&SSDPClass::_update, this)); if (!_server->connect(multicast_addr, SSDP_PORT)) { return false; } _startTimer(); return true; } static const char* _ssdp_packet_template = "%s" // _ssdp_response_template / _ssdp_notify_template "CACHE-CONTROL: max-age=100\r\n" // SSDP_INTERVAL "LOCATION: http://%s:%u/%s\r\n" // WiFi.localIP(), _port, _schemaURL "SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/1.20.0\r\n" "hue-bridgeid: %s\r\n" //_bridgeId "%s: %s\r\n" // "NT" or "ST", _deviceType "USN: uuid:%s::upnp:rootdevice\r\n" // _uuid "\r\n"; void SSDPClass::_send(ssdp_method_t method) { char buffer[1460]; int len; len = snprintf(buffer, sizeof(buffer), _ssdp_packet_template, (method == NONE) ? _ssdp_response_template : _ssdp_notify_template, _ip, _port, _schemaURL, _bridgeId, (method == NONE) ? "ST" : "NT", _deviceType, _uuid ); _server->append(buffer, len); ip_addr_t remoteAddr; uint16_t remotePort; if (method == NONE) { remoteAddr.addr = _respondToAddr; remotePort = _respondToPort; #ifdef DEBUG_SSDP DEBUG_SSDP.print("Sending Response to "); #endif } else { remoteAddr.addr = SSDP_MULTICAST_ADDR; remotePort = SSDP_PORT; #ifdef DEBUG_SSDP DEBUG_SSDP.println("Sending Notify to "); #endif } #ifdef DEBUG_SSDP DEBUG_SSDP.print(IPAddress(remoteAddr.addr)); DEBUG_SSDP.print(":"); DEBUG_SSDP.println(remotePort); Serial.println(buffer); #endif _server->send(&remoteAddr, remotePort); } ////void SSDPClass::schema(WiFiClient client) { //// IPAddress ip = WiFi.localIP(); //// client.printf(_ssdp_schema_template, //// ip.toString().c_str(), _port, //// _deviceType, //// _friendlyName, //// _presentationURL, //// _serialNumber, //// _modelName, //// _modelNumber, //// _modelURL, //// _manufacturer, //// _manufacturerURL, //// _uuid //// ); ////} // writes the next token into token if token is not NULL // returns -1 on message end, otherwise returns int SSDPClass::_getNextToken(String *token, bool break_on_space, bool break_on_colon) { if (token) *token = ""; bool token_found = false; int cr_found = 0; while (_server->getSize() > 0) { char next = _server->read(); switch (next) { case '\r': case '\n': cr_found++; if (cr_found == 3) { // end of message reached return -1; } if (token_found) { // end of token reached return _server->getSize(); } continue; case ' ': // only treat spaces as part of text if they're not leading if (!token_found) { cr_found = 0; continue; } if (!break_on_space) { break; } cr_found = 0; // end of token reached return _server->getSize(); case ':': // only treat colons as part of text if they're not leading if (!token_found) { cr_found = 0; continue; } if (!break_on_colon) { break; } cr_found = 0; // end of token reached return _server->getSize(); default: cr_found = 0; token_found = true; break; } if (token) { (*token) += next; } } return 0; } void SSDPClass::_bailRead() { while (_getNextToken(NULL, true, true) > 0); _pending = false; _delay = 0; } void SSDPClass::_parseIncoming() { _respondToAddr = _server->getRemoteAddress(); _respondToPort = _server->getRemotePort(); typedef enum { START, MAN, ST, MX, UNKNOWN } headers; headers header = START; String token; // get message type int res = _getNextToken(&token, true, false); if (res <= 0) { _bailRead(); return; } if (token == "M-SEARCH") { } else if (token == "NOTIFY") { // incoming notifies are not currently handled _bailRead(); return; } else { _bailRead(); return; } // get URI res = _getNextToken(&token, true, false); if (res <= 0) { _bailRead(); return; } if (token != "*") { _bailRead(); return; } // eat protocol (HTTP/1.1) res = _getNextToken(NULL, false, false); if (res <= 0) { _bailRead(); return; } while (_server->getSize() > 0) { res = _getNextToken(&token, header == START, header == START); if (res < 0 && header == START) { break; } switch (header) { case START: if (token.equalsIgnoreCase("MAN")) header = MAN; else if (token.equalsIgnoreCase("ST")) header = ST; else if (token.equalsIgnoreCase("MX")) header = MX; else { header = UNKNOWN; #ifdef DEBUG_SSDP DEBUG_SSDP.printf("Found unknown header '%s'\r\n", token.c_str()); #endif } break; case MAN: #ifdef DEBUG_SSDP DEBUG_SSDP.printf("MAN: %s\r\n", token.c_str()); #endif header = START; break; case ST: if (token != "ssdp:all" && token != _deviceType) { #ifdef DEBUG_SSDP DEBUG_SSDP.printf("REJECT: %s\r\n", token.c_str()); #endif } _pending = true; _process_time = millis(); header = START; break; case MX: _delay = random(0, atoi(token.c_str())) * 1000L; header = START; break; case UNKNOWN: header = START; #ifdef DEBUG_SSDP DEBUG_SSDP.printf("Value for unkown header: %s\r\n", token.c_str()); #endif break; } } if (header != START) { // something broke during parsing of the message _bailRead(); } } void SSDPClass::_update() { if (!_pending && _server->next()) { _parseIncoming(); } if (_pending && (millis() - _process_time) > _delay) { _pending = false; _delay = 0; _send(NONE); } else if (_notify_time == 0 || (millis() - _notify_time) > (SSDP_INTERVAL * 1000L)) { _notify_time = millis(); _send(NOTIFY); } if (_pending) { while (_server->next()) _server->flush(); } } void SSDPClass::setBridgeId(const char *brideId) { strlcpy(_bridgeId, brideId, sizeof(_bridgeId)); } void SSDPClass::setIpAdress(const char *ip) { strlcpy(_ip, ip, sizeof(_ip)); } void SSDPClass::setSchemaURL(const char *url) { strlcpy(_schemaURL, url, sizeof(_schemaURL)); } void SSDPClass::setHTTPPort(uint16_t port) { _port = port; } void SSDPClass::setDeviceType(const char *deviceType) { strlcpy(_deviceType, deviceType, sizeof(_deviceType)); } void SSDPClass::setName(const char *name) { strlcpy(_friendlyName, name, sizeof(_friendlyName)); } void SSDPClass::setURL(const char *url) { strlcpy(_presentationURL, url, sizeof(_presentationURL)); } void SSDPClass::setSerialNumber(const char *serialNumber) { strlcpy(_serialNumber, serialNumber, sizeof(_serialNumber)); } void SSDPClass::setSerialNumber(const uint32_t serialNumber) { snprintf(_serialNumber, sizeof(uint32_t) * 2 + 1, "%08X", serialNumber); } void SSDPClass::setModelName(const char *name) { strlcpy(_modelName, name, sizeof(_modelName)); } void SSDPClass::setModelNumber(const char *num) { strlcpy(_modelNumber, num, sizeof(_modelNumber)); } void SSDPClass::setModelURL(const char *url) { strlcpy(_modelURL, url, sizeof(_modelURL)); } void SSDPClass::setManufacturer(const char *name) { strlcpy(_manufacturer, name, sizeof(_manufacturer)); } void SSDPClass::setManufacturerURL(const char *url) { strlcpy(_manufacturerURL, url, sizeof(_manufacturerURL)); } void SSDPClass::setTTL(const uint8_t ttl) { _ttl = ttl; } void SSDPClass::_onTimerStatic(SSDPClass* self) { self->_update(); } void SSDPClass::_startTimer() { ETSTimer* tm = &(_timer->timer); const int interval = 1000; os_timer_disarm(tm); os_timer_setfn(tm, reinterpret_cast<ETSTimerFunc*>(&SSDPClass::_onTimerStatic), reinterpret_cast<void*>(this)); os_timer_arm(tm, interval, 1 /* repeat */); } #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SSDP) SSDPClass SSDP; #endif
11,041
4,719
#include <exception> #include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <cmath> using std::cout; inline void cout_rep_sym(char c, int n) { for (int i = 0; i < n; ++i) cout << c; } inline std::string str_bin_comp(std::string& s) { std::string ret; ret.resize(s.size()); for (int i = 0; i < s.size(); ++i) ret[i] = s[i] == '0' ? '1' : '0'; bool found = false; for (int i = s.size()-1; !found && i > 0; --i) if (ret[i] == '0') { ret[i] = '1'; found = true; } if (!found) std::fill(ret.begin(), ret.end(), '0'); return ret; } int main(int argc, char* argv[]) try { /* Basic exception checking */ if (argc != 2 && argc != 3) throw std::length_error("Must pass ONE binary number\n"); auto is_bin_num = [](char c){ return c != '0' && c != '1'; }; std::string num{argv[1]}; for (char c : num) if (is_bin_num(c)) throw std::invalid_argument{"Must pass a BINARY number\n"}; // Check for a signed or unsigned number if specified. Defaults to unsigned. bool signed_num = false; if (argc == 3) { std::string num_type_option = argv[2]; if (num_type_option == "s" || num_type_option == "signed") signed_num = true; else if (num_type_option == "u" || num_type_option == "unsigned") signed_num = false; else throw std::invalid_argument("Must pass signed or unsigned as third " "argument\n"); } std::string signed_bin_num; if (signed_num) { signed_bin_num = str_bin_comp(num); std::cout << "Fliping " << num << " -> " << signed_bin_num << "\n"; } /* Conversion */ /* bit position conversions are zero indexed. 101 ^^^ ||| ||------------- 2^0 * 1 |-------------- 2^1 * 0 --------------- 2^2 * 1 */ long long dec_num = 0; std::string bin_num = signed_num ? signed_bin_num : num; int bit_position = bin_num.size() - 1; for (char bit : bin_num) { if (bit == '1') { long long cur_conv = pow(2, bit_position); dec_num += cur_conv; cout << std::setw(14) << std::right << "2^" + std::to_string(bit_position) + " * 1 = " << cur_conv << std::endl; } else { cout << std::setw(14) << std::right << "2^" + std::to_string(bit_position) + " * 0 = " << "0" << std::endl; } --bit_position; } cout_rep_sym('-', 80); cout << std::endl; cout << bin_num << " = "; if (signed_num) cout << "-"; cout << dec_num << " in decimal.\n"; } catch (std::invalid_argument e) { std::string usage_prompt = "usage: bin2dec binary_number [unsigned | u | signed | signed]\n"; cout << e.what() << usage_prompt; return -1; } catch (std::length_error e) { std::string usage_prompt = "usage: bin2dec binary_number [unsigned | u | signed | signed]\n"; cout << e.what() << usage_prompt; return -1; } catch (...) { return -1; }
2,945
1,128
/* Copyright (c) 2009-2015, Jack Poulson All rights reserved. This file is part of Elemental and is under the BSD 2-Clause License, which can be found in the LICENSE file in the root directory, or at http://opensource.org/licenses/BSD-2-Clause */ #include "El.hpp" namespace El { namespace nnls { // Transform each problem // // min || A x - b ||_2 // s.t. x >= 0 // // into the explicit QP // // min (1/2) x^T (A^T A) x + (-A^T b)^T x // s.t. x >= 0 // // and solve the sequence of problems simultaneously with ADMM. // template<typename Real> Int ADMM ( const Matrix<Real>& A, const Matrix<Real>& B, Matrix<Real>& X, const qp::box::ADMMCtrl<Real>& ctrl ) { DEBUG_ONLY(CSE cse("nnls::ADMM")) if( IsComplex<Real>::val ) LogicError("The datatype was assumed to be real"); const Real maxReal = std::numeric_limits<Real>::max(); Matrix<Real> Q, C; Herk( LOWER, ADJOINT, Real(1), A, Q ); Gemm( ADJOINT, NORMAL, Real(-1), A, B, C ); return qp::box::ADMM( Q, C, Real(0), maxReal, X, ctrl ); } template<typename Real> Int ADMM ( const AbstractDistMatrix<Real>& APre, const AbstractDistMatrix<Real>& B, AbstractDistMatrix<Real>& X, const qp::box::ADMMCtrl<Real>& ctrl ) { DEBUG_ONLY(CSE cse("nnls::ADMM")) if( IsComplex<Real>::val ) LogicError("The datatype was assumed to be real"); const Real maxReal = std::numeric_limits<Real>::max(); auto APtr = ReadProxy<Real,MC,MR>( &APre ); auto& A = *APtr; DistMatrix<Real> Q(A.Grid()), C(A.Grid()); Herk( LOWER, ADJOINT, Real(1), A, Q ); Gemm( ADJOINT, NORMAL, Real(-1), A, B, C ); return qp::box::ADMM( Q, C, Real(0), maxReal, X, ctrl ); } } // namespace nnls } // namespace El
1,753
687
// Boost.TypeErasure library // // Copyright 2011 Steven Watanabe // // Distributed under the Boost Software License Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // $Id$ #ifndef BOOST_TYPE_ERASURE_CONFIG_HPP_INCLUDED #define BOOST_TYPE_ERASURE_CONFIG_HPP_INCLUDED #ifndef BOOST_TYPE_ERASURE_MAX_FUNCTIONS /** The maximum number of functions that an @ref boost::type_erasure::any "any" * can have. */ #define BOOST_TYPE_ERASURE_MAX_FUNCTIONS 50 #endif #ifndef BOOST_TYPE_ERASURE_MAX_ARITY /** The maximum number of arguments that functions in the library support. */ #define BOOST_TYPE_ERASURE_MAX_ARITY 5 #endif #ifndef BOOST_TYPE_ERASURE_MAX_TUPLE_SIZE /** The maximum number of elements in a @ref boost::type_erasure::tuple "tuple". */ #define BOOST_TYPE_ERASURE_MAX_TUPLE_SIZE 5 #endif #endif
866
336
#include "session.h" #include <memory> #include <boost/lexical_cast.hpp> #include "room.h" #include "player.h" #include "request_handler.h" Session::Session(boost::asio::ip::tcp::socket socket, const Room& room) : socket_(std::move(socket)), room_(const_cast<Room&>(room)), player_(std::make_shared<Player>(*this, room_, boost::lexical_cast<std::string>(socket_.remote_endpoint()))) { } void Session::start() { room_.join(shared_from_this()); do_read_header(); } void Session::deliver(const Message& msg) { bool write_in_progress = !write_msgs_.empty(); write_msgs_.push_back(msg); if (!write_in_progress) { do_write(); } } void Session::do_read_header() { auto self(shared_from_this()); boost::asio::async_read(socket_, boost::asio::buffer(read_msg_.data(), Message::kHeaderLength), [this, self](boost::system::error_code ec, std::size_t /*length*/) { if (!ec && read_msg_.decode_header()) { do_read_body(); } else { if (room_.exist(shared_from_this())) { player_->leave(); room_.leave(shared_from_this()); } } }); } void Session::do_read_body() { auto self(shared_from_this()); boost::asio::async_read(socket_, boost::asio::buffer(read_msg_.body(), read_msg_.body_length()), [this, self](boost::system::error_code ec, std::size_t /*length*/) { if (!ec) { RequestHandler::handleRequest(read_msg_, player_); do_read_header(); } else { if (room_.exist(shared_from_this())) { player_->leave(); room_.leave(shared_from_this()); } } }); } void Session::do_write() { auto self(shared_from_this()); boost::asio::async_write(socket_, boost::asio::buffer(write_msgs_.front().data(), write_msgs_.front().length()), [this, self](boost::system::error_code ec, std::size_t /*length*/) { if (!ec) { write_msgs_.pop_front(); if (!write_msgs_.empty()) { do_write(); } } else { if (room_.exist(shared_from_this())) { player_->leave(); room_.leave(shared_from_this()); } } }); }
2,339
744
/********************************************************************************* * Copyright (c) 2018, Università degli Studi di Salerno, ALTEC S.p.A. * 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. * * 3. Neither the name of the copyright holder 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 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. *********************************************************************************/ /* ------------------------------------------------------------------- * * This module has been developed as part of a collaboration between * the Automatic Control Group @ UNISA and ALTEC. * * Title: fourr_kazerounian_controller.cpp * Author: Enrico Ferrentino * Org.: UNISA - Automatic Control Group * Date: Jul 16, 2018 * * This file implements a ROS node to control the 4R planar * manipulator first proposed by Kazerounian & Wang, whose * configuration is included in the ROS module * fourr_kazerounian_moveit_config. It follows the model of the * move_group_interface_tutorial. * * ------------------------------------------------------------------- */ #include <ros/ros.h> #include <moveit/planning_scene_interface/planning_scene_interface.h> #include <moveit/move_group_interface/move_group_interface.h> #include <moveit_msgs/DisplayRobotState.h> #include <moveit_msgs/DisplayTrajectory.h> #include <moveit_visual_tools/moveit_visual_tools.h> #include <geometry_msgs/Pose.h> #include <moveit_dp_redundancy_resolution/workspace_trajectory.h> #include <moveit_dp_redundancy_resolution/dp_redundancy_resolution_capability.h> int main(int argc, char** argv) { // Initializing the node and the move_grou interface ros::init(argc, argv, "fourr_kazerounian_controller"); ros::NodeHandle node_handle; /* * The async spinner spawns a new thread in charge of calling callbacks * when needed. Uncomment the lines below if, as instance, you need to * ask for the robot state and expect an answer before the time expires. */ ros::AsyncSpinner spinner(1); spinner.start(); static const std::string PLANNING_GROUP = "fourr_planar_arm"; static const std::string NON_REDUNDANT_PLANNING_GROUP = "q2_q3_q4"; moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP); const robot_state::JointModelGroup* joint_model_group = move_group.getCurrentState()->getJointModelGroup(PLANNING_GROUP); ROS_INFO_NAMED("main", "Reference frame: %s", move_group.getPlanningFrame().c_str()); ROS_INFO_NAMED("main", "End effector link: %s", move_group.getEndEffectorLink().c_str()); // Loading the trajectory from the Parameter Server and creating a WorkspaceTrajectory object std::string trajectory_name; std::vector<double> time; std::vector<double> x; std::vector<double> y; std::vector<double> z; std::vector<double> roll; std::vector<double> pitch; std::vector<double> yaw; node_handle.getParam("/trajectory/name", trajectory_name); node_handle.getParam("/trajectory/time", time); node_handle.getParam("/trajectory/x", x); node_handle.getParam("/trajectory/y", y); node_handle.getParam("/trajectory/z", z); node_handle.getParam("/trajectory/roll", roll); node_handle.getParam("/trajectory/pitch", pitch); node_handle.getParam("/trajectory/yaw", yaw); moveit_dp_redundancy_resolution::WorkspaceTrajectory ws_trajectory(trajectory_name, time, x, y, z, roll, pitch, yaw); ROS_INFO_NAMED("main", "WorkspaceTrajectory object created with %lu waypoints", time.size()); namespace rvt = rviz_visual_tools; moveit_visual_tools::MoveItVisualTools visual_tools("base_link"); visual_tools.deleteAllMarkers(); visual_tools.loadRemoteControl(); visual_tools.publishPath(ws_trajectory.getWaypoints(), rvt::LIME_GREEN, rvt::SMALL); visual_tools.trigger(); //visual_tools.prompt("Press 'next' in the RvizVisualToolsGui window to start planning"); // Planning with dynamic programming redundancy resolution ros::ServiceClient dp_redundancy_resolution_service = node_handle.serviceClient<moveit_dp_redundancy_resolution_msgs::GetOptimizedJointsTrajectory>(move_group::DP_REDUNDANCY_RESOLUTION_SERVICE_NAME); moveit_dp_redundancy_resolution_msgs::GetOptimizedJointsTrajectoryRequest req; moveit_dp_redundancy_resolution_msgs::GetOptimizedJointsTrajectoryResponse res; moveit_dp_redundancy_resolution_msgs::WorkspaceTrajectory ws_trajectory_msg; ws_trajectory.getWorkspaceTrajectoryMsg(ws_trajectory_msg); req.ws_trajectory = ws_trajectory_msg; req.planning_group_name = PLANNING_GROUP; req.non_redundant_group_name = NON_REDUNDANT_PLANNING_GROUP; req.redundancy_parameter_samples = 1440; req.redundancy_parameters.push_back("joint1"); dp_redundancy_resolution_service.call(req, res); visual_tools.publishTrajectoryLine(res.solution, joint_model_group); visual_tools.trigger(); visual_tools.prompt("Press 'next' in the RvizVisualToolsGui window to continue planning"); // Planning to a pose goal /* * Uncomment these instructions to see how the KDL kinematics solver fails in * finding a solution for a < 6 DOF manipulator */ /* geometry_msgs::Pose target_pose1; target_pose1.position.x = 5; target_pose1.position.y = 5; target_pose1.position.z = 0.4; move_group.setPoseTarget(target_pose1); moveit::planning_interface::MoveGroupInterface::Plan my_plan; bool success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS); ROS_INFO_NAMED("main", "Visualizing plan 1 (pose goal) %s", success ? "" : "FAILED"); ROS_INFO_NAMED("main", "Visualizing plan 1 as trajectory line"); visual_tools.publishAxisLabeled(target_pose1, "pose1"); visual_tools.publishTrajectoryLine(my_plan.trajectory_, joint_model_group); visual_tools.trigger(); visual_tools.prompt("Press 'next' in the RvizVisualToolsGui window to continue planning"); */ // Planning to a joint space goal moveit::core::RobotStatePtr current_state = move_group.getCurrentState(); std::vector<double> joint_group_positions; current_state->copyJointGroupPositions(joint_model_group, joint_group_positions); joint_group_positions[0] = -1.0; // radians move_group.setJointValueTarget(joint_group_positions); moveit::planning_interface::MoveGroupInterface::Plan my_plan; bool success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS); ROS_INFO_NAMED("main", "Visualizing plan 2 (joint space goal) %s", success ? "" : "FAILED"); visual_tools.deleteAllMarkers(); visual_tools.publishTrajectoryLine(my_plan.trajectory_, joint_model_group); visual_tools.trigger(); visual_tools.prompt("Press 'next' in the RvizVisualToolsGui window to continue planning"); // Planning a joint space path starting from workspace waypoints robot_state::RobotState start_state(*move_group.getCurrentState()); geometry_msgs::Pose start_pose = ws_trajectory.getWaypoints()[0]; start_state.setFromIK(joint_model_group, start_pose); move_group.setStartState(start_state); moveit_msgs::RobotTrajectory trajectory; const double jump_threshold = 0; const double eef_step = 0.01; double fraction = move_group.computeCartesianPath(ws_trajectory.getWaypoints(), eef_step, jump_threshold, trajectory, false); ROS_INFO_NAMED("main", "Visualizing plan (%.2f%% achieved)", fraction * 100.0); visual_tools.deleteAllMarkers(); visual_tools.publishPath(ws_trajectory.getWaypoints(), rvt::LIME_GREEN, rvt::SMALL); // for (std::size_t i = 0; i < time.size(); ++i) // visual_tools.publishAxisLabeled(ws_trajectory.getWaypoints()[i], "pt" + std::to_string(i), rvt::SMALL); visual_tools.publishTrajectoryLine(trajectory, joint_model_group); visual_tools.trigger(); visual_tools.prompt("Press 'next' in the RvizVisualToolsGui window to terminate the node"); ros::shutdown(); return 0; }
9,382
3,131
#include "../stdafx.h" #include "storehelper.h" Handle<PkiItemCollection> Provider::getProviderItemCollection(){ LOGGER_FN(); return this->providerItemCollection; } ProviderCollection::ProviderCollection(){ LOGGER_FN(); _items = std::vector<Handle<Provider> >(); } ProviderCollection::~ProviderCollection(){ LOGGER_FN(); } Handle<Provider> ProviderCollection::items(int index){ LOGGER_FN(); return _items.at(index); } int ProviderCollection::length(){ LOGGER_FN(); return _items.size(); } void ProviderCollection::push(Handle<Provider> v){ LOGGER_FN(); _items.push_back(v); } PkiItem::PkiItem(){ LOGGER_FN(); type = new std::string(""); provider = new std::string(""); category = new std::string(""); hash = new std::string(""); uri = new std::string(""); format = new std::string(""); certSubjectName = new std::string(""); certSubjectFriendlyName = new std::string(""); certIssuerName = new std::string(""); certIssuerFriendlyName = new std::string(""); certNotBefore = new std::string(""); certNotAfter = new std::string(""); certSerial = new std::string(""); certKey = new std::string(""); certOrganizationName = new std::string(""); certSignatureAlgorithm = new std::string(""); csrSubjectName = new std::string(""); csrSubjectFriendlyName = new std::string(""); csrKey = new std::string(""); crlIssuerName = new std::string(""); crlIssuerFriendlyName = new std::string(""); crlLastUpdate = new std::string(""); crlNextUpdate = new std::string(""); keyEncrypted = false; } void PkiItem::setFormat(Handle<std::string> format){ LOGGER_FN(); this->format = format; } void PkiItem::setType(Handle<std::string> type){ LOGGER_FN(); this->type = type; } void PkiItem::setProvider(Handle<std::string> provider){ LOGGER_FN(); this->provider = provider; } void PkiItem::setCategory(Handle<std::string> category){ LOGGER_FN(); this->category = category; } void PkiItem::setURI(Handle<std::string> uri){ LOGGER_FN(); this->uri = uri; } void PkiItem::setHash(Handle<std::string> hash){ LOGGER_FN(); this->hash = hash; } void PkiItem::setSubjectName(Handle<std::string> subjectName){ LOGGER_FN(); this->certSubjectName = subjectName; this->csrSubjectName = subjectName; } void PkiItem::setSubjectFriendlyName(Handle<std::string> subjectFriendlyName){ LOGGER_FN(); this->certSubjectFriendlyName = subjectFriendlyName; this->csrSubjectFriendlyName = subjectFriendlyName; } void PkiItem::setIssuerName(Handle<std::string> issuerName){ LOGGER_FN(); this->certIssuerName = issuerName; this->crlIssuerName = issuerName; } void PkiItem::setIssuerFriendlyName(Handle<std::string> issuerFriendlyName){ LOGGER_FN(); this->certIssuerFriendlyName = issuerFriendlyName; this->crlIssuerFriendlyName = issuerFriendlyName; } void PkiItem::setSerial(Handle<std::string> serial){ LOGGER_FN(); this->certSerial = serial; } void PkiItem::setNotBefore(Handle<std::string> notBefore){ LOGGER_FN(); this->certNotBefore = notBefore; } void PkiItem::setNotAfter(Handle<std::string> notAfter){ LOGGER_FN(); this->certNotAfter = notAfter; } void PkiItem::setLastUpdate(Handle<std::string> lastUpdate){ LOGGER_FN(); this->crlLastUpdate = lastUpdate; } void PkiItem::setNextUpdate(Handle<std::string> nextUpdate){ LOGGER_FN(); this->crlNextUpdate = nextUpdate; } void PkiItem::setKey(Handle<std::string> keyid){ LOGGER_FN(); this->certKey = keyid; this->csrKey = keyid; } void PkiItem::setKeyEncypted(bool enc){ LOGGER_FN(); this->keyEncrypted = enc; } void PkiItem::setOrganizationName(Handle<std::string> organizationName){ LOGGER_FN(); this->certOrganizationName = organizationName; } void PkiItem::setSignatureAlgorithm(Handle<std::string> signatureAlgorithm){ LOGGER_FN(); this->certSignatureAlgorithm = signatureAlgorithm; } PkiItemCollection::PkiItemCollection(){ LOGGER_FN(); _items = std::vector<PkiItem>(); } PkiItemCollection::~PkiItemCollection(){ LOGGER_FN(); } Handle<PkiItem> PkiItemCollection::items(int index){ LOGGER_FN(); return new PkiItem(_items.at(index)); } int PkiItemCollection::length(){ LOGGER_FN(); return _items.size(); } void PkiItemCollection::push(Handle<PkiItem> v){ LOGGER_FN(); _items.push_back((*v.operator->())); } void PkiItemCollection::push(PkiItem &v){ LOGGER_FN(); _items.push_back(v); } Filter::Filter(){ LOGGER_FN(); types = std::vector<Handle<std::string>>(); providers = std::vector<Handle<std::string>>(); categorys = std::vector<Handle<std::string>>(); isValid = true; } void Filter::setType(Handle<std::string> type){ LOGGER_FN(); this->types.push_back(type); } void Filter::setProvider(Handle<std::string> provider){ LOGGER_FN(); this->providers.push_back(provider); } void Filter::setCategory(Handle<std::string> category){ LOGGER_FN(); this->categorys.push_back(category); } void Filter::setHash(Handle<std::string> hash){ LOGGER_FN(); this->hash = hash; } void Filter::setSubjectName(Handle<std::string> subjectName){ LOGGER_FN(); this->subjectName = subjectName; } void Filter::setSubjectFriendlyName(Handle<std::string> subjectFriendlyName){ LOGGER_FN(); this->subjectFriendlyName = subjectFriendlyName; } void Filter::setIssuerName(Handle<std::string> issuerName){ LOGGER_FN(); this->issuerName = issuerName; } void Filter::setIssuerFriendlyName(Handle<std::string> issuerFriendlyName){ LOGGER_FN(); this->issuerFriendlyName = issuerFriendlyName; } void Filter::setSerial(Handle<std::string> serial){ LOGGER_FN(); this->serial = serial; } void Filter::setIsValid(bool isValid){ LOGGER_FN(); this->isValid = isValid; }
5,639
2,114
// This file has been generated by Py++. #ifndef Image_hpp__pyplusplus_wrapper #define Image_hpp__pyplusplus_wrapper void register_Image_class(); #endif//Image_hpp__pyplusplus_wrapper
187
62
#include <vector> #include <iostream> #include "types.h" #include "symbol.h" #include "token.h" #include "lexer.h" #include "statement_parser.h" #include "ast.h" #include "ast_parser.h" int main() { try { printf("main block started. moving on to lexing...\n"); Token_Linked_List tokens = lex_file((char*)"./examples/basicstatements.eme"); printf("lexer finished. moving on to declaring list of statements...\n"); Token_Linked_List statements; printf("list of statements declared. Moving on to parsing statements...\n"); parse_statements(&statements, tokens); printf("parsed statements. printing tokens..."); print_all_tokens_after(*statements.first); Ast_Node *root = parse_statements_to_ast(statements); print_node(*root); } catch(const std::exception& e) { printf("Error: %s\n", e.what()); } }
851
280
/***************************************************************************************** * * * OpenSpace * * * * Copyright (c) 2014-2019 * * * * 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 <openspace/interaction/navigationhandler.h> #include <openspace/engine/globals.h> #include <openspace/scene/scenegraphnode.h> #include <openspace/scripting/lualibrary.h> #include <openspace/interaction/orbitalnavigator.h> #include <openspace/interaction/keyframenavigator.h> #include <openspace/interaction/inputstate.h> #include <openspace/network/parallelpeer.h> #include <openspace/util/camera.h> #include <ghoul/filesystem/file.h> #include <ghoul/filesystem/filesystem.h> #include <ghoul/logging/logmanager.h> #include <fstream> namespace { constexpr const char* _loggerCat = "NavigationHandler"; constexpr const char* KeyAnchor = "Anchor"; constexpr const char* KeyAim = "Aim"; constexpr const char* KeyPosition = "Position"; constexpr const char* KeyRotation = "Rotation"; constexpr const openspace::properties::Property::PropertyInfo KeyFrameInfo = { "UseKeyFrameInteraction", "Use keyframe interaction", "If this is set to 'true' the entire interaction is based off key frames rather " "than using the mouse interaction." }; } // namespace #include "navigationhandler_lua.inl" namespace openspace::interaction { NavigationHandler::NavigationHandler() : properties::PropertyOwner({ "NavigationHandler" }) , _useKeyFrameInteraction(KeyFrameInfo, false) { _inputState = std::make_unique<InputState>(); _orbitalNavigator = std::make_unique<OrbitalNavigator>(); _keyframeNavigator = std::make_unique<KeyframeNavigator>(); // Add the properties addProperty(_useKeyFrameInteraction); addPropertySubOwner(*_orbitalNavigator); } NavigationHandler::~NavigationHandler() {} // NOLINT void NavigationHandler::initialize() { global::parallelPeer.connectionEvent().subscribe( "NavigationHandler", "statusChanged", [this]() { _useKeyFrameInteraction = (global::parallelPeer.status() == ParallelConnection::Status::ClientWithHost); } ); } void NavigationHandler::deinitialize() { global::parallelPeer.connectionEvent().unsubscribe("NavigationHandler"); } void NavigationHandler::setCamera(Camera* camera) { _camera = camera; _orbitalNavigator->setCamera(camera); } const OrbitalNavigator& NavigationHandler::orbitalNavigator() const { return *_orbitalNavigator; } OrbitalNavigator& NavigationHandler::orbitalNavigator() { return *_orbitalNavigator; } KeyframeNavigator& NavigationHandler::keyframeNavigator() const { return *_keyframeNavigator; } bool NavigationHandler::isKeyFrameInteractionEnabled() const { return _useKeyFrameInteraction; } float NavigationHandler::interpolationTime() const { return _orbitalNavigator->retargetInterpolationTime(); } void NavigationHandler::setInterpolationTime(float durationInSeconds) { _orbitalNavigator->setRetargetInterpolationTime(durationInSeconds); } void NavigationHandler::updateCamera(double deltaTime) { ghoul_assert(_inputState != nullptr, "InputState must not be nullptr"); ghoul_assert(_camera != nullptr, "Camera must not be nullptr"); if (_cameraUpdatedFromScript) { _cameraUpdatedFromScript = false; } else if ( ! _playbackModeEnabled ) { if (_camera) { if (_useKeyFrameInteraction) { _keyframeNavigator->updateCamera(*_camera, _playbackModeEnabled); } else { _orbitalNavigator->updateStatesFromInput(*_inputState, deltaTime); _orbitalNavigator->updateCameraStateFromStates(deltaTime); } } } } void NavigationHandler::setEnableKeyFrameInteraction() { _useKeyFrameInteraction = true; } void NavigationHandler::setDisableKeyFrameInteraction() { _useKeyFrameInteraction = false; } void NavigationHandler::triggerPlaybackStart() { _playbackModeEnabled = true; } void NavigationHandler::stopPlayback() { _playbackModeEnabled = false; } Camera* NavigationHandler::camera() const { return _camera; } const InputState& NavigationHandler::inputState() const { return *_inputState; } void NavigationHandler::mouseButtonCallback(MouseButton button, MouseAction action) { _inputState->mouseButtonCallback(button, action); } void NavigationHandler::mousePositionCallback(double x, double y) { _inputState->mousePositionCallback(x, y); } void NavigationHandler::mouseScrollWheelCallback(double pos) { _inputState->mouseScrollWheelCallback(pos); } void NavigationHandler::keyboardCallback(Key key, KeyModifier modifier, KeyAction action) { _inputState->keyboardCallback(key, modifier, action); } void NavigationHandler::setCameraStateFromDictionary(const ghoul::Dictionary& cameraDict) { bool readSuccessful = true; std::string anchor; std::string aim; glm::dvec3 cameraPosition; glm::dvec4 cameraRotation; // Need to read the quaternion as a vector first. readSuccessful &= cameraDict.getValue(KeyAnchor, anchor); readSuccessful &= cameraDict.getValue(KeyPosition, cameraPosition); readSuccessful &= cameraDict.getValue(KeyRotation, cameraRotation); cameraDict.getValue(KeyAim, aim); // Aim is not required if (!readSuccessful) { throw ghoul::RuntimeError( "Position, Rotation and Focus need to be defined for camera dictionary." ); } // Set state _orbitalNavigator->setAnchorNode(anchor); _orbitalNavigator->setAimNode(aim); _camera->setPositionVec3(cameraPosition); _camera->setRotation(glm::dquat( cameraRotation.x, cameraRotation.y, cameraRotation.z, cameraRotation.w)); } ghoul::Dictionary NavigationHandler::cameraStateDictionary() { glm::dvec3 cameraPosition; glm::dquat quat; glm::dvec4 cameraRotation; cameraPosition = _camera->positionVec3(); quat = _camera->rotationQuaternion(); cameraRotation = glm::dvec4(quat.w, quat.x, quat.y, quat.z); ghoul::Dictionary cameraDict; cameraDict.setValue(KeyPosition, cameraPosition); cameraDict.setValue(KeyRotation, cameraRotation); cameraDict.setValue(KeyAnchor, _orbitalNavigator->anchorNode()->identifier()); if (_orbitalNavigator->aimNode()) { cameraDict.setValue(KeyAim, _orbitalNavigator->aimNode()->identifier()); } return cameraDict; } void NavigationHandler::saveCameraStateToFile(const std::string& filepath) { if (!filepath.empty()) { std::string fullpath = absPath(filepath); LINFO(fmt::format("Saving camera position: {}", filepath)); ghoul::Dictionary cameraDict = cameraStateDictionary(); // TODO(abock): Should get the camera state as a dictionary and save the // dictionary to a file in form of a lua state and not use ofstreams here. std::ofstream ofs(fullpath.c_str()); glm::dvec3 p = _camera->positionVec3(); glm::dquat q = _camera->rotationQuaternion(); ofs << "return {" << std::endl; ofs << " " << KeyAnchor << " = " << "\"" << _orbitalNavigator->anchorNode()->identifier() << "\"" << "," << std::endl; if (_orbitalNavigator->aimNode()) { ofs << " " << KeyAim << " = " << "\"" << _orbitalNavigator->aimNode()->identifier() << "\"" << "," << std::endl; } ofs << " " << KeyPosition << " = {" << std::to_string(p.x) << ", " << std::to_string(p.y) << ", " << std::to_string(p.z) << "}," << std::endl; ofs << " " << KeyRotation << " = {" << std::to_string(q.w) << ", " << std::to_string(q.x) << ", " << std::to_string(q.y) << ", " << std::to_string(q.z) << "}," << std::endl; ofs << "}"<< std::endl; ofs.close(); } } void NavigationHandler::restoreCameraStateFromFile(const std::string& filepath) { LINFO(fmt::format("Reading camera state from file: {}", filepath)); if (!FileSys.fileExists(filepath)) { throw ghoul::FileNotFoundError(filepath, "CameraFilePath"); } ghoul::Dictionary cameraDict; try { ghoul::lua::loadDictionaryFromFile(filepath, cameraDict); setCameraStateFromDictionary(cameraDict); _cameraUpdatedFromScript = true; } catch (ghoul::RuntimeError& e) { LWARNING("Unable to set camera position"); LWARNING(e.message); } } void NavigationHandler::setJoystickAxisMapping(int axis, JoystickCameraStates::AxisType mapping, JoystickCameraStates::AxisInvert shouldInvert, JoystickCameraStates::AxisNormalize shouldNormalize) { _orbitalNavigator->joystickStates().setAxisMapping( axis, mapping, shouldInvert, shouldNormalize ); } JoystickCameraStates::AxisInformation NavigationHandler::joystickAxisMapping(int axis) const { return _orbitalNavigator->joystickStates().axisMapping(axis); } void NavigationHandler::setJoystickAxisDeadzone(int axis, float deadzone) { _orbitalNavigator->joystickStates().setDeadzone(axis, deadzone); } float NavigationHandler::joystickAxisDeadzone(int axis) const { return _orbitalNavigator->joystickStates().deadzone(axis); } void NavigationHandler::bindJoystickButtonCommand(int button, std::string command, JoystickAction action, JoystickCameraStates::ButtonCommandRemote remote, std::string documentation) { _orbitalNavigator->joystickStates().bindButtonCommand( button, std::move(command), action, remote, std::move(documentation) ); } void NavigationHandler::clearJoystickButtonCommand(int button) { _orbitalNavigator->joystickStates().clearButtonCommand(button); } std::vector<std::string> NavigationHandler::joystickButtonCommand(int button) const { return _orbitalNavigator->joystickStates().buttonCommand(button); } scripting::LuaLibrary NavigationHandler::luaLibrary() { return { "navigation", { { "setCameraState", &luascriptfunctions::setCameraState, {}, "object", "Set the camera state" }, { "saveCameraStateToFile", &luascriptfunctions::saveCameraStateToFile, {}, "string", "Save the current camera state to file" }, { "restoreCameraStateFromFile", &luascriptfunctions::restoreCameraStateFromFile, {}, "string", "Restore the camera state from file" }, { "retargetAnchor", &luascriptfunctions::retargetAnchor, {}, "void", "Reset the camera direction to point at the anchor node" }, { "retargetAim", &luascriptfunctions::retargetAim, {}, "void", "Reset the camera direction to point at the aim node" }, { "bindJoystickAxis", &luascriptfunctions::bindJoystickAxis, {}, "int, axisType [, isInverted, isNormalized]", "Binds the axis identified by the first argument to be used as the type " "identified by the second argument. If 'isInverted' is 'true', the axis " "value is inverted, if 'isNormalized' is true the axis value is " "normalized from [-1, 1] to [0,1]." }, { "joystickAxis", &luascriptfunctions::joystickAxis, {}, "int", "Returns the joystick axis information for the passed axis. The " "information that is returned is the current axis binding as a string, " "whether the values are inverted as bool, and whether the value are " "normalized as a bool" }, { "setAxisDeadZone", &luascriptfunctions::setJoystickAxisDeadzone, {}, "int, float", "Sets the deadzone for a particular joystick axis which means that any " "input less than this value is completely ignored." }, { "bindJoystickButton", &luascriptfunctions::bindJoystickButton, {}, "int, string [, string, bool]", "Binds a Lua script to be executed when the joystick button identified " "by the first argument is triggered. The third argument determines when " "the script should be executed, this defaults to 'pressed', which means " "that the script is run when the user presses the button. The last " "argument determines whether the command is going to be executable " "locally or remotely. The latter being the default." }, { "clearJoystickButotn", &luascriptfunctions::clearJoystickButton, {}, "int", "Removes all commands that are currently bound to the button identified " "by the first argument" }, { "joystickButton", &luascriptfunctions::joystickButton, {}, "int", "Returns the script that is currently bound to be executed when the " "provided button is pressed" } } }; } } // namespace openspace::interaction
16,107
4,255
// A recursive CPP program to find // LCA of two nodes n1 and n2. #include <bits/stdc++.h> using namespace std; class node { public: int data; node* left, *right; }; /* Function to find LCA of n1 and n2. The function assumes that both n1 and n2 are present in BST */ struct node *lca(struct node* root, int n1, int n2) { while (root != NULL) { // If both n1 and n2 are smaller than root, // then LCA lies in left if (root->data > n1 && root->data > n2) root = root->left; // If both n1 and n2 are greater than root, // then LCA lies in right else if (root->data < n1 && root->data < n2) root = root->right; else break; } return root; } /* Helper function that allocates a new node with the given data.*/ node* newNode(int data) { node* Node = new node(); Node->data = data; Node->left = Node->right = NULL; return(Node); } /* Driver code*/ int main() { // Let us construct the BST // shown in the above figure node *root = newNode(20); root->left = newNode(8); root->right = newNode(22); root->left->left = newNode(4); root->left->right = newNode(12); root->left->right->left = newNode(10); root->left->right->right = newNode(14); int n1 = 10, n2 = 14; node *t = lca(root, n1, n2); cout << "LCA of " << n1 << " and " << n2 << " is " << t->data<<endl; n1 = 14, n2 = 8; t = lca(root, n1, n2); cout<<"LCA of " << n1 << " and " << n2 << " is " << t->data << endl; n1 = 10, n2 = 22; t = lca(root, n1, n2); cout << "LCA of " << n1 << " and " << n2 << " is " << t->data << endl; return 0; }
1,802
705
// // Created by marsevil on 10/01/2021. // #include "Controller.hpp" Controller::Controller(View* _view, sf::path const& _source, sf::path const& _destination, std::string const& _password) : view(_view), source(_source), destination(_destination), password(_password) { // Nothing to do here. } Controller::~Controller() { delete view; } void Controller::checkDirectoryContent(bool encExtension, sf::path sourcePath, sf::path destinationPath, std::vector<Tuple>& diffList) { for (sf::path const& path : sf::directory_iterator(destinationPath)) { sf::path hypotheticalSourcePath(sourcePath / path.filename()); if (encExtension && !sf::is_directory(path)) { if (hypotheticalSourcePath.extension() == ".enc") hypotheticalSourcePath.replace_extension(""); else hypotheticalSourcePath += ".enc"; } if (!exists(hypotheticalSourcePath)) diffList.push_back({ "", path, Tuple::Action::DELETE }); } } std::vector<Tuple> Controller::diff(bool encExtension) const { std::vector<Tuple> diffList(checkConfig(encExtension)); if (sf::last_write_time(source) > sf::last_write_time(destination)) checkDirectoryContent(encExtension, source, destination, diffList); diff(encExtension, source, destination, diffList); return diffList; } void Controller::diff(bool encExtension, sf::path const& sourceDirectory, sf::path const& destinationDirectory, std::vector<Tuple>& diffList) { for (sf::path const& sourcePath : sf::directory_iterator(sourceDirectory)) { sf::path destinationPath(destinationDirectory / sourcePath.filename()); bool isDirectory(sf::is_directory(sourcePath)); if (isDirectory) { // If sourcePath is a directory if (!sf::exists(destinationPath)) diffList.push_back({ sourcePath, destinationPath, Tuple::Action::CREATE_DIR }); else if (sf::last_write_time(sourcePath) > sf::last_write_time(destinationPath)) { checkDirectoryContent(encExtension, sourcePath, destinationPath, diffList); } diff(encExtension, sourcePath, destinationPath, diffList); } else { // If sourcePath is not a directory. if (encExtension) { if (sourcePath.extension() == ".enc") destinationPath.replace_extension(""); else destinationPath += ".enc"; } if (!sf::exists(destinationPath)) diffList.push_back({ sourcePath, destinationPath, Tuple::Action::CREATE }); else if (sf::last_write_time(sourcePath) > sf::last_write_time(destinationPath)) diffList.push_back({ sourcePath, destinationPath, Tuple::Action::UPDATE }); } } } std::vector<Tuple> Controller::checkConfig(bool isCryptography) const { std::vector<Tuple> ret; if (!sf::exists(source)) throw std::runtime_error("Source doesn't exists."); else if (!sf::is_directory(source)) throw std::runtime_error("Source should be a directory."); if (!sf::exists(destination)) ret.push_back({ source, destination, Tuple::Action::CREATE_DIR }); if (isCryptography && password.empty()) throw std::runtime_error("Password should not be empty."); return ret; } Applyer* Controller::getApplyer(const Applyer::Process &process) const { if (process == Applyer::Process::ENCRYPT || process == Applyer::Process::DECRYPT) { return new CryptMan(password); } else if (process == Applyer::Process::COPY) { throw std::runtime_error("Copy function not implemented yet."); } else { throw std::domain_error("Process not supported."); } } void Controller::apply(std::vector<Tuple> const& diffList, Applyer::Process process) const { Applyer* applyer = getApplyer(process); // Apply modifications. for (Tuple const& tuple : diffList) { view->printTask(tuple); if (tuple.toDo == Tuple::Action::CREATE_DIR) sf::create_directories(tuple.destination); else if (tuple.toDo == Tuple::Action::CREATE || tuple.toDo == Tuple::Action::UPDATE) { applyer->setSource(tuple.source); applyer->setDestination(tuple.destination); applyer->apply(process); } else if (tuple.toDo == Tuple::DELETE) sf::remove_all(tuple.destination); view->printDone(); } // Copy last modified time. for (Tuple const& tuple : diffList) { if (tuple.toDo != Tuple::DELETE && tuple.source.lexically_relative(source).has_parent_path()) sf::last_write_time(tuple.destination.parent_path(), sf::last_write_time(tuple.source.parent_path())); } delete applyer; } void Controller::run() { setSource(view->getSource()); setDestination(view->getDestination()); Applyer::Process process(view->getProcess()); Action action(view->getAction()); bool isCryptography = (process == Applyer::DECRYPT || process == Applyer::ENCRYPT); if (isCryptography) setPassword(view->getPassword()); std::vector<Tuple> diffs(diff(isCryptography)); if (action == Action::APPLY && view->confirmDiff(diffs)) apply(diffs, process); else if (action == Action::SHOW) view->printDiff(diffs); }
5,433
1,535
#include "merge_scoring_function_dfp.h" #include "distances.h" #include "factored_transition_system.h" #include "label_equivalence_relation.h" #include "labels.h" #include "transition_system.h" #include "../options/option_parser.h" #include "../options/plugin.h" #include "../utils/markup.h" #include <cassert> using namespace std; namespace merge_and_shrink { vector<int> MergeScoringFunctionDFP::compute_label_ranks( const FactoredTransitionSystem &fts, int index) const { const TransitionSystem &ts = fts.get_transition_system(index); const Distances &distances = fts.get_distances(index); assert(distances.are_goal_distances_computed()); int num_labels = fts.get_labels().get_size(); // Irrelevant (and inactive, i.e. reduced) labels have a dummy rank of -1 vector<int> label_ranks(num_labels, -1); for (const GroupAndTransitions &gat : ts) { const LabelGroup &label_group = gat.label_group; const vector<Transition> &transitions = gat.transitions; // Relevant labels with no transitions have a rank of infinity. int label_rank = INF; bool group_relevant = false; if (static_cast<int>(transitions.size()) == ts.get_size()) { /* A label group is irrelevant in the earlier notion if it has exactly a self loop transition for every state. */ for (const Transition &transition : transitions) { if (transition.target != transition.src) { group_relevant = true; break; } } } else { group_relevant = true; } if (!group_relevant) { label_rank = -1; } else { for (const Transition &transition : transitions) { label_rank = min(label_rank, distances.get_goal_distance(transition.target)); } } for (int label_no : label_group) { label_ranks[label_no] = label_rank; } } return label_ranks; } vector<double> MergeScoringFunctionDFP::compute_scores( const FactoredTransitionSystem &fts, const vector<pair<int, int>> &merge_candidates) { int num_ts = fts.get_size(); vector<vector<int>> transition_system_label_ranks(num_ts); vector<double> scores; scores.reserve(merge_candidates.size()); // Go over all pairs of transition systems and compute their weight. for (pair<int, int> merge_candidate : merge_candidates) { int ts_index1 = merge_candidate.first; int ts_index2 = merge_candidate.second; vector<int> &label_ranks1 = transition_system_label_ranks[ts_index1]; if (label_ranks1.empty()) { label_ranks1 = compute_label_ranks(fts, ts_index1); } vector<int> &label_ranks2 = transition_system_label_ranks[ts_index2]; if (label_ranks2.empty()) { label_ranks2 = compute_label_ranks(fts, ts_index2); } assert(label_ranks1.size() == label_ranks2.size()); // Compute the weight associated with this pair int pair_weight = INF; for (size_t i = 0; i < label_ranks1.size(); ++i) { if (label_ranks1[i] != -1 && label_ranks2[i] != -1) { // label is relevant in both transition_systems int max_label_rank = max(label_ranks1[i], label_ranks2[i]); pair_weight = min(pair_weight, max_label_rank); } } scores.push_back(pair_weight); } return scores; } string MergeScoringFunctionDFP::name() const { return "dfp"; } static shared_ptr<MergeScoringFunction>_parse(options::OptionParser &parser) { parser.document_synopsis( "DFP scoring", "This scoring function computes the 'DFP' score as descrdibed in the " "paper \"Directed model checking with distance-preserving abstractions\" " "by Draeger, Finkbeiner and Podelski (SPIN 2006), adapted to planning in " "the following paper:" + utils::format_conference_reference( {"Silvan Sievers", "Martin Wehrle", "Malte Helmert"}, "Generalized Label Reduction for Merge-and-Shrink Heuristics", "https://ai.dmi.unibas.ch/papers/sievers-et-al-aaai2014.pdf", "Proceedings of the 28th AAAI Conference on Artificial" " Intelligence (AAAI 2014)", "2358-2366", "AAAI Press", "2014")); if (parser.dry_run()) return nullptr; else return make_shared<MergeScoringFunctionDFP>(); } static options::Plugin<MergeScoringFunction> _plugin("dfp", _parse); }
4,690
1,469
#include "mex.h" #include "RigidBodyConstraint.h" #include "drakeMexUtil.h" #include "../RigidBodyManipulator.h" #include <cstring> /* * [num_constraint,constraint_val,iAfun,jAvar,A ,constraint_name,lower_bound,upper_bound] = testMultipleTimeLinearPostureConstraintmex(kinCnst_ptr,q,t) * @param kinCnst_ptr A pointer to a MultipleTimeLinearPostureConstraint object * @param q A nqxnT double vector * @param t A double array, the time moments to evaluate constraint value, bounds and name. * @retval num_constraint The number of constraint active at time t * @retval constraint_val The value of the constraint at time t * @retval iAfun,jAvar,A The sparse matrix sparse(iAfun,jAvar,A,num_constraint,numel(q)) is the gradient of constraint_val w.r.t q * @retval constraint_name The name of the constraint at time t * @retval lower_bound The lower bound of the constraint at time t * @retval upper_bound The upper bound of the constraint at time t * */ void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray *prhs[]) { if(nrhs!=3 || nlhs != 8) { mexErrMsgIdAndTxt("Drake:testMultipleTimeLinearPostureConstrainttmex:BadInputs","Usage [num_cnst,cnst_val,iAfun,jAvar,A,cnst_name,lb,ub] = testMultipleTimeLinearPostureConstraintmex(kinCnst,q,t)"); } MultipleTimeLinearPostureConstraint* cnst = (MultipleTimeLinearPostureConstraint*) getDrakeMexPointer(prhs[0]); int n_breaks = static_cast<int>(mxGetNumberOfElements(prhs[2])); double* t_ptr = new double[n_breaks]; memcpy(t_ptr,mxGetPrSafe(prhs[2]),sizeof(double)*n_breaks); int nq = cnst->getRobotPointer()->num_positions; Eigen::MatrixXd q(nq,n_breaks); if(mxGetM(prhs[1]) != nq || mxGetN(prhs[1]) != n_breaks) { mexErrMsgIdAndTxt("Drake:testMultipleTimeLinearPostureConstraintmex:BadInputs","Argument 2 must be of size nq*n_breaks"); } memcpy(q.data(),mxGetPrSafe(prhs[1]),sizeof(double)*nq*n_breaks); int num_cnst = cnst->getNumConstraint(t_ptr,n_breaks); Eigen::VectorXd c(num_cnst); cnst->feval(t_ptr,n_breaks,q,c); Eigen::VectorXi iAfun; Eigen::VectorXi jAvar; Eigen::VectorXd A; cnst->geval(t_ptr,n_breaks,iAfun,jAvar,A); std::vector<std::string> cnst_names; cnst->name(t_ptr,n_breaks,cnst_names); Eigen::VectorXd lb(num_cnst); Eigen::VectorXd ub(num_cnst); cnst->bounds(t_ptr,n_breaks,lb,ub); Eigen::VectorXd iAfun_tmp(iAfun.size()); Eigen::VectorXd jAvar_tmp(jAvar.size()); for(int i = 0;i<iAfun.size();i++) { iAfun_tmp(i) = (double) iAfun(i)+1; jAvar_tmp(i) = (double) jAvar(i)+1; } plhs[0] = mxCreateDoubleScalar((double) num_cnst); plhs[1] = mxCreateDoubleMatrix(num_cnst,1,mxREAL); memcpy(mxGetPrSafe(plhs[1]),c.data(),sizeof(double)*num_cnst); plhs[2] = mxCreateDoubleMatrix(iAfun_tmp.size(),1,mxREAL); memcpy(mxGetPrSafe(plhs[2]),iAfun_tmp.data(),sizeof(double)*iAfun_tmp.size()); plhs[3] = mxCreateDoubleMatrix(jAvar_tmp.size(),1,mxREAL); memcpy(mxGetPrSafe(plhs[3]),jAvar_tmp.data(),sizeof(double)*jAvar_tmp.size()); plhs[4] = mxCreateDoubleMatrix(A.size(),1,mxREAL); memcpy(mxGetPrSafe(plhs[4]),A.data(),sizeof(double)*A.size()); int name_ndim = 1; mwSize name_dims[] = {(mwSize) num_cnst}; plhs[5] = mxCreateCellArray(name_ndim,name_dims); mxArray *name_ptr; for(int i = 0;i<num_cnst;i++) { name_ptr = mxCreateString(cnst_names[i].c_str()); mxSetCell(plhs[5],i,name_ptr); } plhs[6] = mxCreateDoubleMatrix(num_cnst,1,mxREAL); plhs[7] = mxCreateDoubleMatrix(num_cnst,1,mxREAL); memcpy(mxGetPrSafe(plhs[6]),lb.data(),sizeof(double)*num_cnst); memcpy(mxGetPrSafe(plhs[7]),ub.data(),sizeof(double)*num_cnst); delete[] t_ptr; }
3,732
1,543
#include <string> #include <iostream> #include <vector> #include <utility> #include <algorithm> using namespace std; typedef pair<int,int> PII; typedef vector<PII> VPII; #define a second #define b first int main() { int n; cin>>n; VPII v(n); for (int i=0;i<n;i++) cin>>v[i].a>>v[i].b; sort(v.begin(),v.end()); int answer=0; for (int i=n-1,min=(~0u)>>1;i>=0;i--) { if (v[i].a>min) answer++; else min=v[i].a; } cout<<answer<<endl; return 0; }
544
236
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <config.h> #include <cc/command_interpreter.h> #include <config/module_spec.h> #include <exceptions/exceptions.h> #include <dhcpsrv/parsers/dhcp_parsers.h> #include <process/testutils/d_test_stubs.h> #include <process/d_cfg_mgr.h> #include <boost/foreach.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <gtest/gtest.h> #include <sstream> using namespace std; using namespace isc; using namespace isc::config; using namespace isc::process; using namespace isc::data; using namespace boost::posix_time; namespace { /// @brief Test Class for verifying that configuration context cannot be null /// during construction. class DCtorTestCfgMgr : public DCfgMgrBase { public: /// @brief Constructor - Note that is passes in an empty configuration /// pointer to the base class constructor. DCtorTestCfgMgr() : DCfgMgrBase(DCfgContextBasePtr()) { } /// @brief Destructor virtual ~DCtorTestCfgMgr() { } /// @brief Dummy implementation as this method is abstract. virtual DCfgContextBasePtr createNewContext() { return (DCfgContextBasePtr()); } /// @brief Returns summary of configuration in the textual format. virtual std::string getConfigSummary(const uint32_t) { return (""); } }; /// @brief Test fixture class for testing DCfgMgrBase class. /// It maintains an member instance of DStubCfgMgr and derives from /// ConfigParseTest fixture, thus providing methods for converting JSON /// strings to configuration element sets, checking parse results, /// accessing the configuration context and trying to unparse. class DStubCfgMgrTest : public ConfigParseTest { public: /// @brief Constructor DStubCfgMgrTest():cfg_mgr_(new DStubCfgMgr) { } /// @brief Destructor ~DStubCfgMgrTest() { } /// @brief Convenience method which returns a DStubContextPtr to the /// configuration context. /// /// @return returns a DStubContextPtr. DStubContextPtr getStubContext() { return (boost::dynamic_pointer_cast<DStubContext> (cfg_mgr_->getContext())); } /// @brief Configuration manager instance. DStubCfgMgrPtr cfg_mgr_; }; ///@brief Tests basic construction/destruction of configuration manager. /// Verifies that: /// 1. Proper construction succeeds. /// 2. Configuration context is initialized by construction. /// 3. Destruction works properly. /// 4. Construction with a null context is not allowed. TEST(DCfgMgrBase, construction) { DCfgMgrBasePtr cfg_mgr; // Verify that configuration manager constructions without error. ASSERT_NO_THROW(cfg_mgr.reset(new DStubCfgMgr())); // Verify that the context can be retrieved and is not null. DCfgContextBasePtr context = cfg_mgr->getContext(); EXPECT_TRUE(context); // Verify that the manager can be destructed without error. EXPECT_NO_THROW(cfg_mgr.reset()); // Verify that an attempt to construct a manger with a null context fails. ASSERT_THROW(DCtorTestCfgMgr(), DCfgMgrBaseError); } ///@brief Tests fundamental aspects of configuration parsing. /// Verifies that: /// 1. A correctly formed simple configuration parses without error. /// 2. An error building the element is handled. /// 3. An error committing the element is handled. /// 4. An unknown element error is handled. TEST_F(DStubCfgMgrTest, basicParseTest) { // Create a simple configuration. string config = "{ \"test-value\": [] } "; ASSERT_TRUE(fromJSON(config)); // Verify that we can parse a simple configuration. answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(0)); // Verify that we can check a simple configuration. answer_ = cfg_mgr_->parseConfig(config_set_, true); EXPECT_TRUE(checkAnswer(0)); // Verify that an unknown element error is caught and returns a failed // parse result. SimFailure::set(SimFailure::ftElementUnknown); answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(1)); // Verify that an error is caught too when the config is checked for. SimFailure::set(SimFailure::ftElementUnknown); answer_ = cfg_mgr_->parseConfig(config_set_, true); EXPECT_TRUE(checkAnswer(1)); } ///@brief Tests ordered and non-ordered element parsing /// This test verifies that: /// 1. Non-ordered parsing parses elements in the order they are presented /// by the configuration set (as-they-come). /// 2. A parse order list with too few elements is detected. /// 3. Ordered parsing parses the elements in the order specified by the /// configuration manager's parse order list. /// 4. A parse order list with too many elements is detected. TEST_F(DStubCfgMgrTest, parseOrderTest) { // Element ids used for test. std::string charlie("charlie"); std::string bravo("bravo"); std::string alpha("alpha"); std::string string_test("string_test"); std::string uint32_test("uint32_test"); std::string bool_test("bool_test"); // Create the test configuration with the elements in "random" order. // NOTE that element sets produced by isc::data::Element::fromJSON(), // are in lexical order by element_id. This means that iterating over // such an element set, will present the elements in lexical order. Should // this change, this test will need to be modified accordingly. string config = "{" " \"string_test\": \"hoopla\", " " \"bravo\": [], " " \"uint32_test\": 55, " " \"alpha\": {}, " " \"charlie\": [], " " \"bool_test\": true " "} "; ASSERT_TRUE(fromJSON(config)); // Verify that non-ordered parsing, results in an as-they-come parse order. // Create an expected parse order. // (NOTE that iterating over Element sets produced by fromJSON() will // present the elements in lexical order. Should this change, the expected // order list below would need to be changed accordingly). ElementIdList order_expected; // scalar params should be first and lexically order_expected.push_back(bool_test); order_expected.push_back(string_test); order_expected.push_back(uint32_test); // objects second and lexically order_expected.push_back(alpha); order_expected.push_back(bravo); order_expected.push_back(charlie); // Verify that the manager has an EMPTY parse order list. (Empty list // instructs the manager to parse them as-they-come.) EXPECT_EQ(0, cfg_mgr_->getParseOrder().size()); // Parse the configuration, verify it parses without error. answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(0)); // Verify that the parsed order matches what we expected. EXPECT_TRUE(cfg_mgr_->parsed_order_ == order_expected); // Clear the manager's parse order "memory". cfg_mgr_->parsed_order_.clear(); // Create a parse order list that has too few entries. Verify that // when parsing the test config, it fails. cfg_mgr_->addToParseOrder(charlie); // Verify the parse order list is the size we expect. EXPECT_EQ(1, cfg_mgr_->getParseOrder().size()); // Verify the configuration fails. answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(1)); // Verify that the configuration parses correctly, when the parse order // is correct. Add the needed entries to the parse order cfg_mgr_->addToParseOrder(bravo); cfg_mgr_->addToParseOrder(alpha); // Verify the parse order list is the size we expect. EXPECT_EQ(3, cfg_mgr_->getParseOrder().size()); // Clear the manager's parse order "memory". cfg_mgr_->parsed_order_.clear(); // Verify the configuration parses without error. answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(0)); // Build expected order // primitives should be first and lexically order_expected.clear(); order_expected.push_back(bool_test); order_expected.push_back(string_test); order_expected.push_back(uint32_test); // objects second and by the parse order order_expected.push_back(charlie); order_expected.push_back(bravo); order_expected.push_back(alpha); // Verify that the parsed order is the order we configured. EXPECT_TRUE(cfg_mgr_->parsed_order_ == order_expected); // Create a parse order list that has too many entries. Verify that // when parsing the test config, it fails. cfg_mgr_->addToParseOrder("delta"); // Verify the parse order list is the size we expect. EXPECT_EQ(4, cfg_mgr_->getParseOrder().size()); // Verify the configuration fails. answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(1)); } /// @brief Tests that element ids supported by the base class as well as those /// added by the derived class function properly. /// This test verifies that: /// 1. Boolean parameters can be parsed and retrieved. /// 2. Uint32 parameters can be parsed and retrieved. /// 3. String parameters can be parsed and retrieved. /// 4. Map elements can be parsed and retrieved. /// 5. List elements can be parsed and retrieved. /// 6. Parsing a second configuration, updates the existing context values /// correctly. TEST_F(DStubCfgMgrTest, simpleTypesTest) { // Create a configuration with all of the parameters. string config = "{ \"bool_test\": true , " " \"uint32_test\": 77 , " " \"string_test\": \"hmmm chewy\" , " " \"map_test\" : {} , " " \"list_test\": [] }"; ASSERT_TRUE(fromJSON(config)); // Verify that the configuration parses without error. answer_ = cfg_mgr_->parseConfig(config_set_, false); ASSERT_TRUE(checkAnswer(0)); DStubContextPtr context = getStubContext(); ASSERT_TRUE(context); // Verify that the boolean parameter was parsed correctly by retrieving // its value from the context. bool actual_bool = false; EXPECT_NO_THROW(context->getParam("bool_test", actual_bool)); EXPECT_EQ(true, actual_bool); // Verify that the uint32 parameter was parsed correctly by retrieving // its value from the context. uint32_t actual_uint32 = 0; EXPECT_NO_THROW(context->getParam("uint32_test", actual_uint32)); EXPECT_EQ(77, actual_uint32); // Verify that the string parameter was parsed correctly by retrieving // its value from the context. std::string actual_string = ""; EXPECT_NO_THROW(context->getParam("string_test", actual_string)); EXPECT_EQ("hmmm chewy", actual_string); isc::data::ConstElementPtr object; EXPECT_NO_THROW(context->getObjectParam("map_test", object)); EXPECT_TRUE(object); EXPECT_NO_THROW(context->getObjectParam("list_test", object)); EXPECT_TRUE(object); // Create a configuration which "updates" all of the parameter values. string config2 = "{ \"bool_test\": false , " " \"uint32_test\": 88 , " " \"string_test\": \"ewww yuk!\" , " " \"map_test2\" : {} , " " \"list_test2\": [] }"; ASSERT_TRUE(fromJSON(config2)); // Verify that the configuration parses without error. answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(0)); context = getStubContext(); ASSERT_TRUE(context); // Verify that the boolean parameter was updated correctly by retrieving // its value from the context. actual_bool = true; EXPECT_NO_THROW(context->getParam("bool_test", actual_bool)); EXPECT_FALSE(actual_bool); // Verify that the uint32 parameter was updated correctly by retrieving // its value from the context. actual_uint32 = 0; EXPECT_NO_THROW(context->getParam("uint32_test", actual_uint32)); EXPECT_EQ(88, actual_uint32); // Verify that the string parameter was updated correctly by retrieving // its value from the context. actual_string = ""; EXPECT_NO_THROW(context->getParam("string_test", actual_string)); EXPECT_EQ("ewww yuk!", actual_string); // Verify previous objects are not there. EXPECT_THROW(context->getObjectParam("map_test", object), isc::dhcp::DhcpConfigError); EXPECT_THROW(context->getObjectParam("list_test", object), isc::dhcp::DhcpConfigError); // Verify new map object is there. EXPECT_NO_THROW(context->getObjectParam("map_test2", object)); EXPECT_TRUE(object); // Verify new list object is there. EXPECT_NO_THROW(context->getObjectParam("list_test2", object)); EXPECT_TRUE(object); } /// @brief Tests that the configuration context is preserved after failure /// during parsing causes a rollback. /// 1. Verifies configuration context rollback. TEST_F(DStubCfgMgrTest, rollBackTest) { // Create a configuration with all of the parameters. string config = "{ \"bool_test\": true , " " \"uint32_test\": 77 , " " \"string_test\": \"hmmm chewy\" , " " \"map_test\" : {} , " " \"list_test\": [] }"; ASSERT_TRUE(fromJSON(config)); // Verify that the configuration parses without error. answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(0)); DStubContextPtr context = getStubContext(); ASSERT_TRUE(context); // Verify that all of parameters have the expected values. bool actual_bool = false; EXPECT_NO_THROW(context->getParam("bool_test", actual_bool)); EXPECT_EQ(true, actual_bool); uint32_t actual_uint32 = 0; EXPECT_NO_THROW(context->getParam("uint32_test", actual_uint32)); EXPECT_EQ(77, actual_uint32); std::string actual_string = ""; EXPECT_NO_THROW(context->getParam("string_test", actual_string)); EXPECT_EQ("hmmm chewy", actual_string); isc::data::ConstElementPtr object; EXPECT_NO_THROW(context->getObjectParam("map_test", object)); EXPECT_TRUE(object); EXPECT_NO_THROW(context->getObjectParam("list_test", object)); EXPECT_TRUE(object); // Create a configuration which "updates" all of the parameter values // plus one unknown at the end. string config2 = "{ \"bool_test\": false , " " \"uint32_test\": 88 , " " \"string_test\": \"ewww yuk!\" , " " \"map_test2\" : {} , " " \"list_test2\": [] , " " \"zeta_unknown\": 33 } "; ASSERT_TRUE(fromJSON(config2)); // Force a failure on the last element SimFailure::set(SimFailure::ftElementUnknown); answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(1)); context = getStubContext(); ASSERT_TRUE(context); // Verify that all of parameters have the original values. actual_bool = false; EXPECT_NO_THROW(context->getParam("bool_test", actual_bool)); EXPECT_EQ(true, actual_bool); actual_uint32 = 0; EXPECT_NO_THROW(context->getParam("uint32_test", actual_uint32)); EXPECT_EQ(77, actual_uint32); actual_string = ""; EXPECT_NO_THROW(context->getParam("string_test", actual_string)); EXPECT_EQ("hmmm chewy", actual_string); EXPECT_NO_THROW(context->getObjectParam("map_test", object)); EXPECT_TRUE(object); EXPECT_NO_THROW(context->getObjectParam("list_test", object)); EXPECT_TRUE(object); } /// @brief Tests that the configuration context is preserved during /// check only parsing. TEST_F(DStubCfgMgrTest, checkOnly) { // Create a configuration with all of the parameters. string config = "{ \"bool_test\": true , " " \"uint32_test\": 77 , " " \"string_test\": \"hmmm chewy\" , " " \"map_test\" : {} , " " \"list_test\": [] }"; ASSERT_TRUE(fromJSON(config)); // Verify that the configuration parses without error. answer_ = cfg_mgr_->parseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(0)); DStubContextPtr context = getStubContext(); ASSERT_TRUE(context); // Verify that all of parameters have the expected values. bool actual_bool = false; EXPECT_NO_THROW(context->getParam("bool_test", actual_bool)); EXPECT_EQ(true, actual_bool); uint32_t actual_uint32 = 0; EXPECT_NO_THROW(context->getParam("uint32_test", actual_uint32)); EXPECT_EQ(77, actual_uint32); std::string actual_string = ""; EXPECT_NO_THROW(context->getParam("string_test", actual_string)); EXPECT_EQ("hmmm chewy", actual_string); isc::data::ConstElementPtr object; EXPECT_NO_THROW(context->getObjectParam("map_test", object)); EXPECT_TRUE(object); EXPECT_NO_THROW(context->getObjectParam("list_test", object)); EXPECT_TRUE(object); // Create a configuration which "updates" all of the parameter values. string config2 = "{ \"bool_test\": false , " " \"uint32_test\": 88 , " " \"string_test\": \"ewww yuk!\" , " " \"map_test2\" : {} , " " \"list_test2\": [] }"; ASSERT_TRUE(fromJSON(config2)); answer_ = cfg_mgr_->parseConfig(config_set_, true); EXPECT_TRUE(checkAnswer(0)); context = getStubContext(); ASSERT_TRUE(context); // Verify that all of parameters have the original values. actual_bool = false; EXPECT_NO_THROW(context->getParam("bool_test", actual_bool)); EXPECT_EQ(true, actual_bool); actual_uint32 = 0; EXPECT_NO_THROW(context->getParam("uint32_test", actual_uint32)); EXPECT_EQ(77, actual_uint32); actual_string = ""; EXPECT_NO_THROW(context->getParam("string_test", actual_string)); EXPECT_EQ("hmmm chewy", actual_string); EXPECT_NO_THROW(context->getObjectParam("map_test", object)); EXPECT_TRUE(object); EXPECT_NO_THROW(context->getObjectParam("list_test", object)); EXPECT_TRUE(object); } // Tests that configuration element position is returned by getParam variants. TEST_F(DStubCfgMgrTest, paramPosition) { // Create a configuration with one of each scalar types. We end them // with line feeds so we can test position value. string config = "{ \"bool_test\": true , \n" " \"uint32_test\": 77 , \n" " \"string_test\": \"hmmm chewy\" }"; ASSERT_TRUE(fromJSON(config)); // Verify that the configuration parses without error. answer_ = cfg_mgr_->parseConfig(config_set_, false); ASSERT_TRUE(checkAnswer(0)); DStubContextPtr context = getStubContext(); ASSERT_TRUE(context); // Verify that the boolean parameter was parsed correctly by retrieving // its value from the context. bool actual_bool = false; isc::data::Element::Position pos; EXPECT_NO_THROW(pos = context->getParam("bool_test", actual_bool)); EXPECT_EQ(true, actual_bool); EXPECT_EQ(1, pos.line_); // Verify that the uint32 parameter was parsed correctly by retrieving // its value from the context. uint32_t actual_uint32 = 0; EXPECT_NO_THROW(pos = context->getParam("uint32_test", actual_uint32)); EXPECT_EQ(77, actual_uint32); EXPECT_EQ(2, pos.line_); // Verify that the string parameter was parsed correctly by retrieving // its value from the context. std::string actual_string = ""; EXPECT_NO_THROW(pos = context->getParam("string_test", actual_string)); EXPECT_EQ("hmmm chewy", actual_string); EXPECT_EQ(3, pos.line_); // Verify that an optional parameter that is not defined, returns the // zero position. pos = isc::data::Element::ZERO_POSITION(); EXPECT_NO_THROW(pos = context->getParam("bogus_value", actual_string, true)); EXPECT_EQ(pos.file_, isc::data::Element::ZERO_POSITION().file_); } // This tests if some aspects of simpleParseConfig are behaving properly. // Thorough testing is only possible for specific implementations. This // is done for control agent (see CtrlAgentControllerTest tests in // src/bin/agent/tests/ctrl_agent_controller_unittest.cc for example). // Also, shell tests in src/bin/agent/ctrl_agent_process_tests.sh test // the whole CA process that uses simpleParseConfig. The alternative // would be to implement whole parser that would set the context // properly. The ROI for this is not worth the effort. TEST_F(DStubCfgMgrTest, simpleParseConfig) { using namespace isc::data; // Passing just null pointer should result in error return code answer_ = cfg_mgr_->simpleParseConfig(ConstElementPtr(), false); EXPECT_TRUE(checkAnswer(1)); // Ok, now try with a dummy, but valid json code string config = "{ \"bool_test\": true , \n" " \"uint32_test\": 77 , \n" " \"string_test\": \"hmmm chewy\" }"; ASSERT_NO_THROW(fromJSON(config)); answer_ = cfg_mgr_->simpleParseConfig(config_set_, false); EXPECT_TRUE(checkAnswer(0)); } // This test checks that the post configuration callback function is // executed by the simpleParseConfig function. TEST_F(DStubCfgMgrTest, simpleParseConfigWithCallback) { string config = "{ \"bool_test\": true , \n" " \"uint32_test\": 77 , \n" " \"string_test\": \"hmmm chewy\" }"; ASSERT_NO_THROW(fromJSON(config)); answer_ = cfg_mgr_->simpleParseConfig(config_set_, false, [this]() { isc_throw(Unexpected, "unexpected configuration error"); }); EXPECT_TRUE(checkAnswer(1)); } } // end of anonymous namespace
22,099
6,973
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // Intel License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000, Intel Corporation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's 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. // // * The name of Intel Corporation may not 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 Intel Corporation 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. // //M*/ #include "precomp.hpp" /*F/////////////////////////////////////////////////////////////////////////////////////// // Name: cvMatchContours // Purpose: // Calculates matching of the two contours // Context: // Parameters: // contour_1 - pointer to the first input contour object. // contour_2 - pointer to the second input contour object. // method - method for the matching calculation // (now CV_IPPI_CONTOURS_MATCH_I1, CV_CONTOURS_MATCH_I2 or // CV_CONTOURS_MATCH_I3 only ) // rezult - output calculated measure // //F*/ CV_IMPL double cvMatchShapes( const void* contour1, const void* contour2, int method, double /*parameter*/ ) { CvMoments moments; CvHuMoments huMoments; double ma[7], mb[7]; int i, sma, smb; double eps = 1.e-5; double mmm; double result = 0; if( !contour1 || !contour2 ) CV_Error( CV_StsNullPtr, "" ); // calculate moments of the first shape cvMoments( contour1, &moments ); cvGetHuMoments( &moments, &huMoments ); ma[0] = huMoments.hu1; ma[1] = huMoments.hu2; ma[2] = huMoments.hu3; ma[3] = huMoments.hu4; ma[4] = huMoments.hu5; ma[5] = huMoments.hu6; ma[6] = huMoments.hu7; // calculate moments of the second shape cvMoments( contour2, &moments ); cvGetHuMoments( &moments, &huMoments ); mb[0] = huMoments.hu1; mb[1] = huMoments.hu2; mb[2] = huMoments.hu3; mb[3] = huMoments.hu4; mb[4] = huMoments.hu5; mb[5] = huMoments.hu6; mb[6] = huMoments.hu7; switch (method) { case 1: { for( i = 0; i < 7; i++ ) { double ama = fabs( ma[i] ); double amb = fabs( mb[i] ); if( ma[i] > 0 ) sma = 1; else if( ma[i] < 0 ) sma = -1; else sma = 0; if( mb[i] > 0 ) smb = 1; else if( mb[i] < 0 ) smb = -1; else smb = 0; if( ama > eps && amb > eps ) { ama = 1. / (sma * log10( ama )); amb = 1. / (smb * log10( amb )); result += fabs( -ama + amb ); } } break; } case 2: { for( i = 0; i < 7; i++ ) { double ama = fabs( ma[i] ); double amb = fabs( mb[i] ); if( ma[i] > 0 ) sma = 1; else if( ma[i] < 0 ) sma = -1; else sma = 0; if( mb[i] > 0 ) smb = 1; else if( mb[i] < 0 ) smb = -1; else smb = 0; if( ama > eps && amb > eps ) { ama = sma * log10( ama ); amb = smb * log10( amb ); result += fabs( -ama + amb ); } } break; } case 3: { for( i = 0; i < 7; i++ ) { double ama = fabs( ma[i] ); double amb = fabs( mb[i] ); if( ma[i] > 0 ) sma = 1; else if( ma[i] < 0 ) sma = -1; else sma = 0; if( mb[i] > 0 ) smb = 1; else if( mb[i] < 0 ) smb = -1; else smb = 0; if( ama > eps && amb > eps ) { ama = sma * log10( ama ); amb = smb * log10( amb ); mmm = fabs( (ama - amb) / ama ); if( result < mmm ) result = mmm; } } break; } default: CV_Error( CV_StsBadArg, "Unknown comparison method" ); } return result; } /* End of file. */
6,254
1,955
#include "BejeweledIO.h" #include <stdlib.h> ScoreIO::ScoreIO() : scoreFile("HighScores.txt") { readScores(); } vector<PlayerScore> ScoreIO::readScores() { string HighScores = "HighScores.txt"; ifstream ist(HighScores.c_str()); if(!ist) cout << "High Score File Not Found!" << endl; string temp; string name; int score; int level; while(getline(ist, temp)) { istringstream strInput(temp); strInput>>name>>level>>score; PlayerScore pscore(name, level, score); scores.push_back(pscore); cout << "Score pushed back: Name: " << name << ' ' << level << ' ' << score << endl; } ist.close(); return scores; } void ScoreIO::writeScore(PlayerScore ps) { string HighScores = "HighScores.txt"; ofstream ost(HighScores.c_str()); if(!ost) cout << "High Score File Not Found!\n" << endl; bool scoreMadeIt = false; for (unsigned int i=0; i<scores.size(); i++) { int temp = scores[i].getScore(); if(!scoreMadeIt && ps.getScore()>=temp) { cout << "Writing: " << ps.getName() << " " << ps.getLevel() << " " << ps.getScore() << endl; ost << ps.getName() << " " << ps.getLevel() << " " << ps.getScore() << endl; scoreMadeIt = true; } else { cout << "Writing: " << scores[i].getName() << " " << scores[i].getLevel() << " " << scores[i].getScore() << endl; ost << scores[i].getName() << " " << scores[i].getLevel() << " " << scores[i].getScore() << endl; } } ost.close(); } string readHelpFile(string filename) { ifstream ist(filename.c_str()); if(!ist) return "Help file not found!"; string temp; string helpFile; while(getline(ist, temp)) { helpFile+=temp+'\n'; } ist.close(); return helpFile; } PlayerScore ScoreIO::getPlayer(int idx) { return scores[idx]; }
1,816
722
#include "gpk_encoding.h" #include "gpk_view_bit.h" #include "gpk_noise.h" #include "gpk_chrono.h" #include "gpk_parse.h" #include <ctime> #include <random> ::gpk::error_t gpk::saltDataSalt (const ::gpk::view_const_byte& binary, ::gpk::array_pod<byte_t> & salted) { gpk_necall(salted.resize(binary.size() * 2), "%s", "Out of memory?"); byte_t * pSalted = salted.begin(); const byte_t * pBinary = binary.begin(); for(uint32_t iBinary = 0; iBinary < binary.size(); ++iBinary) { pSalted[iBinary * 2] = pBinary[iBinary]; pSalted[iBinary * 2 + 1] = (::gpk::noise1DBase(::gpk::timeCurrentInUs()) + ::gpk::timeCurrentInUs()) & 0xFF; } return 0; } ::gpk::error_t gpk::saltDataUnsalt (const ::gpk::view_const_byte& salted, ::gpk::array_pod<byte_t> & binary) { gpk_necall(binary.resize(salted.size() / 2), "%s", "Out of memory?"); const byte_t * pSalted = salted.begin(); byte_t * pBinary = binary.begin(); for(uint32_t iBinary = 0; iBinary < binary.size(); ++iBinary) pBinary[iBinary] = pSalted[iBinary * 2]; return 0; } static ::gpk::error_t hexFromByte (uint8_t i, char* hexed) { char converted [0x20] = {}; snprintf(converted, ::gpk::size(converted) - 1, "%*.2X", 2, i); hexed[0] = converted[0]; hexed[1] = converted[1]; return 0; } static ::gpk::error_t hexToByte (const char* s, uint8_t& byte) { char temp [3] = {s[0], s[1]}; gpk_necall(::gpk::parseIntegerHexadecimal(::gpk::vcs{temp}, &byte), "%s", ""); return 0; } static ::gpk::error_t hexToByte (const char* s, byte_t& byte) { char temp [3] = {s[0], s[1]}; gpk_necall(::gpk::parseIntegerHexadecimal(::gpk::vcs{temp}, &byte), "%s", ""); return 0; } ::gpk::error_t gpk::hexEncode (const ::gpk::view_array<const ubyte_t > & in_binary, ::gpk::array_pod<char_t > & out_hexed ) { uint32_t offset = out_hexed.size(); gpk_necall(out_hexed.resize(offset + in_binary.size() * 2), "%s", "Out of memory?"); byte_t * pHexed = out_hexed.begin(); const ubyte_t * pBinary = in_binary.begin(); for(uint32_t iByte = 0; iByte < in_binary.size(); ++iByte) hexFromByte(pBinary[iByte], &pHexed[offset + iByte * 2]); return 0; } ::gpk::error_t gpk::hexDecode (const ::gpk::view_array<const char_t > & in_hexed , ::gpk::array_pod<ubyte_t > & out_binary) { uint32_t offset = out_binary.size(); uint32_t binarySize = in_hexed.size() >> 1; gpk_necall(out_binary.resize(offset + binarySize), "%s", "Out of memory?"); const byte_t * pHexed = in_hexed.begin(); ubyte_t * pBinary = out_binary.begin(); for(uint32_t iByte = 0; iByte < binarySize; ++iByte) hexToByte(&pHexed[iByte * 2], pBinary[offset + iByte]); return 0; } ::gpk::error_t gpk::hexDecode (const ::gpk::view_array<const char_t > & in_hexed , ::gpk::array_pod<byte_t > & out_binary) { uint32_t offset = out_binary.size(); uint32_t binarySize = in_hexed.size() >> 1; gpk_necall(out_binary.resize(offset + binarySize), "%s", "Out of memory?"); const byte_t * pHexed = in_hexed.begin(); byte_t * pBinary = out_binary.begin(); for(uint32_t iByte = 0; iByte < binarySize; ++iByte) hexToByte(&pHexed[iByte * 2], pBinary[offset + iByte]); return 0; } ::gpk::error_t gpk::ardellEncode (::gpk::array_pod<int32_t> & cache, const ::gpk::view_array<const byte_t>& input, uint64_t key, bool salt, ::gpk::array_pod<byte_t>& output) { // Originally written by Gary Ardell as Visual Basic code. free from all copyright restrictions. char saltValue [4] = {}; if (salt) for (int32_t i = 0; i < 4; i++) { int32_t t = 100 * (1 + saltValue[i]) * rand() * (((int32_t)time(0)) + 1); saltValue[i] = t % 256; } const int32_t keyFinal[8] = { (int32_t)(11 + (key % 233)) , (int32_t)( 7 + (key % 239)) , (int32_t)( 5 + (key % 241)) , (int32_t)( 3 + (key % 251)) }; int32_t n = salt ? input.size() + 4 : input.size(); gpk_necall(cache.resize(n), "%s", "Out of memory?"); int32_t * sn = cache.begin(); if(salt) { for(int32_t i = 0; i < 2; ++i) sn[i] = saltValue[i]; for(int32_t i = 0; i < n - 4; ++i) sn[2 + i] = input[i]; for(int32_t i = 0; i < 2; ++i) sn[2 + n + i] = saltValue[2 + i]; } else for(int32_t i = 0; i < n; ++i) sn[i] = input[i]; int32_t i; for(i = 1 ; i < n; ++i) sn[i] = sn[i] ^ sn[i - 1] ^ ((keyFinal[0] * sn[i - 1]) % 256); for(i = n - 2 ; i >= 0; --i) sn[i] = sn[i] ^ sn[i + 1] ^ (keyFinal[1] * sn[i + 1]) % 256 ; for(i = 2 ; i < n; ++i) sn[i] = sn[i] ^ sn[i - 2] ^ (keyFinal[2] * sn[i - 1]) % 256 ; for(i = n - 3 ; i >= 0; --i) sn[i] = sn[i] ^ sn[i + 2] ^ (keyFinal[3] * sn[i + 1]) % 256 ; uint32_t outputOffset = output.size(); gpk_necall(output.resize(outputOffset + n), "%s", "Out of memory?"); byte_t * outputFast = output.begin(); for( i = 0; i < n; ++i) outputFast[outputOffset + i] = (char)sn[i]; return 0; } ::gpk::error_t gpk::ardellDecode (::gpk::array_pod<int32_t> & cache, const ::gpk::view_array<const byte_t>& input, uint64_t key, bool salt, ::gpk::array_pod<byte_t>& output) { // Originally written by Gary Ardell as Visual Basic code. free from all copyright restrictions. const int32_t keyFinal[8] = { (int32_t)(11 + (key % 233)) , (int32_t)( 7 + (key % 239)) , (int32_t)( 5 + (key % 241)) , (int32_t)( 3 + (key % 251)) }; int32_t n = (int32_t)input.size(); gpk_necall(cache.resize(n), "%s", "Out of memory?"); int32_t * sn = cache.begin(); int32_t i; for(i = 0 ; i < n ; ++i) sn[i] = input[i]; for(i = 0 ; i < n - 2; ++i) sn[i] = sn[i] ^ sn[i + 2] ^ (keyFinal[3] * sn[i + 1]) % 256; for(i = n - 1 ; i >= 2 ; --i) sn[i] = sn[i] ^ sn[i - 2] ^ (keyFinal[2] * sn[i - 1]) % 256; for(i = 0 ; i < n - 1; ++i) sn[i] = sn[i] ^ sn[i + 1] ^ (keyFinal[1] * sn[i + 1]) % 256; for(i = n - 1 ; i >= 1 ; --i) sn[i] = sn[i] ^ sn[i - 1] ^ (keyFinal[0] * sn[i - 1]) % 256; uint32_t outputOffset = output.size(); const uint32_t finalStringSize = salt ? n - 4 : n; const ::gpk::view_array<const int32_t> finalValues = {salt ? &sn[2] : sn, finalStringSize}; gpk_necall(output.resize(outputOffset + finalStringSize), "%s", "Out of memory?"); byte_t * outputFast = output.begin(); const int32_t * finalValuesFast = finalValues.begin(); for( i = 0; i < (int32_t)finalStringSize; ++i) outputFast[outputOffset + i] = (char)finalValuesFast[i]; return 0; } ::gpk::error_t gpk::utf8FromCodePoint (uint32_t codePoint, ::gpk::array_pod<char_t> & hexDigits) { const uint32_t offset = hexDigits.size(); if (codePoint <= 0x7f) { hexDigits.resize(offset + 1); hexDigits[offset + 0] = static_cast<char>(codePoint); } else { if (codePoint <= 0x7FF) { hexDigits.resize(offset + 2); hexDigits[offset + 1] = static_cast<char>(0x80 | (0x3f & codePoint)); hexDigits[offset + 0] = static_cast<char>(0xC0 | (0x1f & (codePoint >> 6))); } else if (codePoint <= 0xFFFF) { hexDigits.resize(offset + 3); hexDigits[offset + 2] = static_cast<char>(0x80 | (0x3f & codePoint)); hexDigits[offset + 1] = static_cast<char>(0x80 | (0x3f & (codePoint >> 6))); hexDigits[offset + 0] = static_cast<char>(0xE0 | (0x0f & (codePoint >> 12))); } else if (codePoint <= 0x10FFFF) { hexDigits.resize(offset + 4); hexDigits[offset + 3] = static_cast<char>(0x80 | (0x3f & codePoint)); hexDigits[offset + 2] = static_cast<char>(0x80 | (0x3f & (codePoint >> 6))); hexDigits[offset + 1] = static_cast<char>(0x80 | (0x3f & (codePoint >> 12))); hexDigits[offset + 0] = static_cast<char>(0xF0 | (0x07 & (codePoint >> 18))); } } return 0; } ::gpk::error_t gpk::digest (const ::gpk::view_const_byte & input, ::gpk::array_pod<uint32_t> & digest) { uint32_t x = 0; ::gpk::array_pod<uint32_t> filtered = {}; for(uint32_t i = 0; i < input.size() - 8; ++i) { x += ::gpk::noise1DBase32(input[i]) + ::gpk::noise1DBase32(input[i + 1]) + ::gpk::noise1DBase32(input[i + 2]) + ::gpk::noise1DBase32(input[i + 3]) + ::gpk::noise1DBase32(input[i + 4]) + ::gpk::noise1DBase32(input[i + 5]) + ::gpk::noise1DBase32(input[i + 6]) + ::gpk::noise1DBase32(input[i + 7]) ; x += x ^ (x << 11); filtered.push_back(x); } for(uint32_t i = 0; i < filtered.size() - 8; ++i) { filtered[i] ^= ::gpk::noise1DBase32(filtered[i]) + ::gpk::noise1DBase32(filtered[i + 1]) + ::gpk::noise1DBase32(filtered[i + 2]) + ::gpk::noise1DBase32(filtered[i + 3]) + ::gpk::noise1DBase32(filtered[i + 4]) + ::gpk::noise1DBase32(filtered[i + 5]) + ::gpk::noise1DBase32(filtered[i + 6]) + ::gpk::noise1DBase32(filtered[i + 7]) ; } for(uint32_t i = 2; i < (filtered.size() - 32); i += 2) { for(uint32_t j = 0; j < 32; j++) filtered[j] += filtered[i + j]; } digest.append({filtered.begin(), ::gpk::min(32U, filtered.size())}); return 0; } ::gpk::error_t gpk::digest (const ::gpk::view_const_byte & input, ::gpk::array_pod<byte_t> & digest) { uint32_t x = 0; ::gpk::array_pod<uint32_t> filtered = {}; for(uint32_t i = 0; i < input.size() - 8; ++i) { x += ::gpk::noise1DBase32(input[i]) + ::gpk::noise1DBase32(input[i + 1]) + ::gpk::noise1DBase32(input[i + 2]) + ::gpk::noise1DBase32(input[i + 3]) + ::gpk::noise1DBase32(input[i + 4]) + ::gpk::noise1DBase32(input[i + 5]) + ::gpk::noise1DBase32(input[i + 6]) + ::gpk::noise1DBase32(input[i + 7]) ; x += x ^ (x << 11); filtered.push_back(x); } for(uint32_t i = 0; i < filtered.size() - 8; ++i) { filtered[i] ^= ::gpk::noise1DBase32(filtered[i]) + ::gpk::noise1DBase32(filtered[i + 1]) + ::gpk::noise1DBase32(filtered[i + 2]) + ::gpk::noise1DBase32(filtered[i + 3]) + ::gpk::noise1DBase32(filtered[i + 4]) + ::gpk::noise1DBase32(filtered[i + 5]) + ::gpk::noise1DBase32(filtered[i + 6]) + ::gpk::noise1DBase32(filtered[i + 7]) ; } for(uint32_t i = 2, count = (filtered.size() - 8); i < count; i += 2) { for(uint32_t j = 0; j < 8; j++) filtered[j] += filtered[i + j]; } char temp [32] = {}; for(uint32_t i = 0; i < ::gpk::min(filtered.size(), 8U); ++i) { snprintf(temp, ::gpk::size(temp) - 2, "%i", filtered[i]); digest.append_string(temp); } return 0; }
11,528
6,724
#include "amr-wind/equation_systems/icns/source_terms/BodyForce.H" #include "amr-wind/CFDSim.H" #include "amr-wind/utilities/trig_ops.H" #include "AMReX_ParmParse.H" #include "AMReX_Gpu.H" namespace amr_wind { namespace pde { namespace icns { /** Body Force */ BodyForce::BodyForce(const CFDSim& sim) : m_time(sim.time()) { // Read the geostrophic wind speed vector (in m/s) amrex::ParmParse pp("BodyForce"); pp.query("type", m_type); m_type = amrex::toLower(m_type); pp.getarr("magnitude", m_body_force); if (m_type == "oscillatory") pp.get("angular_frequency", m_omega); } BodyForce::~BodyForce() = default; void BodyForce::operator()( const int lev, const amrex::MFIter& mfi, const amrex::Box& bx, const FieldState fstate, const amrex::Array4<amrex::Real>& src_term) const { const auto& time = m_time.current_time(); amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> forcing{ {m_body_force[0], m_body_force[1], m_body_force[2]}}; amrex::Real coeff = (m_type == "oscillatory") ? std::cos(m_omega * time) : 1.0; amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { src_term(i, j, k, 0) += coeff * forcing[0]; src_term(i, j, k, 1) += coeff * forcing[1]; src_term(i, j, k, 2) += coeff * forcing[2]; }); } } // namespace icns } // namespace pde } // namespace amr_wind
1,400
584
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "Types.h" #include "Unicode.h" namespace graphql::mapi { StringId::StringId(PCWSTR name) : m_name { convert::utf8::to_utf8(name) } { } const std::string& StringId::getName() const { return m_name; } } // namespace graphql::mapi
339
122
/* * Copyright (C) 2014 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 "graph_checker.h" #include <map> #include <string> #include <sstream> #include "base/bit_vector-inl.h" #include "base/stringprintf.h" namespace art { void GraphChecker::VisitBasicBlock(HBasicBlock* block) { current_block_ = block; // Check consistency with respect to predecessors of `block`. const GrowableArray<HBasicBlock*>& predecessors = block->GetPredecessors(); std::map<HBasicBlock*, size_t> predecessors_count; for (size_t i = 0, e = predecessors.Size(); i < e; ++i) { HBasicBlock* p = predecessors.Get(i); ++predecessors_count[p]; } for (auto& pc : predecessors_count) { HBasicBlock* p = pc.first; size_t p_count_in_block_predecessors = pc.second; const GrowableArray<HBasicBlock*>& p_successors = p->GetSuccessors(); size_t block_count_in_p_successors = 0; for (size_t j = 0, f = p_successors.Size(); j < f; ++j) { if (p_successors.Get(j) == block) { ++block_count_in_p_successors; } } if (p_count_in_block_predecessors != block_count_in_p_successors) { AddError(StringPrintf( "Block %d lists %zu occurrences of block %d in its predecessors, whereas " "block %d lists %zu occurrences of block %d in its successors.", block->GetBlockId(), p_count_in_block_predecessors, p->GetBlockId(), p->GetBlockId(), block_count_in_p_successors, block->GetBlockId())); } } // Check consistency with respect to successors of `block`. const GrowableArray<HBasicBlock*>& successors = block->GetSuccessors(); std::map<HBasicBlock*, size_t> successors_count; for (size_t i = 0, e = successors.Size(); i < e; ++i) { HBasicBlock* s = successors.Get(i); ++successors_count[s]; } for (auto& sc : successors_count) { HBasicBlock* s = sc.first; size_t s_count_in_block_successors = sc.second; const GrowableArray<HBasicBlock*>& s_predecessors = s->GetPredecessors(); size_t block_count_in_s_predecessors = 0; for (size_t j = 0, f = s_predecessors.Size(); j < f; ++j) { if (s_predecessors.Get(j) == block) { ++block_count_in_s_predecessors; } } if (s_count_in_block_successors != block_count_in_s_predecessors) { AddError(StringPrintf( "Block %d lists %zu occurrences of block %d in its successors, whereas " "block %d lists %zu occurrences of block %d in its predecessors.", block->GetBlockId(), s_count_in_block_successors, s->GetBlockId(), s->GetBlockId(), block_count_in_s_predecessors, block->GetBlockId())); } } // Ensure `block` ends with a branch instruction. if (!block->EndsWithControlFlowInstruction()) { AddError(StringPrintf("Block %d does not end with a branch instruction.", block->GetBlockId())); } // Visit this block's list of phis. for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { HInstruction* current = it.Current(); // Ensure this block's list of phis contains only phis. if (!current->IsPhi()) { AddError(StringPrintf("Block %d has a non-phi in its phi list.", current_block_->GetBlockId())); } if (current->GetNext() == nullptr && current != block->GetLastPhi()) { AddError(StringPrintf("The recorded last phi of block %d does not match " "the actual last phi %d.", current_block_->GetBlockId(), current->GetId())); } current->Accept(this); } // Visit this block's list of instructions. for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) { HInstruction* current = it.Current(); // Ensure this block's list of instructions does not contains phis. if (current->IsPhi()) { AddError(StringPrintf("Block %d has a phi in its non-phi list.", current_block_->GetBlockId())); } if (current->GetNext() == nullptr && current != block->GetLastInstruction()) { AddError(StringPrintf("The recorded last instruction of block %d does not match " "the actual last instruction %d.", current_block_->GetBlockId(), current->GetId())); } current->Accept(this); } } void GraphChecker::VisitBoundsCheck(HBoundsCheck* check) { if (!GetGraph()->HasBoundsChecks()) { AddError(StringPrintf("Instruction %s:%d is a HBoundsCheck, " "but HasBoundsChecks() returns false", check->DebugName(), check->GetId())); } // Perform the instruction base checks too. VisitInstruction(check); } void GraphChecker::VisitInstruction(HInstruction* instruction) { if (seen_ids_.IsBitSet(instruction->GetId())) { AddError(StringPrintf("Instruction id %d is duplicate in graph.", instruction->GetId())); } else { seen_ids_.SetBit(instruction->GetId()); } // Ensure `instruction` is associated with `current_block_`. if (instruction->GetBlock() == nullptr) { AddError(StringPrintf("%s %d in block %d not associated with any block.", instruction->IsPhi() ? "Phi" : "Instruction", instruction->GetId(), current_block_->GetBlockId())); } else if (instruction->GetBlock() != current_block_) { AddError(StringPrintf("%s %d in block %d associated with block %d.", instruction->IsPhi() ? "Phi" : "Instruction", instruction->GetId(), current_block_->GetBlockId(), instruction->GetBlock()->GetBlockId())); } // Ensure the inputs of `instruction` are defined in a block of the graph. for (HInputIterator input_it(instruction); !input_it.Done(); input_it.Advance()) { HInstruction* input = input_it.Current(); const HInstructionList& list = input->IsPhi() ? input->GetBlock()->GetPhis() : input->GetBlock()->GetInstructions(); if (!list.Contains(input)) { AddError(StringPrintf("Input %d of instruction %d is not defined " "in a basic block of the control-flow graph.", input->GetId(), instruction->GetId())); } } // Ensure the uses of `instruction` are defined in a block of the graph, // and the entry in the use list is consistent. for (HUseIterator<HInstruction*> use_it(instruction->GetUses()); !use_it.Done(); use_it.Advance()) { HInstruction* use = use_it.Current()->GetUser(); const HInstructionList& list = use->IsPhi() ? use->GetBlock()->GetPhis() : use->GetBlock()->GetInstructions(); if (!list.Contains(use)) { AddError(StringPrintf("User %s:%d of instruction %d is not defined " "in a basic block of the control-flow graph.", use->DebugName(), use->GetId(), instruction->GetId())); } size_t use_index = use_it.Current()->GetIndex(); if ((use_index >= use->InputCount()) || (use->InputAt(use_index) != instruction)) { AddError(StringPrintf("User %s:%d of instruction %d has a wrong " "UseListNode index.", use->DebugName(), use->GetId(), instruction->GetId())); } } // Ensure the environment uses entries are consistent. for (HUseIterator<HEnvironment*> use_it(instruction->GetEnvUses()); !use_it.Done(); use_it.Advance()) { HEnvironment* use = use_it.Current()->GetUser(); size_t use_index = use_it.Current()->GetIndex(); if ((use_index >= use->Size()) || (use->GetInstructionAt(use_index) != instruction)) { AddError(StringPrintf("Environment user of %s:%d has a wrong " "UseListNode index.", instruction->DebugName(), instruction->GetId())); } } // Ensure 'instruction' has pointers to its inputs' use entries. for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) { HUserRecord<HInstruction*> input_record = instruction->InputRecordAt(i); HInstruction* input = input_record.GetInstruction(); HUseListNode<HInstruction*>* use_node = input_record.GetUseNode(); size_t use_index = use_node->GetIndex(); if ((use_node == nullptr) || !input->GetUses().Contains(use_node) || (use_index >= e) || (use_index != i)) { AddError(StringPrintf("Instruction %s:%d has an invalid pointer to use entry " "at input %u (%s:%d).", instruction->DebugName(), instruction->GetId(), static_cast<unsigned>(i), input->DebugName(), input->GetId())); } } } void GraphChecker::VisitInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) { VisitInstruction(invoke); if (invoke->IsStaticWithExplicitClinitCheck()) { size_t last_input_index = invoke->InputCount() - 1; HInstruction* last_input = invoke->InputAt(last_input_index); if (last_input == nullptr) { AddError(StringPrintf("Static invoke %s:%d marked as having an explicit clinit check " "has a null pointer as last input.", invoke->DebugName(), invoke->GetId())); } if (!last_input->IsClinitCheck() && !last_input->IsLoadClass()) { AddError(StringPrintf("Static invoke %s:%d marked as having an explicit clinit check " "has a last instruction (%s:%d) which is neither a clinit check " "nor a load class instruction.", invoke->DebugName(), invoke->GetId(), last_input->DebugName(), last_input->GetId())); } } } void GraphChecker::VisitCheckCast(HCheckCast* check) { VisitInstruction(check); HInstruction* input = check->InputAt(1); if (!input->IsLoadClass()) { AddError(StringPrintf("%s:%d expects a HLoadClass as second input, not %s:%d.", check->DebugName(), check->GetId(), input->DebugName(), input->GetId())); } } void GraphChecker::VisitInstanceOf(HInstanceOf* instruction) { VisitInstruction(instruction); HInstruction* input = instruction->InputAt(1); if (!input->IsLoadClass()) { AddError(StringPrintf("%s:%d expects a HLoadClass as second input, not %s:%d.", instruction->DebugName(), instruction->GetId(), input->DebugName(), input->GetId())); } } void SSAChecker::VisitBasicBlock(HBasicBlock* block) { super_type::VisitBasicBlock(block); // Ensure there is no critical edge (i.e., an edge connecting a // block with multiple successors to a block with multiple // predecessors). if (block->GetSuccessors().Size() > 1) { for (size_t j = 0; j < block->GetSuccessors().Size(); ++j) { HBasicBlock* successor = block->GetSuccessors().Get(j); if (successor->GetPredecessors().Size() > 1) { AddError(StringPrintf("Critical edge between blocks %d and %d.", block->GetBlockId(), successor->GetBlockId())); } } } // Check Phi uniqueness (no two Phis with the same type refer to the same register). for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { HPhi* phi = it.Current()->AsPhi(); if (phi->GetNextEquivalentPhiWithSameType() != nullptr) { std::stringstream type_str; type_str << phi->GetType(); AddError(StringPrintf("Equivalent phi (%d) found for VReg %d with type: %s", phi->GetId(), phi->GetRegNumber(), type_str.str().c_str())); } } if (block->IsLoopHeader()) { CheckLoop(block); } } void SSAChecker::CheckLoop(HBasicBlock* loop_header) { int id = loop_header->GetBlockId(); HLoopInformation* loop_information = loop_header->GetLoopInformation(); // Ensure the pre-header block is first in the list of // predecessors of a loop header. if (!loop_header->IsLoopPreHeaderFirstPredecessor()) { AddError(StringPrintf( "Loop pre-header is not the first predecessor of the loop header %d.", id)); } // Ensure the loop header has only one incoming branch and the remaining // predecessors are back edges. size_t num_preds = loop_header->GetPredecessors().Size(); if (num_preds < 2) { AddError(StringPrintf( "Loop header %d has less than two predecessors: %zu.", id, num_preds)); } else { HBasicBlock* first_predecessor = loop_header->GetPredecessors().Get(0); if (loop_information->IsBackEdge(*first_predecessor)) { AddError(StringPrintf( "First predecessor of loop header %d is a back edge.", id)); } for (size_t i = 1, e = loop_header->GetPredecessors().Size(); i < e; ++i) { HBasicBlock* predecessor = loop_header->GetPredecessors().Get(i); if (!loop_information->IsBackEdge(*predecessor)) { AddError(StringPrintf( "Loop header %d has multiple incoming (non back edge) blocks.", id)); } } } const ArenaBitVector& loop_blocks = loop_information->GetBlocks(); // Ensure back edges belong to the loop. size_t num_back_edges = loop_information->GetBackEdges().Size(); if (num_back_edges == 0) { AddError(StringPrintf( "Loop defined by header %d has no back edge.", id)); } else { for (size_t i = 0; i < num_back_edges; ++i) { int back_edge_id = loop_information->GetBackEdges().Get(i)->GetBlockId(); if (!loop_blocks.IsBitSet(back_edge_id)) { AddError(StringPrintf( "Loop defined by header %d has an invalid back edge %d.", id, back_edge_id)); } } } // Ensure all blocks in the loop are live and dominated by the loop header. for (uint32_t i : loop_blocks.Indexes()) { HBasicBlock* loop_block = GetGraph()->GetBlocks().Get(i); if (loop_block == nullptr) { AddError(StringPrintf("Loop defined by header %d contains a previously removed block %d.", id, i)); } else if (!loop_header->Dominates(loop_block)) { AddError(StringPrintf("Loop block %d not dominated by loop header %d.", i, id)); } } // If this is a nested loop, ensure the outer loops contain a superset of the blocks. for (HLoopInformationOutwardIterator it(*loop_header); !it.Done(); it.Advance()) { HLoopInformation* outer_info = it.Current(); if (!loop_blocks.IsSubsetOf(&outer_info->GetBlocks())) { AddError(StringPrintf("Blocks of loop defined by header %d are not a subset of blocks of " "an outer loop defined by header %d.", id, outer_info->GetHeader()->GetBlockId())); } } } void SSAChecker::VisitInstruction(HInstruction* instruction) { super_type::VisitInstruction(instruction); // Ensure an instruction dominates all its uses. for (HUseIterator<HInstruction*> use_it(instruction->GetUses()); !use_it.Done(); use_it.Advance()) { HInstruction* use = use_it.Current()->GetUser(); if (!use->IsPhi() && !instruction->StrictlyDominates(use)) { AddError(StringPrintf("Instruction %d in block %d does not dominate " "use %d in block %d.", instruction->GetId(), current_block_->GetBlockId(), use->GetId(), use->GetBlock()->GetBlockId())); } } // Ensure an instruction having an environment is dominated by the // instructions contained in the environment. for (HEnvironment* environment = instruction->GetEnvironment(); environment != nullptr; environment = environment->GetParent()) { for (size_t i = 0, e = environment->Size(); i < e; ++i) { HInstruction* env_instruction = environment->GetInstructionAt(i); if (env_instruction != nullptr && !env_instruction->StrictlyDominates(instruction)) { AddError(StringPrintf("Instruction %d in environment of instruction %d " "from block %d does not dominate instruction %d.", env_instruction->GetId(), instruction->GetId(), current_block_->GetBlockId(), instruction->GetId())); } } } } static Primitive::Type PrimitiveKind(Primitive::Type type) { switch (type) { case Primitive::kPrimBoolean: case Primitive::kPrimByte: case Primitive::kPrimShort: case Primitive::kPrimChar: case Primitive::kPrimInt: return Primitive::kPrimInt; default: return type; } } void SSAChecker::VisitPhi(HPhi* phi) { VisitInstruction(phi); // Ensure the first input of a phi is not itself. if (phi->InputAt(0) == phi) { AddError(StringPrintf("Loop phi %d in block %d is its own first input.", phi->GetId(), phi->GetBlock()->GetBlockId())); } // Ensure the number of inputs of a phi is the same as the number of // its predecessors. const GrowableArray<HBasicBlock*>& predecessors = phi->GetBlock()->GetPredecessors(); if (phi->InputCount() != predecessors.Size()) { AddError(StringPrintf( "Phi %d in block %d has %zu inputs, " "but block %d has %zu predecessors.", phi->GetId(), phi->GetBlock()->GetBlockId(), phi->InputCount(), phi->GetBlock()->GetBlockId(), predecessors.Size())); } else { // Ensure phi input at index I either comes from the Ith // predecessor or from a block that dominates this predecessor. for (size_t i = 0, e = phi->InputCount(); i < e; ++i) { HInstruction* input = phi->InputAt(i); HBasicBlock* predecessor = predecessors.Get(i); if (!(input->GetBlock() == predecessor || input->GetBlock()->Dominates(predecessor))) { AddError(StringPrintf( "Input %d at index %zu of phi %d from block %d is not defined in " "predecessor number %zu nor in a block dominating it.", input->GetId(), i, phi->GetId(), phi->GetBlock()->GetBlockId(), i)); } } } // Ensure that the inputs have the same primitive kind as the phi. for (size_t i = 0, e = phi->InputCount(); i < e; ++i) { HInstruction* input = phi->InputAt(i); if (PrimitiveKind(input->GetType()) != PrimitiveKind(phi->GetType())) { AddError(StringPrintf( "Input %d at index %zu of phi %d from block %d does not have the " "same type as the phi: %s versus %s", input->GetId(), i, phi->GetId(), phi->GetBlock()->GetBlockId(), Primitive::PrettyDescriptor(input->GetType()), Primitive::PrettyDescriptor(phi->GetType()))); } } if (phi->GetType() != HPhi::ToPhiType(phi->GetType())) { AddError(StringPrintf("Phi %d in block %d does not have an expected phi type: %s", phi->GetId(), phi->GetBlock()->GetBlockId(), Primitive::PrettyDescriptor(phi->GetType()))); } } void SSAChecker::HandleBooleanInput(HInstruction* instruction, size_t input_index) { HInstruction* input = instruction->InputAt(input_index); if (input->IsIntConstant()) { int32_t value = input->AsIntConstant()->GetValue(); if (value != 0 && value != 1) { AddError(StringPrintf( "%s instruction %d has a non-Boolean constant input %d whose value is: %d.", instruction->DebugName(), instruction->GetId(), static_cast<int>(input_index), value)); } } else if (input->GetType() == Primitive::kPrimInt && (input->IsPhi() || input->IsAnd() || input->IsOr() || input->IsXor())) { // TODO: We need a data-flow analysis to determine if the Phi or // binary operation is actually Boolean. Allow for now. } else if (input->GetType() != Primitive::kPrimBoolean) { AddError(StringPrintf( "%s instruction %d has a non-Boolean input %d whose type is: %s.", instruction->DebugName(), instruction->GetId(), static_cast<int>(input_index), Primitive::PrettyDescriptor(input->GetType()))); } } void SSAChecker::VisitIf(HIf* instruction) { VisitInstruction(instruction); HandleBooleanInput(instruction, 0); } void SSAChecker::VisitBooleanNot(HBooleanNot* instruction) { VisitInstruction(instruction); HandleBooleanInput(instruction, 0); } void SSAChecker::VisitCondition(HCondition* op) { VisitInstruction(op); if (op->GetType() != Primitive::kPrimBoolean) { AddError(StringPrintf( "Condition %s %d has a non-Boolean result type: %s.", op->DebugName(), op->GetId(), Primitive::PrettyDescriptor(op->GetType()))); } HInstruction* lhs = op->InputAt(0); HInstruction* rhs = op->InputAt(1); if (PrimitiveKind(lhs->GetType()) != PrimitiveKind(rhs->GetType())) { AddError(StringPrintf( "Condition %s %d has inputs of different types: %s, and %s.", op->DebugName(), op->GetId(), Primitive::PrettyDescriptor(lhs->GetType()), Primitive::PrettyDescriptor(rhs->GetType()))); } if (!op->IsEqual() && !op->IsNotEqual()) { if ((lhs->GetType() == Primitive::kPrimNot)) { AddError(StringPrintf( "Condition %s %d uses an object as left-hand side input.", op->DebugName(), op->GetId())); } else if (rhs->GetType() == Primitive::kPrimNot) { AddError(StringPrintf( "Condition %s %d uses an object as right-hand side input.", op->DebugName(), op->GetId())); } } } void SSAChecker::VisitBinaryOperation(HBinaryOperation* op) { VisitInstruction(op); if (op->IsUShr() || op->IsShr() || op->IsShl()) { if (PrimitiveKind(op->InputAt(1)->GetType()) != Primitive::kPrimInt) { AddError(StringPrintf( "Shift operation %s %d has a non-int kind second input: " "%s of type %s.", op->DebugName(), op->GetId(), op->InputAt(1)->DebugName(), Primitive::PrettyDescriptor(op->InputAt(1)->GetType()))); } } else { if (PrimitiveKind(op->InputAt(0)->GetType()) != PrimitiveKind(op->InputAt(1)->GetType())) { AddError(StringPrintf( "Binary operation %s %d has inputs of different types: " "%s, and %s.", op->DebugName(), op->GetId(), Primitive::PrettyDescriptor(op->InputAt(0)->GetType()), Primitive::PrettyDescriptor(op->InputAt(1)->GetType()))); } } if (op->IsCompare()) { if (op->GetType() != Primitive::kPrimInt) { AddError(StringPrintf( "Compare operation %d has a non-int result type: %s.", op->GetId(), Primitive::PrettyDescriptor(op->GetType()))); } } else { // Use the first input, so that we can also make this check for shift operations. if (PrimitiveKind(op->GetType()) != PrimitiveKind(op->InputAt(0)->GetType())) { AddError(StringPrintf( "Binary operation %s %d has a result type different " "from its input type: %s vs %s.", op->DebugName(), op->GetId(), Primitive::PrettyDescriptor(op->GetType()), Primitive::PrettyDescriptor(op->InputAt(0)->GetType()))); } } } void SSAChecker::VisitConstant(HConstant* instruction) { HBasicBlock* block = instruction->GetBlock(); if (!block->IsEntryBlock()) { AddError(StringPrintf( "%s %d should be in the entry block but is in block %d.", instruction->DebugName(), instruction->GetId(), block->GetBlockId())); } } } // namespace art
24,967
7,517
#include "BonDriver_Proxy.h" namespace BonDriver_Proxy { static BOOL IsTagMatch(const char *line, const char *tag, char **value) { const int taglen = ::strlen(tag); const char *p; if (::strncmp(line, tag, taglen) != 0) return FALSE; p = line + taglen; while (*p == ' ' || *p == '\t') p++; if (value == NULL && *p == '\0') return TRUE; if (*p++ != '=') return FALSE; while (*p == ' ' || *p == '\t') p++; *value = const_cast<char *>(p); return TRUE; } static int Init() { FILE *fp; char *p, buf[512]; Dl_info info; if (::dladdr((void *)Init, &info) == 0) return -1; ::strncpy(buf, info.dli_fname, sizeof(buf) - 8); buf[sizeof(buf) - 8] = '\0'; ::strcat(buf, ".conf"); fp = ::fopen(buf, "r"); if (fp == NULL) return -2; BOOL bHost, bPort, bBonDriver, bChannelLock, bConnectTimeOut, bUseMagicPacket; BOOL bTargetHost, bTargetPort, bTargetMac; BOOL bPacketFifoSize, bTsFifoSize, bTsPacketBufSize; bHost = bPort = bBonDriver = bChannelLock = bConnectTimeOut = bUseMagicPacket = FALSE; bTargetHost = bTargetPort = bTargetMac = FALSE; bPacketFifoSize = bTsFifoSize = bTsPacketBufSize = FALSE; while (::fgets(buf, sizeof(buf), fp)) { if (buf[0] == ';') continue; p = buf + ::strlen(buf) - 1; while ((p >= buf) && (*p == '\r' || *p == '\n')) *p-- = '\0'; if (p < buf) continue; if (!bHost && IsTagMatch(buf, "ADDRESS", &p)) { ::strncpy(g_Host, p, sizeof(g_Host) - 1); g_Host[sizeof(g_Host) - 1] = '\0'; bHost = TRUE; } else if (!bPort && IsTagMatch(buf, "PORT", &p)) { ::strncpy(g_Port, p, sizeof(g_Port) - 1); g_Port[sizeof(g_Port) - 1] = '\0'; bPort = TRUE; } else if (!bBonDriver && IsTagMatch(buf, "BONDRIVER", &p)) { ::strncpy(g_BonDriver, p, sizeof(g_BonDriver) - 1); g_BonDriver[sizeof(g_BonDriver) - 1] = '\0'; bBonDriver = TRUE; } else if (!bChannelLock && IsTagMatch(buf, "CHANNEL_LOCK", &p)) { g_ChannelLock = (BYTE)::atoi(p); bChannelLock = TRUE; } else if (!bConnectTimeOut && IsTagMatch(buf, "CONNECT_TIMEOUT", &p)) { g_ConnectTimeOut = ::atoi(p); bConnectTimeOut = TRUE; } else if (!bUseMagicPacket && IsTagMatch(buf, "USE_MAGICPACKET", &p)) { g_UseMagicPacket = ::atoi(p); bUseMagicPacket = TRUE; } else if (!bTargetHost && IsTagMatch(buf, "TARGET_ADDRESS", &p)) { ::strncpy(g_TargetHost, p, sizeof(g_TargetHost) - 1); g_TargetHost[sizeof(g_TargetHost) - 1] = '\0'; bTargetHost = TRUE; } else if (!bTargetPort && IsTagMatch(buf, "TARGET_PORT", &p)) { ::strncpy(g_TargetPort, p, sizeof(g_TargetPort) - 1); g_TargetPort[sizeof(g_TargetPort) - 1] = '\0'; bTargetPort = TRUE; } else if (!bTargetMac && IsTagMatch(buf, "TARGET_MACADDRESS", &p)) { char mac[32]; ::memset(mac, 0, sizeof(mac)); ::strncpy(mac, p, sizeof(mac) - 1); BOOL bErr = FALSE; for (int i = 0; i < 6 && !bErr; i++) { BYTE b = 0; p = &mac[i * 3]; for (int j = 0; j < 2 && !bErr; j++) { if ('0' <= *p && *p <= '9') b = b * 0x10 + (*p - '0'); else if ('A' <= *p && *p <= 'F') b = b * 0x10 + (*p - 'A' + 10); else if ('a' <= *p && *p <= 'f') b = b * 0x10 + (*p - 'a' + 10); else bErr = TRUE; p++; } g_TargetMac[i] = b; } if (!bErr) bTargetMac = TRUE; } else if (!bPacketFifoSize && IsTagMatch(buf, "PACKET_FIFO_SIZE", &p)) { g_PacketFifoSize = ::atoi(p); bPacketFifoSize = TRUE; } else if (!bTsFifoSize && IsTagMatch(buf, "TS_FIFO_SIZE", &p)) { g_TsFifoSize = ::atoi(p); bTsFifoSize = TRUE; } else if (!bTsPacketBufSize && IsTagMatch(buf, "TSPACKET_BUFSIZE", &p)) { g_TsPacketBufSize = ::atoi(p); bTsPacketBufSize = TRUE; } } ::fclose(fp); if (!bHost || !bPort || !bBonDriver) return -3; if (g_UseMagicPacket) { if (!bTargetMac) return -4; if (!bTargetHost) ::strcpy(g_TargetHost, g_Host); if (!bTargetPort) ::strcpy(g_TargetPort, g_Port); } return 0; } cProxyClient::cProxyClient() : m_Error(m_c, m_m), m_SingleShot(m_c, m_m), m_fifoSend(m_c, m_m), m_fifoRecv(m_c, m_m), m_fifoTS(m_c, m_m) { m_s = INVALID_SOCKET; m_LastBuf = NULL; m_dwBufPos = 0; ::memset(m_pBuf, 0, sizeof(m_pBuf)); m_bBonDriver = m_bTuner = m_bRereased = m_bWaitCNR = FALSE; m_fSignalLevel = 0; m_dwSpace = m_dwChannel = 0x7fffffff; // INT_MAX m_hThread = 0; // m_iEndCount = -1; size_t n = 0; char *p = (char *)TUNER_NAME; for (;;) { m_TunerName[n++] = *p; m_TunerName[n++] = '\0'; if ((*p++ == '\0') || (n > (sizeof(m_TunerName) - 2))) break; } m_TunerName[sizeof(m_TunerName) - 2] = '\0'; m_TunerName[sizeof(m_TunerName) - 1] = '\0'; pthread_mutexattr_t attr; ::pthread_mutexattr_init(&attr); ::pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); ::pthread_mutex_init(&m_m, &attr); ::pthread_cond_init(&m_c, NULL); m_SingleShot.SetAutoReset(TRUE); int i; for (i = 0; i < ebResNum; i++) { m_bResEvent[i] = new cEvent(m_c, m_m); m_bResEvent[i]->SetAutoReset(TRUE); } for (i = 0; i < edwResNum; i++) { m_dwResEvent[i] = new cEvent(m_c, m_m); m_dwResEvent[i]->SetAutoReset(TRUE); } for (i = 0; i < epResNum; i++) { m_pResEvent[i] = new cEvent(m_c, m_m); m_pResEvent[i]->SetAutoReset(TRUE); } } cProxyClient::~cProxyClient() { if (!m_bRereased) { if (m_bTuner) CloseTuner(); makePacket(eRelease); } m_Error.Set(); // if (m_iEndCount != -1) // SleepLock(3); if (m_hThread != 0) ::pthread_join(m_hThread, NULL); int i; { LOCK(m_writeLock); for (i = 0; i < 8; i++) delete[] m_pBuf[i]; TsFlush(); delete m_LastBuf; } for (i = 0; i < ebResNum; i++) delete m_bResEvent[i]; for (i = 0; i < edwResNum; i++) delete m_dwResEvent[i]; for (i = 0; i < epResNum; i++) delete m_pResEvent[i]; ::pthread_cond_destroy(&m_c); ::pthread_mutex_destroy(&m_m); if (m_s != INVALID_SOCKET) ::close(m_s); } void *cProxyClient::ProcessEntry(LPVOID pv) { cProxyClient *pProxy = static_cast<cProxyClient *>(pv); DWORD &ret = pProxy->m_tRet; ret = pProxy->Process(); // pProxy->m_iEndCount++; return &ret; } DWORD cProxyClient::Process() { pthread_t hThread[2]; if (::pthread_create(&hThread[0], NULL, cProxyClient::Sender, this)) { m_Error.Set(); return 1; } if (::pthread_create(&hThread[1], NULL, cProxyClient::Receiver, this)) { m_Error.Set(); ::pthread_join(hThread[0], NULL); return 2; } // m_iEndCount = 0; m_SingleShot.Set(); cEvent *h[2] = { &m_Error, m_fifoRecv.GetEventHandle() }; for (;;) { DWORD dwRet = cEvent::MultipleWait(2, h); switch (dwRet) { case WAIT_OBJECT_0: goto end; case WAIT_OBJECT_0 + 1: { int idx; cPacketHolder *pPh = NULL; m_fifoRecv.Pop(&pPh); switch (pPh->GetCommand()) { case eSelectBonDriver: idx = ebResSelectBonDriver; goto bres; case eCreateBonDriver: idx = ebResCreateBonDriver; goto bres; case eOpenTuner: idx = ebResOpenTuner; goto bres; case ePurgeTsStream: idx = ebResPurgeTsStream; goto bres; case eSetLnbPower: idx = ebResSetLnbPower; bres: { LOCK(m_readLock); if (pPh->GetBodyLength() != sizeof(BYTE)) m_bRes[idx] = FALSE; else m_bRes[idx] = pPh->m_pPacket->payload[0]; m_bResEvent[idx]->Set(); break; } case eGetTsStream: if (pPh->GetBodyLength() >= (sizeof(DWORD) * 2)) { DWORD *pdw = (DWORD *)(pPh->m_pPacket->payload); DWORD dwSize = ntohl(*pdw); // 変なパケットは廃棄(正規のサーバに繋いでいる場合は来る事はないハズ) if ((pPh->GetBodyLength() - (sizeof(DWORD) * 2)) == dwSize) { union { DWORD dw; float f; } u; pdw = (DWORD *)(&(pPh->m_pPacket->payload[sizeof(DWORD)])); u.dw = ntohl(*pdw); m_fSignalLevel = u.f; m_bWaitCNR = FALSE; pPh->SetDeleteFlag(FALSE); TS_DATA *pData = new TS_DATA(); pData->dwSize = dwSize; pData->pbBufHead = pPh->m_pBuf; pData->pbBuf = &(pPh->m_pPacket->payload[sizeof(DWORD) * 2]); m_fifoTS.Push(pData); } } break; case eEnumTuningSpace: idx = epResEnumTuningSpace; goto pres; case eEnumChannelName: idx = epResEnumChannelName; pres: { LOCK(m_writeLock); if (m_dwBufPos >= 8) m_dwBufPos = 0; if (m_pBuf[m_dwBufPos]) delete[] m_pBuf[m_dwBufPos]; if (pPh->GetBodyLength() == sizeof(TCHAR)) m_pBuf[m_dwBufPos] = NULL; else { DWORD dw = pPh->GetBodyLength(); m_pBuf[m_dwBufPos] = (TCHAR *)(new BYTE[dw]); ::memcpy(m_pBuf[m_dwBufPos], pPh->m_pPacket->payload, dw); } { LOCK(m_readLock); m_pRes[idx] = m_pBuf[m_dwBufPos++]; m_pResEvent[idx]->Set(); } break; } case eSetChannel2: idx = edwResSetChannel2; goto dwres; case eGetTotalDeviceNum: idx = edwResGetTotalDeviceNum; goto dwres; case eGetActiveDeviceNum: idx = edwResGetActiveDeviceNum; dwres: { LOCK(m_readLock); if (pPh->GetBodyLength() != sizeof(DWORD)) m_dwRes[idx] = 0; else { DWORD *pdw = (DWORD *)(pPh->m_pPacket->payload); m_dwRes[idx] = ntohl(*pdw); } m_dwResEvent[idx]->Set(); break; } default: break; } delete pPh; break; } default: // 何かのエラー m_Error.Set(); goto end; } } end: // SleepLock(2); ::pthread_join(hThread[0], NULL); ::pthread_join(hThread[1], NULL); return 0; } int cProxyClient::ReceiverHelper(char *pDst, DWORD left) { int len, ret; fd_set rd; timeval tv; while (left > 0) { if (m_Error.IsSet()) return -1; FD_ZERO(&rd); FD_SET(m_s, &rd); tv.tv_sec = 1; tv.tv_usec = 0; if ((len = ::select((int)(m_s + 1), &rd, NULL, NULL, &tv)) == SOCKET_ERROR) { ret = -2; goto err; } if (len == 0) continue; if ((len = ::recv(m_s, pDst, left, 0)) <= 0) { ret = -3; goto err; } left -= len; pDst += len; } return 0; err: m_Error.Set(); return ret; } void *cProxyClient::Receiver(LPVOID pv) { cProxyClient *pProxy = static_cast<cProxyClient *>(pv); DWORD left, &ret = pProxy->m_tRet; char *p; cPacketHolder *pPh = NULL; const DWORD MaxPacketBufSize = g_TsPacketBufSize + (sizeof(DWORD) * 2); for (;;) { pPh = new cPacketHolder(MaxPacketBufSize); left = sizeof(stPacketHead); p = (char *)&(pPh->m_pPacket->head); if (pProxy->ReceiverHelper(p, left) != 0) { ret = 201; goto end; } if (!pPh->IsValid()) { pProxy->m_Error.Set(); ret = 202; goto end; } left = pPh->GetBodyLength(); if (left == 0) { pProxy->m_fifoRecv.Push(pPh); continue; } if (left > MaxPacketBufSize) { pProxy->m_Error.Set(); ret = 203; goto end; } p = (char *)(pPh->m_pPacket->payload); if (pProxy->ReceiverHelper(p, left) != 0) { ret = 204; goto end; } pProxy->m_fifoRecv.Push(pPh); } end: delete pPh; // pProxy->m_iEndCount++; return &ret; } void cProxyClient::makePacket(enumCommand eCmd) { cPacketHolder *p = new cPacketHolder(eCmd, 0); m_fifoSend.Push(p); } void cProxyClient::makePacket(enumCommand eCmd, LPCSTR str) { register size_t size = (::strlen(str) + 1); cPacketHolder *p = new cPacketHolder(eCmd, size); ::memcpy(p->m_pPacket->payload, str, size); m_fifoSend.Push(p); } void cProxyClient::makePacket(enumCommand eCmd, BOOL b) { cPacketHolder *p = new cPacketHolder(eCmd, sizeof(BYTE)); p->m_pPacket->payload[0] = (BYTE)b; m_fifoSend.Push(p); } void cProxyClient::makePacket(enumCommand eCmd, DWORD dw) { cPacketHolder *p = new cPacketHolder(eCmd, sizeof(DWORD)); DWORD *pos = (DWORD *)(p->m_pPacket->payload); *pos = htonl(dw); m_fifoSend.Push(p); } void cProxyClient::makePacket(enumCommand eCmd, DWORD dw1, DWORD dw2) { cPacketHolder *p = new cPacketHolder(eCmd, sizeof(DWORD) * 2); DWORD *pos = (DWORD *)(p->m_pPacket->payload); *pos++ = htonl(dw1); *pos = htonl(dw2); m_fifoSend.Push(p); } void cProxyClient::makePacket(enumCommand eCmd, DWORD dw1, DWORD dw2, BYTE b) { cPacketHolder *p = new cPacketHolder(eCmd, (sizeof(DWORD) * 2) + sizeof(BYTE)); DWORD *pos = (DWORD *)(p->m_pPacket->payload); *pos++ = htonl(dw1); *pos++ = htonl(dw2); *(BYTE *)pos = b; m_fifoSend.Push(p); } void *cProxyClient::Sender(LPVOID pv) { cProxyClient *pProxy = static_cast<cProxyClient *>(pv); DWORD &ret = pProxy->m_tRet; cEvent *h[2] = { &(pProxy->m_Error), pProxy->m_fifoSend.GetEventHandle() }; for (;;) { DWORD dwRet = cEvent::MultipleWait(2, h); switch (dwRet) { case WAIT_OBJECT_0: ret = 101; goto end; case WAIT_OBJECT_0 + 1: { cPacketHolder *pPh = NULL; pProxy->m_fifoSend.Pop(&pPh); int left = (int)pPh->m_Size; char *p = (char *)(pPh->m_pPacket); while (left > 0) { int len = ::send(pProxy->m_s, p, left, 0); if (len == SOCKET_ERROR) { pProxy->m_Error.Set(); break; } left -= len; p += len; } delete pPh; break; } default: // 何かのエラー pProxy->m_Error.Set(); ret = 102; goto end; } } end: // pProxy->m_iEndCount++; return &ret; } BOOL cProxyClient::SelectBonDriver() { { LOCK(g_Lock); makePacket(eSelectBonDriver, g_BonDriver); } if (m_bResEvent[ebResSelectBonDriver]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); return m_bRes[ebResSelectBonDriver]; } return FALSE; } BOOL cProxyClient::CreateBonDriver() { makePacket(eCreateBonDriver); if (m_bResEvent[ebResCreateBonDriver]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); if (m_bRes[ebResCreateBonDriver]) m_bBonDriver = TRUE; return m_bRes[ebResCreateBonDriver]; } return FALSE; } const BOOL cProxyClient::OpenTuner(void) { if (!m_bBonDriver) return FALSE; makePacket(eOpenTuner); if (m_bResEvent[ebResOpenTuner]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); if (m_bRes[ebResOpenTuner]) m_bTuner = TRUE; return m_bRes[ebResOpenTuner]; } return FALSE; } void cProxyClient::CloseTuner(void) { if (!m_bTuner) return; makePacket(eCloseTuner); m_bTuner = m_bWaitCNR = FALSE; m_fSignalLevel = 0; m_dwSpace = m_dwChannel = 0x7fffffff; // INT_MAX { LOCK(m_writeLock); m_dwBufPos = 0; for (int i = 0; i < 8; i++) delete[] m_pBuf[i]; ::memset(m_pBuf, 0, sizeof(m_pBuf)); } } const BOOL cProxyClient::SetChannel(const BYTE bCh) { return TRUE; } const float cProxyClient::GetSignalLevel(void) { // イベントでやろうかと思ったけど、デッドロックを防ぐ為には発生する処理の回数の内大半では // 全く無駄なイベント処理が発生する事になるので、ポーリングでやる事にした // なお、絶妙なタイミングでのネットワーク切断等に備えて、最大でも約0.5秒までしか待たない timespec ts; ts.tv_sec = 0; ts.tv_nsec = 10 * 1000 * 1000; for (int i = 0; m_bWaitCNR && (i < 50); i++) ::nanosleep(&ts, NULL); return m_fSignalLevel; } const DWORD cProxyClient::WaitTsStream(const DWORD dwTimeOut) { if (!m_bTuner) return WAIT_ABANDONED; if (m_fifoTS.Size() != 0) return WAIT_OBJECT_0; else return WAIT_TIMEOUT; // 手抜き } const DWORD cProxyClient::GetReadyCount(void) { if (!m_bTuner) return 0; return (DWORD)m_fifoTS.Size(); } const BOOL cProxyClient::GetTsStream(BYTE *pDst, DWORD *pdwSize, DWORD *pdwRemain) { if (!m_bTuner) return FALSE; BYTE *pSrc; if (GetTsStream(&pSrc, pdwSize, pdwRemain)) { if (*pdwSize) ::memcpy(pDst, pSrc, *pdwSize); return TRUE; } return FALSE; } const BOOL cProxyClient::GetTsStream(BYTE **ppDst, DWORD *pdwSize, DWORD *pdwRemain) { if (!m_bTuner) return FALSE; BOOL b; { LOCK(m_writeLock); if (m_fifoTS.Size() != 0) { delete m_LastBuf; m_fifoTS.Pop(&m_LastBuf); *ppDst = m_LastBuf->pbBuf; *pdwSize = m_LastBuf->dwSize; *pdwRemain = (DWORD)m_fifoTS.Size(); b = TRUE; } else { *pdwSize = 0; *pdwRemain = 0; b = FALSE; } } return b; } void cProxyClient::PurgeTsStream(void) { if (!m_bTuner) return; makePacket(ePurgeTsStream); if (m_bResEvent[ebResPurgeTsStream]->Wait(&m_Error) != WAIT_OBJECT_0) { BOOL b; { LOCK(m_readLock); b = m_bRes[ebResPurgeTsStream]; } if (b) { LOCK(m_writeLock); TsFlush(); } } } void cProxyClient::Release(void) { if (m_bTuner) CloseTuner(); makePacket(eRelease); m_bRereased = TRUE; { LOCK(g_Lock); g_InstanceList.remove(this); } delete this; } LPCTSTR cProxyClient::GetTunerName(void) { return (LPCTSTR)m_TunerName; } const BOOL cProxyClient::IsTunerOpening(void) { return FALSE; } LPCTSTR cProxyClient::EnumTuningSpace(const DWORD dwSpace) { if (!m_bTuner) return NULL; makePacket(eEnumTuningSpace, dwSpace); if (m_pResEvent[epResEnumTuningSpace]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); return m_pRes[epResEnumTuningSpace]; } return NULL; } LPCTSTR cProxyClient::EnumChannelName(const DWORD dwSpace, const DWORD dwChannel) { if (!m_bTuner) return NULL; makePacket(eEnumChannelName, dwSpace, dwChannel); if (m_pResEvent[epResEnumChannelName]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); return m_pRes[epResEnumChannelName]; } return NULL; } const BOOL cProxyClient::SetChannel(const DWORD dwSpace, const DWORD dwChannel) { if (!m_bTuner) goto err; // if ((m_dwSpace == dwSpace) && (m_dwChannel == dwChannel)) // return TRUE; makePacket(eSetChannel2, dwSpace, dwChannel, g_ChannelLock); DWORD dw; if (m_dwResEvent[edwResSetChannel2]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); dw = m_dwRes[edwResSetChannel2]; } else dw = 0xff; switch (dw) { case 0x00: // 成功 { LOCK(m_writeLock); TsFlush(); m_dwSpace = dwSpace; m_dwChannel = dwChannel; m_fSignalLevel = 0; m_bWaitCNR = TRUE; } case 0x01: // fall-through / チャンネルロックされてる return TRUE; default: break; } err: m_fSignalLevel = 0; return FALSE; } const DWORD cProxyClient::GetCurSpace(void) { return m_dwSpace; } const DWORD cProxyClient::GetCurChannel(void) { return m_dwChannel; } const DWORD cProxyClient::GetTotalDeviceNum(void) { if (!m_bTuner) return 0; makePacket(eGetTotalDeviceNum); if (m_dwResEvent[edwResGetTotalDeviceNum]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); return m_dwRes[edwResGetTotalDeviceNum]; } return 0; } const DWORD cProxyClient::GetActiveDeviceNum(void) { if (!m_bTuner) return 0; makePacket(eGetActiveDeviceNum); if (m_dwResEvent[edwResGetActiveDeviceNum]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); return m_dwRes[edwResGetActiveDeviceNum]; } return 0; } const BOOL cProxyClient::SetLnbPower(const BOOL bEnable) { if (!m_bTuner) return FALSE; makePacket(eSetLnbPower, bEnable); if (m_bResEvent[ebResSetLnbPower]->Wait(&m_Error) != WAIT_OBJECT_0) { LOCK(m_readLock); return m_bRes[ebResSetLnbPower]; } return FALSE; } static SOCKET Connect(char *host, char *port) { addrinfo hints, *results, *rp; SOCKET sock; int i, bf; fd_set wd; timeval tv; ::memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; if (g_UseMagicPacket) { char sendbuf[128]; ::memset(sendbuf, 0xff, 6); for (i = 1; i <= 16; i++) ::memcpy(&sendbuf[i * 6], g_TargetMac, 6); hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; hints.ai_flags = AI_NUMERICHOST; if (::getaddrinfo(g_TargetHost, g_TargetPort, &hints, &results) != 0) { hints.ai_flags = 0; if (::getaddrinfo(g_TargetHost, g_TargetPort, &hints, &results) != 0) return INVALID_SOCKET; } for (rp = results; rp != NULL; rp = rp->ai_next) { sock = ::socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sock == INVALID_SOCKET) continue; BOOL opt = TRUE; if (::setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (const char *)&opt, sizeof(opt)) != 0) { ::close(sock); continue; } int ret = ::sendto(sock, sendbuf, 102, 0, rp->ai_addr, (int)(rp->ai_addrlen)); ::close(sock); if (ret == 102) break; } ::freeaddrinfo(results); if (rp == NULL) return INVALID_SOCKET; } hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = AI_NUMERICHOST; if (::getaddrinfo(host, port, &hints, &results) != 0) { hints.ai_flags = 0; if (::getaddrinfo(host, port, &hints, &results) != 0) return INVALID_SOCKET; } for (rp = results; rp != NULL; rp = rp->ai_next) { sock = ::socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sock == INVALID_SOCKET) continue; bf = TRUE; ::ioctl(sock, FIONBIO, &bf); tv.tv_sec = g_ConnectTimeOut; tv.tv_usec = 0; FD_ZERO(&wd); FD_SET(sock, &wd); ::connect(sock, rp->ai_addr, (int)(rp->ai_addrlen)); if ((i = ::select((int)(sock + 1), 0, &wd, 0, &tv)) != SOCKET_ERROR) { // タイムアウト時間が"全体の"ではなく"個々のソケットの"になるけど、とりあえずこれで if (i != 0) { bf = FALSE; ::ioctl(sock, FIONBIO, &bf); break; } } ::close(sock); } ::freeaddrinfo(results); if (rp == NULL) return INVALID_SOCKET; return sock; } extern "C" IBonDriver *CreateBonDriver() { if (Init() != 0) return NULL; SOCKET s = Connect(g_Host, g_Port); if (s == INVALID_SOCKET) return NULL; cProxyClient *pProxy = new cProxyClient(); pProxy->setSocket(s); pthread_t ht; if (::pthread_create(&ht, NULL, cProxyClient::ProcessEntry, pProxy)) goto err; pProxy->setThreadHandle(ht); if (pProxy->WaitSingleShot() == WAIT_OBJECT_0) goto err; if (!pProxy->SelectBonDriver()) goto err; if (pProxy->CreateBonDriver()) { LOCK(g_Lock); g_InstanceList.push_back(pProxy); return pProxy; } err: delete pProxy; return NULL; } extern "C" BOOL SetBonDriver(LPCSTR p) { LOCK(g_Lock); if (::strlen(p) >= sizeof(g_BonDriver)) return FALSE; ::strcpy(g_BonDriver, p); return TRUE; } }
21,386
10,978
#include <cstdio> #include <cstdlib> #include <cerrno> #include <cstring> #define FLOAT32 "%.9g" struct atlas_ent { int bin_id, font_id, glyph; short x, y, ox, oy, w, h; }; int main(int argc, char **argv) { FILE *in = nullptr; if (argc != 2) { fprintf(stderr, "usage: %s <filename>\n", argv[0]); exit(1); } if (!(in = fopen(argv[1], "r"))) { fprintf(stderr, "error: fopen: %s, %s\n", argv[1], strerror(errno)); exit(1); } const int num_fields = 9; int ret; do { atlas_ent ent; ret = fscanf(in, "%d,%d,%d,%hd,%hd,%hd,%hd,%hd,%hd\n", &ent.bin_id, &ent.font_id, &ent.glyph, &ent.x, &ent.y, &ent.ox, &ent.oy, &ent.w, &ent.h); if (ret == num_fields) { printf("%d,%d,%d,%d,%d,%d,%d,%d,%d\n", ent.bin_id, ent.font_id, ent.glyph, ent.x, ent.y, ent.ox, ent.oy, ent.w, ent.h); } } while (ret == num_fields); fclose(in); }
999
434