hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
108
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
724f398fa14240dc814292ba0df5538bc14020f5
638
cpp
C++
Week_3/02 Programming Assignment/Example.cpp
Animart/basics-of-c-plus-plus-development-white-belt
9ad0aec57a54e505955ad4a93a0636903ba92822
[ "Unlicense" ]
1
2018-11-22T17:33:45.000Z
2018-11-22T17:33:45.000Z
Week_3/02 Programming Assignment/Example.cpp
Animart/basics-of-c-plus-plus-development-white-belt
9ad0aec57a54e505955ad4a93a0636903ba92822
[ "Unlicense" ]
null
null
null
Week_3/02 Programming Assignment/Example.cpp
Animart/basics-of-c-plus-plus-development-white-belt
9ad0aec57a54e505955ad4a93a0636903ba92822
[ "Unlicense" ]
1
2021-03-09T05:26:37.000Z
2021-03-09T05:26:37.000Z
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; void PrintVector(const vector<string>& v) { for (const auto i : v) { cout << i << " "; } } string Transform(string& s) { string temp = ""; for (int i = 0; i < s.size(); ++i) { temp += tolower(s[i]); } return temp; } bool Compare(string i, string j) { return Transform(i) < Transform(j); } int main() { int n; cin >> n; vector<string> v(n); for (string& w : v) { cin >> w; } sort(begin(v), end(v), Compare); PrintVector(v); return 0; }
13.869565
42
0.518809
Animart
7251e9c9b6bde9f5987953ad532a5bbd4bdb7e1e
77,592
cpp
C++
sdk/cpp/core/src/network_topology.cpp
YDK-Solutions/ydk
7ab961284cdc82de8828e53fa4870d3204d7730e
[ "ECL-2.0", "Apache-2.0" ]
125
2016-03-15T17:04:13.000Z
2022-03-22T02:46:17.000Z
sdk/cpp/core/src/network_topology.cpp
YDK-Solutions/ydk
7ab961284cdc82de8828e53fa4870d3204d7730e
[ "ECL-2.0", "Apache-2.0" ]
818
2016-03-17T17:06:00.000Z
2022-03-28T03:56:17.000Z
sdk/cpp/core/src/network_topology.cpp
YDK-Solutions/ydk
7ab961284cdc82de8828e53fa4870d3204d7730e
[ "ECL-2.0", "Apache-2.0" ]
93
2016-03-15T19:18:55.000Z
2022-02-24T13:55:07.000Z
#include <sstream> #include <iostream> #include "entity_util.hpp" #include "network_topology.hpp" using namespace ydk; namespace opendaylight { namespace network_topology { NetworkTopology::NetworkTopology() { yang_name = "network-topology"; yang_parent_name = "network-topology"; } NetworkTopology::~NetworkTopology() { } bool NetworkTopology::has_data() const { for (std::size_t index=0; index<topology.size(); index++) { if(topology[index]->has_data()) return true; } return false; } bool NetworkTopology::has_operation() const { for (std::size_t index=0; index<topology.size(); index++) { if(topology[index]->has_operation()) return true; } return is_set(yfilter); } std::string NetworkTopology::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "network-topology:network-topology"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::get_name_leaf_data() const { return {}; } std::shared_ptr<Entity> NetworkTopology::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "topology") { for(auto const & c : topology) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology>(); c->parent = this; topology.push_back(c); return c; } return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; for (auto const & c : topology) { children[c->get_segment_path()] = c; } return children; } void NetworkTopology::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkTopology::set_filter(const std::string & value_path, YFilter yfilter) { } std::shared_ptr<Entity> NetworkTopology::clone_ptr() const { return std::make_shared<NetworkTopology>(); } bool NetworkTopology::has_leaf_or_child_of_name(const std::string & name) const { if(name == "topology") return true; return false; } NetworkTopology::Topology::Topology() : topology_id{YType::str, "topology-id"}, server_provided{YType::boolean, "server-provided"} , topology_types(std::make_shared<NetworkTopology::Topology::TopologyTypes>()) { topology_types->parent = this; yang_name = "topology"; yang_parent_name = "network-topology"; } NetworkTopology::Topology::~Topology() { } bool NetworkTopology::Topology::has_data() const { for (std::size_t index=0; index<link.size(); index++) { if(link[index]->has_data()) return true; } for (std::size_t index=0; index<node.size(); index++) { if(node[index]->has_data()) return true; } for (std::size_t index=0; index<underlay_topology.size(); index++) { if(underlay_topology[index]->has_data()) return true; } return topology_id.is_set || server_provided.is_set || (topology_types != nullptr && topology_types->has_data()); } bool NetworkTopology::Topology::has_operation() const { for (std::size_t index=0; index<link.size(); index++) { if(link[index]->has_operation()) return true; } for (std::size_t index=0; index<node.size(); index++) { if(node[index]->has_operation()) return true; } for (std::size_t index=0; index<underlay_topology.size(); index++) { if(underlay_topology[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(topology_id.yfilter) || ydk::is_set(server_provided.yfilter) || (topology_types != nullptr && topology_types->has_operation()); } std::string NetworkTopology::Topology::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "topology" <<"[topology-id='" <<topology_id <<"']"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (topology_id.is_set || is_set(topology_id.yfilter)) leaf_name_data.push_back(topology_id.get_name_leafdata()); if (server_provided.is_set || is_set(server_provided.yfilter)) leaf_name_data.push_back(server_provided.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "link") { for(auto const & c : link) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::Link>(); c->parent = this; link.push_back(c); return c; } if(child_yang_name == "node") { for(auto const & c : node) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::Node>(); c->parent = this; node.push_back(c); return c; } if(child_yang_name == "topology-types") { if(topology_types == nullptr) { topology_types = std::make_shared<NetworkTopology::Topology::TopologyTypes>(); } return topology_types; } if(child_yang_name == "underlay-topology") { for(auto const & c : underlay_topology) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::UnderlayTopology>(); c->parent = this; underlay_topology.push_back(c); return c; } return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; for (auto const & c : link) { children[c->get_segment_path()] = c; } for (auto const & c : node) { children[c->get_segment_path()] = c; } if(topology_types != nullptr) { children["topology-types"] = topology_types; } for (auto const & c : underlay_topology) { children[c->get_segment_path()] = c; } return children; } void NetworkTopology::Topology::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "topology-id") { topology_id = value; topology_id.value_namespace = name_space; topology_id.value_namespace_prefix = name_space_prefix; } if(value_path == "server-provided") { server_provided = value; server_provided.value_namespace = name_space; server_provided.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "topology-id") { topology_id.yfilter = yfilter; } if(value_path == "server-provided") { server_provided.yfilter = yfilter; } } bool NetworkTopology::Topology::has_leaf_or_child_of_name(const std::string & name) const { if(name == "link" || name == "node" || name == "topology-types" || name == "underlay-topology" || name == "topology-id" || name == "server-provided") return true; return false; } NetworkTopology::Topology::TopologyTypes::TopologyTypes() : topology_netconf(std::make_shared<NetworkTopology::Topology::TopologyTypes::TopologyNetconf>()) { topology_netconf->parent = this; yang_name = "topology-types"; yang_parent_name = "topology"; } NetworkTopology::Topology::TopologyTypes::~TopologyTypes() { } bool NetworkTopology::Topology::TopologyTypes::has_data() const { return (topology_netconf != nullptr && topology_netconf->has_data()); } bool NetworkTopology::Topology::TopologyTypes::has_operation() const { return is_set(yfilter) || (topology_netconf != nullptr && topology_netconf->has_operation()); } std::string NetworkTopology::Topology::TopologyTypes::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "topology-types"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::TopologyTypes::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data;; } std::shared_ptr<Entity> NetworkTopology::Topology::TopologyTypes::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "topology-netconf") { if(topology_netconf == nullptr) { topology_netconf = std::make_shared<NetworkTopology::Topology::TopologyTypes::TopologyNetconf>(); } return topology_netconf; } return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::TopologyTypes::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; if(topology_netconf != nullptr) { children["topology-netconf"] = topology_netconf; } return children; } void NetworkTopology::Topology::TopologyTypes::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkTopology::Topology::TopologyTypes::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkTopology::Topology::TopologyTypes::has_leaf_or_child_of_name(const std::string & name) const { if(name == "topology-netconf") return true; return false; } NetworkTopology::Topology::TopologyTypes::TopologyNetconf::TopologyNetconf() { yang_name = "topology-netconf"; yang_parent_name = "topology-types"; } NetworkTopology::Topology::TopologyTypes::TopologyNetconf::~TopologyNetconf() { } bool NetworkTopology::Topology::TopologyTypes::TopologyNetconf::has_data() const { return false; } bool NetworkTopology::Topology::TopologyTypes::TopologyNetconf::has_operation() const { return is_set(yfilter); } std::string NetworkTopology::Topology::TopologyTypes::TopologyNetconf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "netconf-node-topology:topology-netconf"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::TopologyTypes::TopologyNetconf::get_name_leaf_data() const { return {}; } std::shared_ptr<Entity> NetworkTopology::Topology::TopologyTypes::TopologyNetconf::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::TopologyTypes::TopologyNetconf::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::TopologyTypes::TopologyNetconf::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkTopology::Topology::TopologyTypes::TopologyNetconf::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkTopology::Topology::TopologyTypes::TopologyNetconf::has_leaf_or_child_of_name(const std::string & name) const { return false; } NetworkTopology::Topology::UnderlayTopology::UnderlayTopology() : topology_ref{YType::str, "topology-ref"} { yang_name = "underlay-topology"; yang_parent_name = "topology"; } NetworkTopology::Topology::UnderlayTopology::~UnderlayTopology() { } bool NetworkTopology::Topology::UnderlayTopology::has_data() const { return topology_ref.is_set; } bool NetworkTopology::Topology::UnderlayTopology::has_operation() const { return is_set(yfilter) || ydk::is_set(topology_ref.yfilter); } std::string NetworkTopology::Topology::UnderlayTopology::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "underlay-topology" <<"[topology-ref='" <<topology_ref <<"']"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::UnderlayTopology::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (topology_ref.is_set || is_set(topology_ref.yfilter)) leaf_name_data.push_back(topology_ref.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::UnderlayTopology::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::UnderlayTopology::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::UnderlayTopology::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "topology-ref") { topology_ref = value; topology_ref.value_namespace = name_space; topology_ref.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::UnderlayTopology::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "topology-ref") { topology_ref.yfilter = yfilter; } } bool NetworkTopology::Topology::UnderlayTopology::has_leaf_or_child_of_name(const std::string & name) const { if(name == "topology-ref") return true; return false; } NetworkTopology::Topology::Node::Node() : node_id{YType::str, "node-id"}, between_attempts_timeout_millis{YType::uint16, "netconf-node-topology:between-attempts-timeout-millis"}, concurrent_rpc_limit{YType::uint16, "netconf-node-topology:concurrent-rpc-limit"}, connected_message{YType::str, "netconf-node-topology:connected-message"}, connection_status{YType::enumeration, "netconf-node-topology:connection-status"}, connection_timeout_millis{YType::uint32, "netconf-node-topology:connection-timeout-millis"}, default_request_timeout_millis{YType::uint32, "netconf-node-topology:default-request-timeout-millis"}, host{YType::str, "netconf-node-topology:host"}, keepalive_delay{YType::uint32, "netconf-node-topology:keepalive-delay"}, max_connection_attempts{YType::uint32, "netconf-node-topology:max-connection-attempts"}, password{YType::str, "netconf-node-topology:password"}, port{YType::uint16, "netconf-node-topology:port"}, reconnect_on_changed_schema{YType::boolean, "netconf-node-topology:reconnect-on-changed-schema"}, schema_cache_directory{YType::str, "netconf-node-topology:schema-cache-directory"}, schemaless{YType::boolean, "netconf-node-topology:schemaless"}, sleep_factor{YType::str, "netconf-node-topology:sleep-factor"}, tcp_only{YType::boolean, "netconf-node-topology:tcp-only"}, username{YType::str, "netconf-node-topology:username"} , available_capabilities(std::make_shared<NetworkTopology::Topology::Node::AvailableCapabilities>()) ,clustered_connection_status(std::make_shared<NetworkTopology::Topology::Node::ClusteredConnectionStatus>()) ,pass_through(std::make_shared<NetworkTopology::Topology::Node::PassThrough>()) ,unavailable_capabilities(std::make_shared<NetworkTopology::Topology::Node::UnavailableCapabilities>()) ,yang_library(std::make_shared<NetworkTopology::Topology::Node::YangLibrary>()) ,yang_module_capabilities(std::make_shared<NetworkTopology::Topology::Node::YangModuleCapabilities>()) { available_capabilities->parent = this; clustered_connection_status->parent = this; pass_through->parent = this; unavailable_capabilities->parent = this; yang_library->parent = this; yang_module_capabilities->parent = this; yang_name = "node"; yang_parent_name = "topology"; } NetworkTopology::Topology::Node::~Node() { } bool NetworkTopology::Topology::Node::has_data() const { for (std::size_t index=0; index<supporting_node.size(); index++) { if(supporting_node[index]->has_data()) return true; } for (std::size_t index=0; index<termination_point.size(); index++) { if(termination_point[index]->has_data()) return true; } return node_id.is_set || between_attempts_timeout_millis.is_set || concurrent_rpc_limit.is_set || connected_message.is_set || connection_status.is_set || connection_timeout_millis.is_set || default_request_timeout_millis.is_set || host.is_set || keepalive_delay.is_set || max_connection_attempts.is_set || password.is_set || port.is_set || reconnect_on_changed_schema.is_set || schema_cache_directory.is_set || schemaless.is_set || sleep_factor.is_set || tcp_only.is_set || username.is_set || (available_capabilities != nullptr && available_capabilities->has_data()) || (clustered_connection_status != nullptr && clustered_connection_status->has_data()) || (pass_through != nullptr && pass_through->has_data()) || (unavailable_capabilities != nullptr && unavailable_capabilities->has_data()) || (yang_library != nullptr && yang_library->has_data()) || (yang_module_capabilities != nullptr && yang_module_capabilities->has_data()); } bool NetworkTopology::Topology::Node::has_operation() const { for (std::size_t index=0; index<supporting_node.size(); index++) { if(supporting_node[index]->has_operation()) return true; } for (std::size_t index=0; index<termination_point.size(); index++) { if(termination_point[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(node_id.yfilter) || ydk::is_set(between_attempts_timeout_millis.yfilter) || ydk::is_set(concurrent_rpc_limit.yfilter) || ydk::is_set(connected_message.yfilter) || ydk::is_set(connection_status.yfilter) || ydk::is_set(connection_timeout_millis.yfilter) || ydk::is_set(default_request_timeout_millis.yfilter) || ydk::is_set(host.yfilter) || ydk::is_set(keepalive_delay.yfilter) || ydk::is_set(max_connection_attempts.yfilter) || ydk::is_set(password.yfilter) || ydk::is_set(port.yfilter) || ydk::is_set(reconnect_on_changed_schema.yfilter) || ydk::is_set(schema_cache_directory.yfilter) || ydk::is_set(schemaless.yfilter) || ydk::is_set(sleep_factor.yfilter) || ydk::is_set(tcp_only.yfilter) || ydk::is_set(username.yfilter) || (available_capabilities != nullptr && available_capabilities->has_operation()) || (clustered_connection_status != nullptr && clustered_connection_status->has_operation()) || (pass_through != nullptr && pass_through->has_operation()) || (unavailable_capabilities != nullptr && unavailable_capabilities->has_operation()) || (yang_library != nullptr && yang_library->has_operation()) || (yang_module_capabilities != nullptr && yang_module_capabilities->has_operation()); } std::string NetworkTopology::Topology::Node::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "node" <<"[node-id='" <<node_id <<"']"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (node_id.is_set || is_set(node_id.yfilter)) leaf_name_data.push_back(node_id.get_name_leafdata()); if (between_attempts_timeout_millis.is_set || is_set(between_attempts_timeout_millis.yfilter)) leaf_name_data.push_back(between_attempts_timeout_millis.get_name_leafdata()); if (concurrent_rpc_limit.is_set || is_set(concurrent_rpc_limit.yfilter)) leaf_name_data.push_back(concurrent_rpc_limit.get_name_leafdata()); if (connected_message.is_set || is_set(connected_message.yfilter)) leaf_name_data.push_back(connected_message.get_name_leafdata()); if (connection_status.is_set || is_set(connection_status.yfilter)) leaf_name_data.push_back(connection_status.get_name_leafdata()); if (connection_timeout_millis.is_set || is_set(connection_timeout_millis.yfilter)) leaf_name_data.push_back(connection_timeout_millis.get_name_leafdata()); if (default_request_timeout_millis.is_set || is_set(default_request_timeout_millis.yfilter)) leaf_name_data.push_back(default_request_timeout_millis.get_name_leafdata()); if (host.is_set || is_set(host.yfilter)) leaf_name_data.push_back(host.get_name_leafdata()); if (keepalive_delay.is_set || is_set(keepalive_delay.yfilter)) leaf_name_data.push_back(keepalive_delay.get_name_leafdata()); if (max_connection_attempts.is_set || is_set(max_connection_attempts.yfilter)) leaf_name_data.push_back(max_connection_attempts.get_name_leafdata()); if (password.is_set || is_set(password.yfilter)) leaf_name_data.push_back(password.get_name_leafdata()); if (port.is_set || is_set(port.yfilter)) leaf_name_data.push_back(port.get_name_leafdata()); if (reconnect_on_changed_schema.is_set || is_set(reconnect_on_changed_schema.yfilter)) leaf_name_data.push_back(reconnect_on_changed_schema.get_name_leafdata()); if (schema_cache_directory.is_set || is_set(schema_cache_directory.yfilter)) leaf_name_data.push_back(schema_cache_directory.get_name_leafdata()); if (schemaless.is_set || is_set(schemaless.yfilter)) leaf_name_data.push_back(schemaless.get_name_leafdata()); if (sleep_factor.is_set || is_set(sleep_factor.yfilter)) leaf_name_data.push_back(sleep_factor.get_name_leafdata()); if (tcp_only.is_set || is_set(tcp_only.yfilter)) leaf_name_data.push_back(tcp_only.get_name_leafdata()); if (username.is_set || is_set(username.yfilter)) leaf_name_data.push_back(username.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "available-capabilities") { if(available_capabilities == nullptr) { available_capabilities = std::make_shared<NetworkTopology::Topology::Node::AvailableCapabilities>(); } return available_capabilities; } if(child_yang_name == "clustered-connection-status") { if(clustered_connection_status == nullptr) { clustered_connection_status = std::make_shared<NetworkTopology::Topology::Node::ClusteredConnectionStatus>(); } return clustered_connection_status; } if(child_yang_name == "pass-through") { if(pass_through == nullptr) { pass_through = std::make_shared<NetworkTopology::Topology::Node::PassThrough>(); } return pass_through; } if(child_yang_name == "supporting-node") { for(auto const & c : supporting_node) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::Node::SupportingNode>(); c->parent = this; supporting_node.push_back(c); return c; } if(child_yang_name == "termination-point") { for(auto const & c : termination_point) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::Node::TerminationPoint>(); c->parent = this; termination_point.push_back(c); return c; } if(child_yang_name == "unavailable-capabilities") { if(unavailable_capabilities == nullptr) { unavailable_capabilities = std::make_shared<NetworkTopology::Topology::Node::UnavailableCapabilities>(); } return unavailable_capabilities; } if(child_yang_name == "yang-library") { if(yang_library == nullptr) { yang_library = std::make_shared<NetworkTopology::Topology::Node::YangLibrary>(); } return yang_library; } if(child_yang_name == "yang-module-capabilities") { if(yang_module_capabilities == nullptr) { yang_module_capabilities = std::make_shared<NetworkTopology::Topology::Node::YangModuleCapabilities>(); } return yang_module_capabilities; } return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; if(available_capabilities != nullptr) { children["available-capabilities"] = available_capabilities; } if(clustered_connection_status != nullptr) { children["clustered-connection-status"] = clustered_connection_status; } if(pass_through != nullptr) { children["pass-through"] = pass_through; } for (auto const & c : supporting_node) { children[c->get_segment_path()] = c; } for (auto const & c : termination_point) { children[c->get_segment_path()] = c; } if(unavailable_capabilities != nullptr) { children["unavailable-capabilities"] = unavailable_capabilities; } if(yang_library != nullptr) { children["yang-library"] = yang_library; } if(yang_module_capabilities != nullptr) { children["yang-module-capabilities"] = yang_module_capabilities; } return children; } void NetworkTopology::Topology::Node::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "node-id") { node_id = value; node_id.value_namespace = name_space; node_id.value_namespace_prefix = name_space_prefix; } if(value_path == "between-attempts-timeout-millis") { between_attempts_timeout_millis = value; between_attempts_timeout_millis.value_namespace = name_space; between_attempts_timeout_millis.value_namespace_prefix = name_space_prefix; } if(value_path == "concurrent-rpc-limit") { concurrent_rpc_limit = value; concurrent_rpc_limit.value_namespace = name_space; concurrent_rpc_limit.value_namespace_prefix = name_space_prefix; } if(value_path == "connected-message") { connected_message = value; connected_message.value_namespace = name_space; connected_message.value_namespace_prefix = name_space_prefix; } if(value_path == "connection-status") { connection_status = value; connection_status.value_namespace = name_space; connection_status.value_namespace_prefix = name_space_prefix; } if(value_path == "connection-timeout-millis") { connection_timeout_millis = value; connection_timeout_millis.value_namespace = name_space; connection_timeout_millis.value_namespace_prefix = name_space_prefix; } if(value_path == "default-request-timeout-millis") { default_request_timeout_millis = value; default_request_timeout_millis.value_namespace = name_space; default_request_timeout_millis.value_namespace_prefix = name_space_prefix; } if(value_path == "host") { host = value; host.value_namespace = name_space; host.value_namespace_prefix = name_space_prefix; } if(value_path == "keepalive-delay") { keepalive_delay = value; keepalive_delay.value_namespace = name_space; keepalive_delay.value_namespace_prefix = name_space_prefix; } if(value_path == "max-connection-attempts") { max_connection_attempts = value; max_connection_attempts.value_namespace = name_space; max_connection_attempts.value_namespace_prefix = name_space_prefix; } if(value_path == "password") { password = value; password.value_namespace = name_space; password.value_namespace_prefix = name_space_prefix; } if(value_path == "port") { port = value; port.value_namespace = name_space; port.value_namespace_prefix = name_space_prefix; } if(value_path == "reconnect-on-changed-schema") { reconnect_on_changed_schema = value; reconnect_on_changed_schema.value_namespace = name_space; reconnect_on_changed_schema.value_namespace_prefix = name_space_prefix; } if(value_path == "schema-cache-directory") { schema_cache_directory = value; schema_cache_directory.value_namespace = name_space; schema_cache_directory.value_namespace_prefix = name_space_prefix; } if(value_path == "schemaless") { schemaless = value; schemaless.value_namespace = name_space; schemaless.value_namespace_prefix = name_space_prefix; } if(value_path == "sleep-factor") { sleep_factor = value; sleep_factor.value_namespace = name_space; sleep_factor.value_namespace_prefix = name_space_prefix; } if(value_path == "tcp-only") { tcp_only = value; tcp_only.value_namespace = name_space; tcp_only.value_namespace_prefix = name_space_prefix; } if(value_path == "username") { username = value; username.value_namespace = name_space; username.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Node::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "node-id") { node_id.yfilter = yfilter; } if(value_path == "between-attempts-timeout-millis") { between_attempts_timeout_millis.yfilter = yfilter; } if(value_path == "concurrent-rpc-limit") { concurrent_rpc_limit.yfilter = yfilter; } if(value_path == "connected-message") { connected_message.yfilter = yfilter; } if(value_path == "connection-status") { connection_status.yfilter = yfilter; } if(value_path == "connection-timeout-millis") { connection_timeout_millis.yfilter = yfilter; } if(value_path == "default-request-timeout-millis") { default_request_timeout_millis.yfilter = yfilter; } if(value_path == "host") { host.yfilter = yfilter; } if(value_path == "keepalive-delay") { keepalive_delay.yfilter = yfilter; } if(value_path == "max-connection-attempts") { max_connection_attempts.yfilter = yfilter; } if(value_path == "password") { password.yfilter = yfilter; } if(value_path == "port") { port.yfilter = yfilter; } if(value_path == "reconnect-on-changed-schema") { reconnect_on_changed_schema.yfilter = yfilter; } if(value_path == "schema-cache-directory") { schema_cache_directory.yfilter = yfilter; } if(value_path == "schemaless") { schemaless.yfilter = yfilter; } if(value_path == "sleep-factor") { sleep_factor.yfilter = yfilter; } if(value_path == "tcp-only") { tcp_only.yfilter = yfilter; } if(value_path == "username") { username.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::has_leaf_or_child_of_name(const std::string & name) const { if(name == "available-capabilities" || name == "clustered-connection-status" || name == "pass-through" || name == "supporting-node" || name == "termination-point" || name == "unavailable-capabilities" || name == "yang-library" || name == "yang-module-capabilities" || name == "node-id" || name == "between-attempts-timeout-millis" || name == "concurrent-rpc-limit" || name == "connected-message" || name == "connection-status" || name == "connection-timeout-millis" || name == "default-request-timeout-millis" || name == "host" || name == "keepalive-delay" || name == "max-connection-attempts" || name == "password" || name == "port" || name == "reconnect-on-changed-schema" || name == "schema-cache-directory" || name == "schemaless" || name == "sleep-factor" || name == "tcp-only" || name == "username") return true; return false; } NetworkTopology::Topology::Node::SupportingNode::SupportingNode() : topology_ref{YType::str, "topology-ref"}, node_ref{YType::str, "node-ref"} { yang_name = "supporting-node"; yang_parent_name = "node"; } NetworkTopology::Topology::Node::SupportingNode::~SupportingNode() { } bool NetworkTopology::Topology::Node::SupportingNode::has_data() const { return topology_ref.is_set || node_ref.is_set; } bool NetworkTopology::Topology::Node::SupportingNode::has_operation() const { return is_set(yfilter) || ydk::is_set(topology_ref.yfilter) || ydk::is_set(node_ref.yfilter); } std::string NetworkTopology::Topology::Node::SupportingNode::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "supporting-node" <<"[topology-ref='" <<topology_ref <<"']" <<"[node-ref='" <<node_ref <<"']"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::SupportingNode::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (topology_ref.is_set || is_set(topology_ref.yfilter)) leaf_name_data.push_back(topology_ref.get_name_leafdata()); if (node_ref.is_set || is_set(node_ref.yfilter)) leaf_name_data.push_back(node_ref.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::SupportingNode::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::SupportingNode::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Node::SupportingNode::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "topology-ref") { topology_ref = value; topology_ref.value_namespace = name_space; topology_ref.value_namespace_prefix = name_space_prefix; } if(value_path == "node-ref") { node_ref = value; node_ref.value_namespace = name_space; node_ref.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Node::SupportingNode::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "topology-ref") { topology_ref.yfilter = yfilter; } if(value_path == "node-ref") { node_ref.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::SupportingNode::has_leaf_or_child_of_name(const std::string & name) const { if(name == "topology-ref" || name == "node-ref") return true; return false; } NetworkTopology::Topology::Node::TerminationPoint::TerminationPoint() : tp_id{YType::str, "tp-id"}, tp_ref{YType::str, "tp-ref"} { yang_name = "termination-point"; yang_parent_name = "node"; } NetworkTopology::Topology::Node::TerminationPoint::~TerminationPoint() { } bool NetworkTopology::Topology::Node::TerminationPoint::has_data() const { for (auto const & leaf : tp_ref.getYLeafs()) { if(leaf.is_set) return true; } return tp_id.is_set; } bool NetworkTopology::Topology::Node::TerminationPoint::has_operation() const { for (auto const & leaf : tp_ref.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(tp_id.yfilter) || ydk::is_set(tp_ref.yfilter); } std::string NetworkTopology::Topology::Node::TerminationPoint::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "termination-point" <<"[tp-id='" <<tp_id <<"']"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::TerminationPoint::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (tp_id.is_set || is_set(tp_id.yfilter)) leaf_name_data.push_back(tp_id.get_name_leafdata()); auto tp_ref_name_datas = tp_ref.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), tp_ref_name_datas.begin(), tp_ref_name_datas.end()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::TerminationPoint::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::TerminationPoint::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Node::TerminationPoint::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "tp-id") { tp_id = value; tp_id.value_namespace = name_space; tp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "tp-ref") { tp_ref.append(value); } } void NetworkTopology::Topology::Node::TerminationPoint::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "tp-id") { tp_id.yfilter = yfilter; } if(value_path == "tp-ref") { tp_ref.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::TerminationPoint::has_leaf_or_child_of_name(const std::string & name) const { if(name == "tp-id" || name == "tp-ref") return true; return false; } NetworkTopology::Topology::Node::YangModuleCapabilities::YangModuleCapabilities() : capability{YType::str, "capability"}, override{YType::boolean, "override"} { yang_name = "yang-module-capabilities"; yang_parent_name = "node"; } NetworkTopology::Topology::Node::YangModuleCapabilities::~YangModuleCapabilities() { } bool NetworkTopology::Topology::Node::YangModuleCapabilities::has_data() const { for (auto const & leaf : capability.getYLeafs()) { if(leaf.is_set) return true; } return override.is_set; } bool NetworkTopology::Topology::Node::YangModuleCapabilities::has_operation() const { for (auto const & leaf : capability.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(capability.yfilter) || ydk::is_set(override.yfilter); } std::string NetworkTopology::Topology::Node::YangModuleCapabilities::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "netconf-node-topology:yang-module-capabilities"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::YangModuleCapabilities::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (override.is_set || is_set(override.yfilter)) leaf_name_data.push_back(override.get_name_leafdata()); auto capability_name_datas = capability.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), capability_name_datas.begin(), capability_name_datas.end()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::YangModuleCapabilities::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::YangModuleCapabilities::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Node::YangModuleCapabilities::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "capability") { capability.append(value); } if(value_path == "override") { override = value; override.value_namespace = name_space; override.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Node::YangModuleCapabilities::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "capability") { capability.yfilter = yfilter; } if(value_path == "override") { override.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::YangModuleCapabilities::has_leaf_or_child_of_name(const std::string & name) const { if(name == "capability" || name == "override") return true; return false; } NetworkTopology::Topology::Node::ClusteredConnectionStatus::ClusteredConnectionStatus() : netconf_master_node{YType::str, "netconf-master-node"} { yang_name = "clustered-connection-status"; yang_parent_name = "node"; } NetworkTopology::Topology::Node::ClusteredConnectionStatus::~ClusteredConnectionStatus() { } bool NetworkTopology::Topology::Node::ClusteredConnectionStatus::has_data() const { for (std::size_t index=0; index<node_status.size(); index++) { if(node_status[index]->has_data()) return true; } return netconf_master_node.is_set; } bool NetworkTopology::Topology::Node::ClusteredConnectionStatus::has_operation() const { for (std::size_t index=0; index<node_status.size(); index++) { if(node_status[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(netconf_master_node.yfilter); } std::string NetworkTopology::Topology::Node::ClusteredConnectionStatus::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "netconf-node-topology:clustered-connection-status"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::ClusteredConnectionStatus::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (netconf_master_node.is_set || is_set(netconf_master_node.yfilter)) leaf_name_data.push_back(netconf_master_node.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::ClusteredConnectionStatus::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "node-status") { for(auto const & c : node_status) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus>(); c->parent = this; node_status.push_back(c); return c; } return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::ClusteredConnectionStatus::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; for (auto const & c : node_status) { children[c->get_segment_path()] = c; } return children; } void NetworkTopology::Topology::Node::ClusteredConnectionStatus::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "netconf-master-node") { netconf_master_node = value; netconf_master_node.value_namespace = name_space; netconf_master_node.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Node::ClusteredConnectionStatus::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "netconf-master-node") { netconf_master_node.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::ClusteredConnectionStatus::has_leaf_or_child_of_name(const std::string & name) const { if(name == "node-status" || name == "netconf-master-node") return true; return false; } NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::NodeStatus() : node{YType::str, "node"}, status{YType::enumeration, "status"} { yang_name = "node-status"; yang_parent_name = "clustered-connection-status"; } NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::~NodeStatus() { } bool NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::has_data() const { return node.is_set || status.is_set; } bool NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::has_operation() const { return is_set(yfilter) || ydk::is_set(node.yfilter) || ydk::is_set(status.yfilter); } std::string NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "node-status"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (node.is_set || is_set(node.yfilter)) leaf_name_data.push_back(node.get_name_leafdata()); if (status.is_set || is_set(status.yfilter)) leaf_name_data.push_back(status.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "node") { node = value; node.value_namespace = name_space; node.value_namespace_prefix = name_space_prefix; } if(value_path == "status") { status = value; status.value_namespace = name_space; status.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "node") { node.yfilter = yfilter; } if(value_path == "status") { status.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::has_leaf_or_child_of_name(const std::string & name) const { if(name == "node" || name == "status") return true; return false; } NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapabilities() { yang_name = "available-capabilities"; yang_parent_name = "node"; } NetworkTopology::Topology::Node::AvailableCapabilities::~AvailableCapabilities() { } bool NetworkTopology::Topology::Node::AvailableCapabilities::has_data() const { for (std::size_t index=0; index<available_capability.size(); index++) { if(available_capability[index]->has_data()) return true; } return false; } bool NetworkTopology::Topology::Node::AvailableCapabilities::has_operation() const { for (std::size_t index=0; index<available_capability.size(); index++) { if(available_capability[index]->has_operation()) return true; } return is_set(yfilter); } std::string NetworkTopology::Topology::Node::AvailableCapabilities::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "netconf-node-topology:available-capabilities"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::AvailableCapabilities::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::AvailableCapabilities::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "available-capability") { for(auto const & c : available_capability) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability>(); c->parent = this; available_capability.push_back(c); return c; } return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::AvailableCapabilities::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; for (auto const & c : available_capability) { children[c->get_segment_path()] = c; } return children; } void NetworkTopology::Topology::Node::AvailableCapabilities::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkTopology::Topology::Node::AvailableCapabilities::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkTopology::Topology::Node::AvailableCapabilities::has_leaf_or_child_of_name(const std::string & name) const { if(name == "available-capability") return true; return false; } NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::AvailableCapability() : capability{YType::str, "capability"}, capability_origin{YType::enumeration, "capability-origin"} { yang_name = "available-capability"; yang_parent_name = "available-capabilities"; } NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::~AvailableCapability() { } bool NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::has_data() const { return capability.is_set || capability_origin.is_set; } bool NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::has_operation() const { return is_set(yfilter) || ydk::is_set(capability.yfilter) || ydk::is_set(capability_origin.yfilter); } std::string NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "available-capability"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (capability.is_set || is_set(capability.yfilter)) leaf_name_data.push_back(capability.get_name_leafdata()); if (capability_origin.is_set || is_set(capability_origin.yfilter)) leaf_name_data.push_back(capability_origin.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "capability") { capability = value; capability.value_namespace = name_space; capability.value_namespace_prefix = name_space_prefix; } if(value_path == "capability-origin") { capability_origin = value; capability_origin.value_namespace = name_space; capability_origin.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "capability") { capability.yfilter = yfilter; } if(value_path == "capability-origin") { capability_origin.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::has_leaf_or_child_of_name(const std::string & name) const { if(name == "capability" || name == "capability-origin") return true; return false; } NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapabilities() { yang_name = "unavailable-capabilities"; yang_parent_name = "node"; } NetworkTopology::Topology::Node::UnavailableCapabilities::~UnavailableCapabilities() { } bool NetworkTopology::Topology::Node::UnavailableCapabilities::has_data() const { for (std::size_t index=0; index<unavailable_capability.size(); index++) { if(unavailable_capability[index]->has_data()) return true; } return false; } bool NetworkTopology::Topology::Node::UnavailableCapabilities::has_operation() const { for (std::size_t index=0; index<unavailable_capability.size(); index++) { if(unavailable_capability[index]->has_operation()) return true; } return is_set(yfilter); } std::string NetworkTopology::Topology::Node::UnavailableCapabilities::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "netconf-node-topology:unavailable-capabilities"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::UnavailableCapabilities::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::UnavailableCapabilities::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "unavailable-capability") { for(auto const & c : unavailable_capability) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability>(); c->parent = this; unavailable_capability.push_back(c); return c; } return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::UnavailableCapabilities::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; for (auto const & c : unavailable_capability) { children[c->get_segment_path()] = c; } return children; } void NetworkTopology::Topology::Node::UnavailableCapabilities::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkTopology::Topology::Node::UnavailableCapabilities::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkTopology::Topology::Node::UnavailableCapabilities::has_leaf_or_child_of_name(const std::string & name) const { if(name == "unavailable-capability") return true; return false; } NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::UnavailableCapability() : capability{YType::str, "capability"}, failure_reason{YType::enumeration, "failure-reason"} { yang_name = "unavailable-capability"; yang_parent_name = "unavailable-capabilities"; } NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::~UnavailableCapability() { } bool NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::has_data() const { return capability.is_set || failure_reason.is_set; } bool NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::has_operation() const { return is_set(yfilter) || ydk::is_set(capability.yfilter) || ydk::is_set(failure_reason.yfilter); } std::string NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "unavailable-capability"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (capability.is_set || is_set(capability.yfilter)) leaf_name_data.push_back(capability.get_name_leafdata()); if (failure_reason.is_set || is_set(failure_reason.yfilter)) leaf_name_data.push_back(failure_reason.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "capability") { capability = value; capability.value_namespace = name_space; capability.value_namespace_prefix = name_space_prefix; } if(value_path == "failure-reason") { failure_reason = value; failure_reason.value_namespace = name_space; failure_reason.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "capability") { capability.yfilter = yfilter; } if(value_path == "failure-reason") { failure_reason.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::has_leaf_or_child_of_name(const std::string & name) const { if(name == "capability" || name == "failure-reason") return true; return false; } NetworkTopology::Topology::Node::PassThrough::PassThrough() { yang_name = "pass-through"; yang_parent_name = "node"; } NetworkTopology::Topology::Node::PassThrough::~PassThrough() { } bool NetworkTopology::Topology::Node::PassThrough::has_data() const { return false; } bool NetworkTopology::Topology::Node::PassThrough::has_operation() const { return is_set(yfilter); } std::string NetworkTopology::Topology::Node::PassThrough::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "netconf-node-topology:pass-through"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::PassThrough::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::PassThrough::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::PassThrough::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Node::PassThrough::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void NetworkTopology::Topology::Node::PassThrough::set_filter(const std::string & value_path, YFilter yfilter) { } bool NetworkTopology::Topology::Node::PassThrough::has_leaf_or_child_of_name(const std::string & name) const { return false; } NetworkTopology::Topology::Node::YangLibrary::YangLibrary() : password{YType::str, "password"}, username{YType::str, "username"}, yang_library_url{YType::str, "yang-library-url"} { yang_name = "yang-library"; yang_parent_name = "node"; } NetworkTopology::Topology::Node::YangLibrary::~YangLibrary() { } bool NetworkTopology::Topology::Node::YangLibrary::has_data() const { return password.is_set || username.is_set || yang_library_url.is_set; } bool NetworkTopology::Topology::Node::YangLibrary::has_operation() const { return is_set(yfilter) || ydk::is_set(password.yfilter) || ydk::is_set(username.yfilter) || ydk::is_set(yang_library_url.yfilter); } std::string NetworkTopology::Topology::Node::YangLibrary::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "netconf-node-topology:yang-library"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Node::YangLibrary::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (password.is_set || is_set(password.yfilter)) leaf_name_data.push_back(password.get_name_leafdata()); if (username.is_set || is_set(username.yfilter)) leaf_name_data.push_back(username.get_name_leafdata()); if (yang_library_url.is_set || is_set(yang_library_url.yfilter)) leaf_name_data.push_back(yang_library_url.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Node::YangLibrary::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Node::YangLibrary::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Node::YangLibrary::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "password") { password = value; password.value_namespace = name_space; password.value_namespace_prefix = name_space_prefix; } if(value_path == "username") { username = value; username.value_namespace = name_space; username.value_namespace_prefix = name_space_prefix; } if(value_path == "yang-library-url") { yang_library_url = value; yang_library_url.value_namespace = name_space; yang_library_url.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Node::YangLibrary::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "password") { password.yfilter = yfilter; } if(value_path == "username") { username.yfilter = yfilter; } if(value_path == "yang-library-url") { yang_library_url.yfilter = yfilter; } } bool NetworkTopology::Topology::Node::YangLibrary::has_leaf_or_child_of_name(const std::string & name) const { if(name == "password" || name == "username" || name == "yang-library-url") return true; return false; } NetworkTopology::Topology::Link::Link() : link_id{YType::str, "link-id"} , destination(std::make_shared<NetworkTopology::Topology::Link::Destination>()) ,source(std::make_shared<NetworkTopology::Topology::Link::Source>()) { destination->parent = this; source->parent = this; yang_name = "link"; yang_parent_name = "topology"; } NetworkTopology::Topology::Link::~Link() { } bool NetworkTopology::Topology::Link::has_data() const { for (std::size_t index=0; index<supporting_link.size(); index++) { if(supporting_link[index]->has_data()) return true; } return link_id.is_set || (destination != nullptr && destination->has_data()) || (source != nullptr && source->has_data()); } bool NetworkTopology::Topology::Link::has_operation() const { for (std::size_t index=0; index<supporting_link.size(); index++) { if(supporting_link[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(link_id.yfilter) || (destination != nullptr && destination->has_operation()) || (source != nullptr && source->has_operation()); } std::string NetworkTopology::Topology::Link::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "link" <<"[link-id='" <<link_id <<"']"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Link::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (link_id.is_set || is_set(link_id.yfilter)) leaf_name_data.push_back(link_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Link::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "destination") { if(destination == nullptr) { destination = std::make_shared<NetworkTopology::Topology::Link::Destination>(); } return destination; } if(child_yang_name == "source") { if(source == nullptr) { source = std::make_shared<NetworkTopology::Topology::Link::Source>(); } return source; } if(child_yang_name == "supporting-link") { for(auto const & c : supporting_link) { std::string segment = c->get_segment_path(); if(segment_path == segment) { return c; } } auto c = std::make_shared<NetworkTopology::Topology::Link::SupportingLink>(); c->parent = this; supporting_link.push_back(c); return c; } return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Link::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; if(destination != nullptr) { children["destination"] = destination; } if(source != nullptr) { children["source"] = source; } for (auto const & c : supporting_link) { children[c->get_segment_path()] = c; } return children; } void NetworkTopology::Topology::Link::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "link-id") { link_id = value; link_id.value_namespace = name_space; link_id.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Link::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "link-id") { link_id.yfilter = yfilter; } } bool NetworkTopology::Topology::Link::has_leaf_or_child_of_name(const std::string & name) const { if(name == "destination" || name == "source" || name == "supporting-link" || name == "link-id") return true; return false; } NetworkTopology::Topology::Link::Source::Source() : source_node{YType::str, "source-node"}, source_tp{YType::str, "source-tp"} { yang_name = "source"; yang_parent_name = "link"; } NetworkTopology::Topology::Link::Source::~Source() { } bool NetworkTopology::Topology::Link::Source::has_data() const { return source_node.is_set || source_tp.is_set; } bool NetworkTopology::Topology::Link::Source::has_operation() const { return is_set(yfilter) || ydk::is_set(source_node.yfilter) || ydk::is_set(source_tp.yfilter); } std::string NetworkTopology::Topology::Link::Source::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "source"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Link::Source::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (source_node.is_set || is_set(source_node.yfilter)) leaf_name_data.push_back(source_node.get_name_leafdata()); if (source_tp.is_set || is_set(source_tp.yfilter)) leaf_name_data.push_back(source_tp.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Link::Source::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Link::Source::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Link::Source::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "source-node") { source_node = value; source_node.value_namespace = name_space; source_node.value_namespace_prefix = name_space_prefix; } if(value_path == "source-tp") { source_tp = value; source_tp.value_namespace = name_space; source_tp.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Link::Source::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "source-node") { source_node.yfilter = yfilter; } if(value_path == "source-tp") { source_tp.yfilter = yfilter; } } bool NetworkTopology::Topology::Link::Source::has_leaf_or_child_of_name(const std::string & name) const { if(name == "source-node" || name == "source-tp") return true; return false; } NetworkTopology::Topology::Link::Destination::Destination() : dest_node{YType::str, "dest-node"}, dest_tp{YType::str, "dest-tp"} { yang_name = "destination"; yang_parent_name = "link"; } NetworkTopology::Topology::Link::Destination::~Destination() { } bool NetworkTopology::Topology::Link::Destination::has_data() const { return dest_node.is_set || dest_tp.is_set; } bool NetworkTopology::Topology::Link::Destination::has_operation() const { return is_set(yfilter) || ydk::is_set(dest_node.yfilter) || ydk::is_set(dest_tp.yfilter); } std::string NetworkTopology::Topology::Link::Destination::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "destination"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Link::Destination::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (dest_node.is_set || is_set(dest_node.yfilter)) leaf_name_data.push_back(dest_node.get_name_leafdata()); if (dest_tp.is_set || is_set(dest_tp.yfilter)) leaf_name_data.push_back(dest_tp.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Link::Destination::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Link::Destination::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Link::Destination::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "dest-node") { dest_node = value; dest_node.value_namespace = name_space; dest_node.value_namespace_prefix = name_space_prefix; } if(value_path == "dest-tp") { dest_tp = value; dest_tp.value_namespace = name_space; dest_tp.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Link::Destination::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "dest-node") { dest_node.yfilter = yfilter; } if(value_path == "dest-tp") { dest_tp.yfilter = yfilter; } } bool NetworkTopology::Topology::Link::Destination::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dest-node" || name == "dest-tp") return true; return false; } NetworkTopology::Topology::Link::SupportingLink::SupportingLink() : link_ref{YType::str, "link-ref"} { yang_name = "supporting-link"; yang_parent_name = "link"; } NetworkTopology::Topology::Link::SupportingLink::~SupportingLink() { } bool NetworkTopology::Topology::Link::SupportingLink::has_data() const { return link_ref.is_set; } bool NetworkTopology::Topology::Link::SupportingLink::has_operation() const { return is_set(yfilter) || ydk::is_set(link_ref.yfilter); } std::string NetworkTopology::Topology::Link::SupportingLink::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "supporting-link" <<"[link-ref='" <<link_ref <<"']"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > NetworkTopology::Topology::Link::SupportingLink::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (link_ref.is_set || is_set(link_ref.yfilter)) leaf_name_data.push_back(link_ref.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<Entity> NetworkTopology::Topology::Link::SupportingLink::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { return nullptr; } std::map<std::string, std::shared_ptr<Entity>> NetworkTopology::Topology::Link::SupportingLink::get_children() const { std::map<std::string, std::shared_ptr<Entity>> children{}; return children; } void NetworkTopology::Topology::Link::SupportingLink::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { if(value_path == "link-ref") { link_ref = value; link_ref.value_namespace = name_space; link_ref.value_namespace_prefix = name_space_prefix; } } void NetworkTopology::Topology::Link::SupportingLink::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "link-ref") { link_ref.yfilter = yfilter; } } bool NetworkTopology::Topology::Link::SupportingLink::has_leaf_or_child_of_name(const std::string & name) const { if(name == "link-ref") return true; return false; } const Enum::YLeaf NetworkTopology::Topology::Node::ConnectionStatus::connecting {0, "connecting"}; const Enum::YLeaf NetworkTopology::Topology::Node::ConnectionStatus::connected {1, "connected"}; const Enum::YLeaf NetworkTopology::Topology::Node::ConnectionStatus::unable_to_connect {2, "unable-to-connect"}; const Enum::YLeaf NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::Status::connected {0, "connected"}; const Enum::YLeaf NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::Status::unavailable {1, "unavailable"}; const Enum::YLeaf NetworkTopology::Topology::Node::ClusteredConnectionStatus::NodeStatus::Status::failed {2, "failed"}; const Enum::YLeaf NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::CapabilityOrigin::user_defined {0, "user-defined"}; const Enum::YLeaf NetworkTopology::Topology::Node::AvailableCapabilities::AvailableCapability::CapabilityOrigin::device_advertised {1, "device-advertised"}; const Enum::YLeaf NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::FailureReason::missing_source {0, "missing-source"}; const Enum::YLeaf NetworkTopology::Topology::Node::UnavailableCapabilities::UnavailableCapability::FailureReason::unable_to_resolve {1, "unable-to-resolve"}; } }
30.98722
809
0.695884
YDK-Solutions
7252b4cf8166909fdca015773c08d681d5ab6a3c
2,643
cc
C++
src/ufo/marine/adt/ObsADTTLAD.cc
fmahebert/ufo
2af9b91433553ca473c72fcd131400a01c3aabdb
[ "Apache-2.0" ]
1
2021-10-08T16:37:25.000Z
2021-10-08T16:37:25.000Z
src/ufo/marine/adt/ObsADTTLAD.cc
fmahebert/ufo
2af9b91433553ca473c72fcd131400a01c3aabdb
[ "Apache-2.0" ]
9
2021-06-25T17:18:06.000Z
2021-10-08T17:40:31.000Z
src/ufo/marine/adt/ObsADTTLAD.cc
fmahebert/ufo
2af9b91433553ca473c72fcd131400a01c3aabdb
[ "Apache-2.0" ]
31
2021-06-24T18:07:53.000Z
2021-10-08T15:40:39.000Z
/* * (C) Copyright 2017-2018 UCAR * * 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. */ #include "ufo/marine/adt/ObsADTTLAD.h" #include <ostream> #include <string> #include <vector> #include "ioda/ObsSpace.h" #include "ioda/ObsVector.h" #include "oops/base/Variables.h" #include "oops/util/Logger.h" #include "ufo/GeoVaLs.h" #include "ufo/ObsBias.h" namespace ufo { // ----------------------------------------------------------------------------- static LinearObsOperatorMaker<ObsADTTLAD> makerADTTL_("ADT"); // ----------------------------------------------------------------------------- ObsADTTLAD::ObsADTTLAD(const ioda::ObsSpace & odb, const eckit::Configuration & config) : LinearObsOperatorBase(odb), keyOper_(0), varin_() { const std::vector<std::string> vv{"sea_surface_height_above_geoid"}; varin_.reset(new oops::Variables(vv)); ufo_adt_tlad_setup_f90(keyOper_, config); oops::Log::trace() << "ObsADTTLAD created" << std::endl; } // ----------------------------------------------------------------------------- ObsADTTLAD::~ObsADTTLAD() { ufo_adt_tlad_delete_f90(keyOper_); oops::Log::trace() << "ObsADTTLAD destructed" << std::endl; } // ----------------------------------------------------------------------------- void ObsADTTLAD::setTrajectory(const GeoVaLs & geovals, const ObsBias & bias, ObsDiagnostics &) { ufo_adt_tlad_settraj_f90(keyOper_, geovals.toFortran(), obsspace()); oops::Log::trace() << "ObsADTTLAD: trajectory set" << std::endl; } // ----------------------------------------------------------------------------- void ObsADTTLAD::simulateObsTL(const GeoVaLs & geovals, ioda::ObsVector & ovec) const { ufo_adt_simobs_tl_f90(keyOper_, geovals.toFortran(), obsspace(), ovec.size(), ovec.toFortran()); oops::Log::trace() << "ObsADTTLAD: tangent linear observation operator run" << std::endl; } // ----------------------------------------------------------------------------- void ObsADTTLAD::simulateObsAD(GeoVaLs & geovals, const ioda::ObsVector & ovec) const { ufo_adt_simobs_ad_f90(keyOper_, geovals.toFortran(), obsspace(), ovec.size(), ovec.toFortran()); oops::Log::trace() << "ObsADTTLAD: adjoint observation operator run" << std::endl; } // ----------------------------------------------------------------------------- void ObsADTTLAD::print(std::ostream & os) const { os << "ObsADTTLAD::print not implemented" << std::endl; } // ----------------------------------------------------------------------------- } // namespace ufo
35.716216
98
0.535376
fmahebert
7253d6553eb568b1cf7dacc4b6979c7572e9aac9
1,625
cpp
C++
library/source/lexicon_tests/terminal_tester.cpp
spiretrading/darcel
a9c32989ad9c1571edaa41c7c3a86b276b782c0d
[ "MIT" ]
null
null
null
library/source/lexicon_tests/terminal_tester.cpp
spiretrading/darcel
a9c32989ad9c1571edaa41c7c3a86b276b782c0d
[ "MIT" ]
null
null
null
library/source/lexicon_tests/terminal_tester.cpp
spiretrading/darcel
a9c32989ad9c1571edaa41c7c3a86b276b782c0d
[ "MIT" ]
1
2020-04-17T13:25:25.000Z
2020-04-17T13:25:25.000Z
#include <sstream> #include <catch.hpp> #include "darcel/lexicon/terminal.hpp" using namespace darcel; using namespace std; TEST_CASE("test_terminal_stream", "[Terminal]") { SECTION("New line") { Terminal t(Terminal::Type::NEW_LINE); stringstream ss; ss << t; REQUIRE(ss.str() == "\n"); } SECTION("End of file") { Terminal t(Terminal::Type::END_OF_FILE); stringstream ss; ss << t; REQUIRE(ss.str().empty()); } } TEST_CASE("test_terminal_equality", "[Terminal]") { Terminal t1(Terminal::Type::END_OF_FILE); Terminal t2(Terminal::Type::NEW_LINE); REQUIRE(t1 == t1); REQUIRE(t1 == Terminal::Type::END_OF_FILE); REQUIRE(t1 != t2); REQUIRE(t2 == Terminal::Type::NEW_LINE); } TEST_CASE("test_parse_terminal", "[Terminal]") { SECTION("Valid Terminal") { auto s = "\0"; REQUIRE(parse_terminal(LexicalIterator(s, 1)) == Terminal::Type::END_OF_FILE); REQUIRE(parse_terminal("\n") == Terminal::Type::NEW_LINE); } SECTION("Delimiters") { auto s = "\09"; REQUIRE(parse_terminal(LexicalIterator(s, 2)) == Terminal::Type::END_OF_FILE); s = "\0+"; REQUIRE(parse_terminal(LexicalIterator(s, 1)) == Terminal::Type::END_OF_FILE); s = "\0:"; REQUIRE(parse_terminal(LexicalIterator(s, 1)) == Terminal::Type::END_OF_FILE); s = "\0,"; REQUIRE(parse_terminal(LexicalIterator(s, 1)) == Terminal::Type::END_OF_FILE); s = "\0a"; REQUIRE(parse_terminal(LexicalIterator(s, 1)) == Terminal::Type::END_OF_FILE); } SECTION("Invalid Terminal") { REQUIRE(parse_terminal("abc") == std::nullopt); } }
27.083333
62
0.635692
spiretrading
7254dab5c34ed42970c7312394b0ca3c4c543331
3,701
cpp
C++
Enemies/EnemyTank.cpp
JTuthill01/Hell-on-Treads
a89c939c3f1d0bd47d075d5b02d589637548ca31
[ "MIT" ]
null
null
null
Enemies/EnemyTank.cpp
JTuthill01/Hell-on-Treads
a89c939c3f1d0bd47d075d5b02d589637548ca31
[ "MIT" ]
null
null
null
Enemies/EnemyTank.cpp
JTuthill01/Hell-on-Treads
a89c939c3f1d0bd47d075d5b02d589637548ca31
[ "MIT" ]
null
null
null
#include "stdafx.hpp" #include "EnemyTank.hpp" std::vector<sf::Texture> EnemyTank::mEnemyProjectileTextures; EnemyTank::EnemyTank() : mShootTimer(mShootTimerMax), mShootTimerMax(50.F) { this->createMovementComponent(350.f, 16.f, 6.f); this->createAnimationComponent(this->mEnemyTankTexture); this->pAnimationComponent->addAnimation("MOVE", 5.f, 0, 0, 7, 0, 435, 435); this->pAnimationComponent->addAnimation("ATTACK", 5.f, 0, 1, 7, 1, 435, 435); this->pAudio.loadSound("Resources/Sounds/Explosions/explosion1.ogg"); this->pAudio.setVolume(10.F); this->loadProjectile(); this->loadEnemyTanks(); } EnemyTank::~EnemyTank() = default; void EnemyTank::render(sf::RenderTarget& target) { target.draw(this->mEnemyTankSprite); for (size_t i = 0; i < this->mProjectiles.size(); i++) this->mProjectiles[i].render(target); } void EnemyTank::update(const float& deltaTime) { this->pMovementComponent->update(deltaTime); this->updateAnimations(deltaTime); this->mEnemyTankSprite.move(sf::Vector2f(-0.6F, 0.F)); for (size_t i = 0; i < this->mProjectiles.size(); i++) this->mProjectiles[i].update(deltaTime); } void EnemyTank::move(const float direction_x, const float direction_y, const float& deltaTime) { if (this->pMovementComponent) this->pMovementComponent->move(direction_x, direction_y, deltaTime); } void EnemyTank::updateAnimations(const float& deltaTime) { if (this->mIsAttacking) { if (this->mEnemyTankSprite.getScale().x > 0.f) //Facing left this->mEnemyTankSprite.setOrigin(96.f, 0.f); if (this->pAnimationComponent->play("ATTACK", deltaTime, true)) { this->mIsAttacking = false; this->mIsMuzzleOn = false; if (this->mEnemyTankSprite.getScale().x > 0.f) //Facing left this->mEnemyTankSprite.setOrigin(0.f, 0.f); } } else if (this->pMovementComponent->getState(MOVING)) { if (this->mEnemyTankSprite.getScale().x < 0.f) { this->mEnemyTankSprite.setOrigin(0.f, 0.f); this->mEnemyTankSprite.setScale(1.f, 1.f); } this->pAnimationComponent->play("MOVE", deltaTime, this->pMovementComponent->getVelocity().x, this->pMovementComponent->getMaxVelocity()); } else if (this->pMovementComponent->getState(MOVING)) { if (this->mEnemyTankSprite.getScale().x < 0.f) { this->mEnemyTankSprite.setOrigin(140.f, 0.f); this->mEnemyTankSprite.setScale(1.f, 1.f); } this->pAnimationComponent->play("MOVE", deltaTime, this->pMovementComponent->getVelocity().x, this->pMovementComponent->getMaxVelocity()); } } void EnemyTank::createMovementComponent(const float max_velocity, const float acceleration, const float deceleration) { this->pMovementComponent = new MovementComponent(this->mEnemyTankSprite, max_velocity, acceleration, deceleration); } void EnemyTank::createAnimationComponent(sf::Texture& texture_sheet) { this->pAnimationComponent = new AnimationComponent(this->mEnemyTankSprite, texture_sheet); } void EnemyTank::loadEnemyTanks() { if (!this->mEnemyTankTexture.loadFromFile("Resources/Textures/Enemy/TankCombined.png")) std::cerr << "Fucking EnemyTank failed to fucking load" << "\n"; this->mEnemyTankSprite.setTexture(this->mEnemyTankTexture); this->mEnemyTankSprite.setPosition(1700.F, 710.F); this->mEnemyTankSprite.setColor(sf::Color::Green); } void EnemyTank::loadProjectile() { sf::Texture temp; if (!temp.loadFromFile("Resources/Textures/Bullets/Bomb_2.png")) std::cerr << "Failed to fucking the fucking bomb texture" << "\n"; this->mEnemyProjectileTextures.push_back(temp); } void EnemyTank::updateAttack(const float& deltaTime) { }
28.689922
118
0.705755
JTuthill01
7257004ed1c670e39b57325874d884a14e951af7
12,376
cpp
C++
cpp/ast/LILRootNode.cpp
veosotano/lil
da2d0774615827d521362ffb731e8abfa3887507
[ "MIT" ]
6
2021-01-02T16:36:28.000Z
2022-01-23T21:50:29.000Z
cpp/ast/LILRootNode.cpp
veosotano/lil
27ef338e7e21403acf2b0202f7db8ef662425d44
[ "MIT" ]
null
null
null
cpp/ast/LILRootNode.cpp
veosotano/lil
27ef338e7e21403acf2b0202f7db8ef662425d44
[ "MIT" ]
null
null
null
/******************************************************************** * * LIL Is a Language * * AUTHORS: Miro Keller * * COPYRIGHT: ©2020-today: All Rights Reserved * * LICENSE: see LICENSE file * * This is a node that participates in local variables * ********************************************************************/ #include "LILRootNode.h" #include "LILAliasDecl.h" #include "LILAssignment.h" #include "LILClassDecl.h" #include "LILConversionDecl.h" #include "LILDocumentation.h" #include "LILFunctionDecl.h" #include "LILInstruction.h" #include "LILNodeToString.h" #include "LILRule.h" #include "LILSelector.h" #include "LILSelectorChain.h" #include "LILSimpleSelector.h" #include "LILSnippetInstruction.h" #include "LILTypeDecl.h" #include "LILVarDecl.h" #include "LILVarName.h" using namespace LIL; LILRootNode::LILRootNode() : LILVarNode(NodeTypeRoot) { } LILRootNode::LILRootNode(const LILRootNode & other) : LILVarNode(other) , _localVars(other._localVars) , _classes(other._classes) , _aliases(other._aliases) , _types(other._types) , _conversions(other._conversions) , _constants(other._constants) , _snippets(other._snippets) , _initializers(other._initializers) , _docs(other._docs) , _rules(other._rules) , _config(other._config) { } LILRootNode::~LILRootNode() { } bool LILRootNode::isRootNode() const { return true; } const std::vector<std::shared_ptr<LILNode>> & LILRootNode::getNodes() const { return this->getChildNodes(); } void LILRootNode::add(std::shared_ptr<LILNode> node, bool addToNodeTree) { switch (node->getNodeType()) { case NodeTypeVarDecl: { auto vd = std::static_pointer_cast<LILVarDecl>(node); auto ty = vd->getType(); if ( vd->getIsExtern() || vd->getIsExported() || vd->getIsConst() ) { if (addToNodeTree) { this->addNode(node); } //local variables on root are globals this->setLocalVariable(vd->getName(), vd); } else if (ty && ty->isA(TypeTypeFunction)) { if (addToNodeTree) { this->addNode(node); } //local variables on root are globals this->setLocalVariable(vd->getName(), node); } else { this->addEvaluable(node); } break; } case NodeTypeFunctionDecl: { auto fd = std::static_pointer_cast<LILFunctionDecl>(node); auto fnTy = std::static_pointer_cast<LILFunctionType>(fd->getType()); if (!fnTy) { std::cerr << "FN DECL HAD NO TY FAIL!!!!!!!!!!\n"; break; } for ( auto arg : fnTy->getArguments()) { if (arg->isA(NodeTypeVarDecl)) { auto argVd = std::static_pointer_cast<LILVarDecl>(arg); fd->setLocalVariable(argVd->getName(), argVd); } } if (addToNodeTree) { this->addNode(fd); } this->setLocalVariable(fd->getName(), fd); break; } case NodeTypeClassDecl: { if (addToNodeTree) { this->addNode(node); } this->addClass(std::static_pointer_cast<LILClassDecl>(node)); break; } case NodeTypeAliasDecl: { if (addToNodeTree) { this->addNode(node); } this->addAlias(std::static_pointer_cast<LILAliasDecl>(node)); break; } case NodeTypeTypeDecl: { if (addToNodeTree) { this->addNode(node); } this->addType(std::static_pointer_cast<LILTypeDecl>(node)); break; } case NodeTypeConversionDecl: { if (addToNodeTree) { this->addNode(node); } this->addConversion(std::static_pointer_cast<LILConversionDecl>(node)); break; } case NodeTypeInstruction: { auto instr = std::static_pointer_cast<LILInstruction>(node); switch (instr->getInstructionType()) { case InstructionTypeNone: case InstructionTypeNew: case InstructionTypeMove: case InstructionTypeRGB: case InstructionTypeRGBA: case InstructionTypeRGBAA: case InstructionTypeRRGGBB: case InstructionTypeRRGGBBA: case InstructionTypeRRGGBBAA: case InstructionTypeGrayscale1: case InstructionTypeGrayscale2: case InstructionTypeDelete: case InstructionTypeSnippet: case InstructionTypeBug: case InstructionTypeArg: //do nothing break; case InstructionTypeIf: case InstructionTypeNeeds: case InstructionTypeImport: case InstructionTypePaste: case InstructionTypeGetConfig: { if (addToNodeTree) { this->addNode(instr); } break; } case InstructionTypeConfigure: { if (addToNodeTree) { this->addNode(instr); } this->addConfigureInstr(instr); break; } case InstructionTypeExport: { for (auto instrNode : instr->getChildNodes()) { this->add(instrNode); } break; } } break; } case NodeTypeSnippetInstruction: { auto snInstr = std::static_pointer_cast<LILSnippetInstruction>(node); this->addSnippet(snInstr); if (addToNodeTree) { this->addNode(node); } break; } case NodeTypeIfInstruction: { if (addToNodeTree) { this->addNode(node); } break; } case NodeTypeForeignLang: { if (addToNodeTree) { this->addNode(node); } break; } case NodeTypeDocumentation: { this->addDoc(std::static_pointer_cast<LILDocumentation>(node)); break; } case NodeTypeRule: { this->addRule(std::static_pointer_cast<LILRule>(node)); break; } default: this->addEvaluable(node); break; } } void LILRootNode::clearNodes() { this->clearChildNodes(); this->_classes.clear(); this->_rules.clear(); this->_docs.clear(); this->_types.clear(); this->_aliases.clear(); this->_snippets.clear(); this->_config.clear(); this->_constants.clear(); this->_mainMenu.clear(); } void LILRootNode::appendNodes(const std::vector<std::shared_ptr<LILNode>> & nodes) { this->_childNodes.insert(this->_childNodes.begin() + this->_childNodes.size(), nodes.begin(), nodes.end()); } void LILRootNode::addClass(std::shared_ptr<LILClassDecl> value) { this->_classes.push_back(value); } const std::vector<std::shared_ptr<LILClassDecl>> & LILRootNode::getClasses() const { return this->_classes; } void LILRootNode::removeClass(std::shared_ptr<LILClassDecl> value) { auto it = std::find(this->_classes.begin(), this->_classes.end(), value); if (it != this->_classes.end()) { this->_classes.erase(it); } } void LILRootNode::addAlias(std::shared_ptr<LILAliasDecl> value) { this->_aliases.push_back(value); } const std::vector<std::shared_ptr<LILAliasDecl>> & LILRootNode::getAliases() const { return this->_aliases; } void LILRootNode::addType(std::shared_ptr<LILTypeDecl> value) { this->_types.push_back(value); } const std::vector<std::shared_ptr<LILTypeDecl>> & LILRootNode::getTypes() const { return this->_types; } void LILRootNode::addConversion(std::shared_ptr<LILConversionDecl> value) { auto vd = value->getVarDecl(); if (!vd) { std::cerr << "!!!!!! CONVERSION DECL HAD NO VAR DECL FAIL !!!!!!\n\n"; return; } auto fromTy = vd->getType(); if (!fromTy) { std::cerr << "!!!!!! VAR DECL OF CONVERSION DECL HAD NO TYPE FAIL !!!!!!\n\n"; return; } auto fromTyName = LILNodeToString::stringify(fromTy.get()); auto toTy = value->getType(); if (!toTy) { std::cerr << "!!!!!! CONVERSION DECL HAD NO TARGET TYPE FAIL !!!!!!\n\n"; return; } auto toTyName = LILNodeToString::stringify(toTy.get()); this->_conversions[fromTyName+"_to_"+toTyName] = value; } const std::map<LILString, std::shared_ptr<LILConversionDecl>> & LILRootNode::getConversions() const { return this->_conversions; } std::shared_ptr<LILConversionDecl> LILRootNode::getConversionNamed(LILString name) { if (this->_conversions.count(name)) { return this->_conversions[name]; } return nullptr; } const std::map<LILString, std::shared_ptr<LILSnippetInstruction>> & LILRootNode::getSnippets() const { return this->_snippets; } std::shared_ptr<LILSnippetInstruction> LILRootNode::getSnippetNamed(LILString key) { if (this->_snippets.count(key)) { return this->_snippets.at(key); } return nullptr; } void LILRootNode::addSnippet(std::shared_ptr<LILSnippetInstruction> snippet) { this->_snippets[snippet->getName()] = snippet; } void LILRootNode::addEvaluable(std::shared_ptr<LILNode> node) { this->_initializers.push_back(node); } bool LILRootNode::hasInitializers() const { return this->_initializers.size() > 0; } const std::vector<std::shared_ptr<LILNode>> & LILRootNode::getInitializers() const { return this->_initializers; } void LILRootNode::clearInitializers() { this->_initializers.clear(); } void LILRootNode::addDoc(std::shared_ptr<LILDocumentation> value) { this->addNode(value); this->_docs.push_back(value); } const std::vector<std::shared_ptr<LILDocumentation>> & LILRootNode::getDocs() const { return this->_docs; } bool LILRootNode::hasRules() const { return this->_rules.size() > 0; } void LILRootNode::addRule(std::shared_ptr<LILRule> value) { const auto & selChNode = value->getSelectorChain(); if (selChNode && selChNode->getNodeType() == NodeTypeSelectorChain) { const auto & selCh = std::static_pointer_cast<LILSelectorChain>(selChNode); const auto & selChNodes = selCh->getNodes(); if (selChNodes.size() == 1) { const auto & simpleSel = std::static_pointer_cast<LILSimpleSelector>(selChNodes.front()); const auto & simpleSelNodes = simpleSel->getNodes(); if (simpleSelNodes.size() == 1) { const auto & sel = std::static_pointer_cast<LILSelector>(simpleSelNodes.front()); if (sel->isA(SelectorTypeMainMenu)) { this->addNode(value); for (auto childRule : value->getChildRules()) { this->_mainMenu.push_back(childRule); } return; } } } } this->addNode(value); this->_rules.push_back(value); } const std::vector<std::shared_ptr<LILRule>> & LILRootNode::getRules() const { return this->_rules; } bool LILRootNode::hasMainMenu() const { return this->_mainMenu.size() > 0; } const std::vector<std::shared_ptr<LILNode>> & LILRootNode::getMainMenuItems() const { return this->_mainMenu; } void LILRootNode::clearMainMenuItems() { this->_mainMenu.clear(); } void LILRootNode::addConfigureInstr(const std::shared_ptr<LILInstruction> & instr) { this->_config.push_back(instr); } const std::vector<std::shared_ptr<LILNode>> & LILRootNode::getConfigure() const { return this->_config; }
27.380531
111
0.563995
veosotano
725c845dc80289814cd01786bf1351fed338c375
270
cpp
C++
with_python/extensions/pickling/main.cpp
MengqiYe/Test_Cpp_Standards
3acf52bd4457be007534b2b481f01a3bdfda0813
[ "MIT" ]
null
null
null
with_python/extensions/pickling/main.cpp
MengqiYe/Test_Cpp_Standards
3acf52bd4457be007534b2b481f01a3bdfda0813
[ "MIT" ]
null
null
null
with_python/extensions/pickling/main.cpp
MengqiYe/Test_Cpp_Standards
3acf52bd4457be007534b2b481f01a3bdfda0813
[ "MIT" ]
null
null
null
// // Created by mqye on 2020/12/7. // #include "p.h" namespace py = pybind11; int main() { std::vector<float> float_vector; float_vector.push_back(.1); float_vector.push_back(.2); float_vector.push_back(.3); auto a_tuple = py::make_tuple(float_vector); }
15.882353
46
0.681481
MengqiYe
725d29f662734cb2d88385e300892d020fef6f47
19,188
cpp
C++
src/db/core/inst.cpp
lbz007/rectanglequery
59d6eb007bf65480fa3e9245542d0b6071f81831
[ "BSD-3-Clause" ]
null
null
null
src/db/core/inst.cpp
lbz007/rectanglequery
59d6eb007bf65480fa3e9245542d0b6071f81831
[ "BSD-3-Clause" ]
null
null
null
src/db/core/inst.cpp
lbz007/rectanglequery
59d6eb007bf65480fa3e9245542d0b6071f81831
[ "BSD-3-Clause" ]
null
null
null
/* @file inst.cpp * @date <date> * @brief <Descriptions> * * Copyright (C) 2020 NIIC EDA * All rights reserved. * * This software may be modified and distributed under the terms * of the BSD license. See the LICENSE file for details. */ /** * @file inst.cpp * @date Apr 2020 */ #include "db/core/inst.h" #include "db/core/cell.h" #include "db/core/db.h" #include "db/core/pin.h" #include "db/util/array.h" #include "db/util/transform.h" namespace open_edi { namespace db { Inst::Inst() { has_eeq_master_ = false; has_source_ = false; has_mask_shift_ = false; has_halo_ = false; has_soft_ = false; has_route_halo_ = false; has_weight_ = false; has_region_ = false; has_property_ = false; name_index_ = 0; master_ = 0; pg_pins_ = 0; pins_ = 0; status_ = PlaceStatus::kUnknown; location_ = Point(0, 0); orient_ = Orient::kUnknown; eeq_master_ = 0; source_ = SourceType::kNetlist; for (int i = 0; i < max_layer_num; i++) { mask_shift_[i] = 0; } halo_ = Box(0, 0, 0, 0); route_halo_dist_ = 0; min_layer_id_ = -1; max_layer_id_ = -1; weight_ = 0; region_ = 0; } Inst::Inst(Inst const &rhs) { copy(rhs); } Inst::~Inst() { clear(); } Inst &Inst::operator=(Inst const &rhs) { if (this != &rhs) { copy(rhs); } return *this; } bool Inst::getHasEeqMaster() const { return has_eeq_master_; } void Inst::setHasEeqMaster(bool flag) { has_eeq_master_ = flag; } bool Inst::getHasSource() const { return has_source_; } void Inst::setHasSource(bool flag) { has_source_ = flag; } bool Inst::getHasMaskShift() const { return has_mask_shift_; } void Inst::setHasMaskShift(bool flag) { has_mask_shift_ = flag; } bool Inst::getHasHalo() const { return has_halo_; } void Inst::setHasHalo(bool flag) { has_halo_ = flag; } bool Inst::getHasSoft() const { return has_soft_; } void Inst::setHasSoft(bool flag) { has_soft_ = flag; } bool Inst::getHasRouteHalo() const { return has_route_halo_; } void Inst::setHasRouteHalo(bool flag) { has_route_halo_ = flag; } bool Inst::getHasWeight() const { return has_weight_; } void Inst::setHasWeight(bool flag) { has_weight_ = flag; } bool Inst::getHasRegion() const { return has_region_; } void Inst::setHasRegion(bool flag) { has_region_ = flag; } bool Inst::getHasProperty() const { return has_property_; } void Inst::setHasProperty(bool flag) { has_property_ = flag; } Box Inst::getBox() { Cell *cell = getMaster(); int llx = 0, lly = 0, urx = 0, ury = 0; int origin_x = 0, origin_y = 0, size_x = 0, size_y = 0; if (cell && cell->hasOrigin()) { origin_x = cell->getOriginX(); origin_y = cell->getOriginY(); } if (cell && cell->hasSize()) { size_x = cell->getSizeX(); size_y = cell->getSizeY(); } // size_x += origin_x; // size_y += origin_y; if (getOrient() == Orient::kN || getOrient() == Orient::kS || getOrient() == Orient::kFN || getOrient() == Orient::kFS) { llx = getLocation().getX(); lly = getLocation().getY(); urx = llx + size_x; ury = lly + size_y; } if (getOrient() == Orient::kW || getOrient() == Orient::kE || getOrient() == Orient::kFW || getOrient() == Orient::kFE) { llx = getLocation().getX(); lly = getLocation().getY(); urx = llx + size_y; ury = lly + size_x; } Box bbox(llx, lly, urx, ury); return bbox; } void Inst::setName(std::string name) { StorageUtil *storage_util = getStorageUtil(); ediAssert(storage_util != nullptr); SymbolTable *symtbl = storage_util->getSymbolTable(); ediAssert(symtbl != nullptr); name_index_ = symtbl->getOrCreateSymbol(name.c_str()); symtbl->addReference(name_index_, this->getId()); } std::string Inst::getName() const { StorageUtil *storage_util = getStorageUtil(); ediAssert(storage_util != nullptr); SymbolTable *symtbl = storage_util->getSymbolTable(); ediAssert(symtbl != nullptr); return symtbl->getSymbolByIndex(name_index_); } Cell *Inst::getMaster() const { return addr<Cell>(master_); } void Inst::setMaster(ObjectId master) { master_ = master; } void Inst::setMaster(const std::string name) { Cell *owner_cell = addr<Cell>(getOwnerId()); ediAssert(owner_cell != nullptr); Cell *master = owner_cell->getCell(name); if (master) { master_ = master->getId(); } else { message->issueMsg("DB", 21, kError, name.c_str(), getName().c_str()); } } UInt32 Inst::numPGPins() const { if (pg_pins_ == 0) { return 0; } ArrayObject<ObjectId> *pins_vector = addr<ArrayObject<ObjectId>>(pg_pins_); if (pins_vector == nullptr) { return 0; } return pins_vector->getSize(); } void Inst::setPGPins(ObjectId pg_pins) { pg_pins_ = pg_pins; } ObjectId Inst::getPGPins() const { return pg_pins_; } Pin *Inst::getPGPin(const std::string &name) const { if (pg_pins_ == 0) { return nullptr; } ArrayObject<ObjectId> *pins_vector = addr<ArrayObject<ObjectId>>(pg_pins_); if (pins_vector == nullptr) { return nullptr; } for (int i = 0; i < pins_vector->getSize(); i++) { ObjectId pin_id = (*pins_vector)[i]; Pin *pin = addr<Pin>(pin_id); if (pin && pin->getName() == name) { return pin; } } return nullptr; } void Inst::addPGPin(Pin *pin) { if (pg_pins_ == 0) { pg_pins_ = __createObjectIdArray(8); } ArrayObject<ObjectId> *pin_vector = addr<ArrayObject<ObjectId>>(pg_pins_); pin_vector->pushBack(pin->getId()); } UInt32 Inst::numPins() const { if (pins_ == 0) { return 0; } ArrayObject<ObjectId> *pins_vector = addr<ArrayObject<ObjectId>>(pins_); if (pins_vector == nullptr) { return 0; } return pins_vector->getSize(); } Pin *Inst::getPin(const std::string &name) const { if (pins_ == 0) { return nullptr; } ArrayObject<ObjectId> *pins_vector = addr<ArrayObject<ObjectId>>(pins_); if (pins_vector == nullptr) { return nullptr; } for (int i = 0; i < pins_vector->getSize(); i++) { ObjectId pin_id = (*pins_vector)[i]; Pin *pin = addr<Pin>(pin_id); if (pin && pin->getName() == name) { return pin; } } return nullptr; } ObjectId Inst::getPins() const { return pins_; } Pin *Inst::getPinById(ObjectId obj_id) const { if (obj_id == 0) { return nullptr; } return addr<Pin>(obj_id); } void Inst::addPin(Pin *pin) { if (pins_ == 0) { pins_ = __createObjectIdArray(8); } ArrayObject<ObjectId> *pin_vector = addr<ArrayObject<ObjectId>>(pins_); pin_vector->pushBack(pin->getId()); } void Inst::createPins() { Cell *master = getMaster(); if (!master) { return; } for (int i = 0; i < master->getNumOfTerms(); i++) { Term *term = master->getTerm(i); createInstancePin(term->getName()); // not handle return value, pin net // is attached in net parser } } Pin *Inst::createInstancePin(std::string &pin_name) { Cell *master = getMaster(); if (!master) { return nullptr; } Term *term = master->getTerm(pin_name); if (!term) { return nullptr; } Pin *pin = Object::createObject<Pin>(kObjectTypePin, getOwnerId()); pin->setName(pin_name); pin->setInst(this); pin->setTerm(term); ArrayObject<ObjectId> *pin_vector = nullptr; if (term->isPGType()) { if (pg_pins_ == 0) { pg_pins_ = __createObjectIdArray(8); } pin_vector = addr<ArrayObject<ObjectId>>(pg_pins_); } else { if (pins_ == 0) { pins_ = __createObjectIdArray(8); } pin_vector = addr<ArrayObject<ObjectId>>(pins_); } pin_vector->pushBack(pin->getId()); return pin; } Pin *Inst::createInstancePinWithoutMaster(std::string &pin_name) { Pin *pin = Object::createObject<Pin>(kObjectTypePin, getOwnerId()); pin->setName(pin_name); pin->setInst(this); ArrayObject<ObjectId> *pin_vector = nullptr; if (pins_ == 0) { pins_ = __createObjectIdArray(8); } pin_vector = Object::addr<ArrayObject<ObjectId>>(pins_); pin_vector->pushBack(pin->getId()); return pin; } PlaceStatus Inst::getStatus() const { return status_; } void Inst::setStatus(const PlaceStatus &s) { status_ = s; } Point Inst::getLocation() const { return location_; } void Inst::setLocation(const Point &l) { location_ = l; } Orient Inst::getOrient() const { return orient_; } void Inst::setOrient(const Orient &o) { orient_ = o; } SourceType Inst::getSource() const { return source_; } void Inst::setSource(const SourceType &s) { source_ = s; } Cell *Inst::getEeqMaster() const { return addr<Cell>(eeq_master_); } void Inst::setEeqMaster(const std::string &name) { Cell *owner_cell = addr<Cell>(getOwnerId()); ediAssert(owner_cell != nullptr); Cell *cell = owner_cell->getCell(name); if (cell) { eeq_master_ = cell->getId(); } } UInt32 Inst::getMaskShift(Int32 layer_id) const { return mask_shift_[layer_id]; } void Inst::setMaskShift(UInt32 m, Int32 layer_id) { mask_shift_[layer_id] = m; } Box Inst::getHalo() const { return halo_; } void Inst::setHalo(const Box &halo) { halo_ = halo; } UInt32 Inst::getRouteHaloDist() const { return route_halo_dist_; } void Inst::setRouteHaloDist(const UInt32 &d) { route_halo_dist_ = d; } Int32 Inst::getMinLayerId() const { return min_layer_id_; } void Inst::setMinLayer(std::string name) { min_layer_id_ = getTechLib()->getLayerLEFIndexByName(name.c_str()); } Int32 Inst::getMaxLayerId() const { return max_layer_id_; } void Inst::setMaxLayer(std::string name) { max_layer_id_ = getTechLib()->getLayerLEFIndexByName(name.c_str()); } Int32 Inst::getWeight() const { return weight_; } void Inst::setWeight(const Int32 &w) { weight_ = w; } Constraint *Inst::getRegion() const { return addr<Constraint>(region_); } void Inst::setRegion(std::string &name) { Cell *owner_cell = addr<Cell>(getOwnerId()); ediAssert(owner_cell != nullptr); Constraint *region = owner_cell->getFloorplan()->getRegion(name); if (region) { region_ = region->getId(); } } void Inst::copy(Inst const &rhs) { has_eeq_master_ = rhs.has_eeq_master_; has_source_ = rhs.has_source_; has_mask_shift_ = rhs.has_mask_shift_; has_halo_ = rhs.has_halo_; has_soft_ = rhs.has_soft_; has_route_halo_ = rhs.has_route_halo_; has_weight_ = rhs.has_weight_; has_region_ = rhs.has_region_; has_property_ = rhs.has_property_; name_index_ = rhs.name_index_; master_ = rhs.master_; if (rhs.pg_pins_ == 0) { pg_pins_ = 0; } ArrayObject<ObjectId> *rhs_pg_pins_vector = addr<ArrayObject<ObjectId>>(rhs.pg_pins_); if (rhs_pg_pins_vector == nullptr) { pg_pins_ = 0; } pg_pins_ = __createObjectIdArray(8); ArrayObject<ObjectId> *new_pg_pin_vector = addr<ArrayObject<ObjectId>>(pg_pins_); for (int i = 0; i < rhs_pg_pins_vector->getSize(); i++) { ObjectId pin_id = (*rhs_pg_pins_vector)[i]; Pin *pin = addr<Pin>(pin_id); new_pg_pin_vector->pushBack(pin->getId()); } if (rhs.pins_ == 0) { pins_ = 0; } ArrayObject<ObjectId> *rhs_pins_vector = addr<ArrayObject<ObjectId>>(rhs.pins_); if (rhs_pins_vector == nullptr) { pins_ = 0; } pins_ = __createObjectIdArray(8); ArrayObject<ObjectId> *new_pin_vector = addr<ArrayObject<ObjectId>>(pins_); for (int i = 0; i < rhs_pins_vector->getSize(); i++) { ObjectId pin_id = (*rhs_pins_vector)[i]; Pin *pin = addr<Pin>(pin_id); new_pin_vector->pushBack(pin->getId()); } location_ = rhs.location_; orient_ = rhs.orient_; eeq_master_ = rhs.eeq_master_; source_ = rhs.source_; for (int i = 0; i < max_layer_num; i++) { mask_shift_[i] = rhs.getMaskShift(i); } halo_ = rhs.halo_; route_halo_dist_ = rhs.route_halo_dist_; min_layer_id_ = rhs.min_layer_id_; max_layer_id_ = rhs.max_layer_id_; weight_ = rhs.weight_; region_ = rhs.region_; } void Inst::move(Inst &&rhs) { // TODO. } ArrayObject<ObjectId> *Inst::getPinArray() const { if (pins_ != 0) { ArrayObject<ObjectId> *pin_array = addr<ArrayObject<ObjectId>>(pins_); return pin_array; } else { return nullptr; } } ArrayObject<ObjectId> *Inst::getPGPinArray() const { if (pg_pins_ != 0) { ArrayObject<ObjectId> *pg_pin_array = addr<ArrayObject<ObjectId>>(pg_pins_); return pg_pin_array; } else { return nullptr; } } /// @brief To check whether an instance is flatten from hierarchical representation /// bool Inst::isFlattenInst() const { std::string name = getName(); if (name.find("/") != std::string::npos) { if (getOwnerId() == getTopCell()->getId()) { return true; } } return false; } void Inst::clear() { //clear pg pins: ArrayObject<ObjectId> *id_array = getPGPinArray(); if (id_array != nullptr) { for (ArrayObject<ObjectId>::iterator iter = id_array->begin(); iter != id_array->end(); ++iter) { if (*iter == 0) continue; //invalid pin id. Pin *pin = addr<Pin>(*iter); Object::destroyObject<Pin>(pin); } } __destroyObjectIdArray(pg_pins_); //clear pins: id_array = getPinArray(); if (id_array != nullptr) { for (ArrayObject<ObjectId>::iterator iter = id_array->begin(); iter != id_array->end(); ++iter) { if (*iter == 0) continue; //invalid pin id. Pin *pin = addr<Pin>(*iter); Object::destroyObject<Pin>(pin); } } __destroyObjectIdArray(pins_); //TODO: if master != 0, decr master's ref_count. } void Inst::printPinGeoms() { ObjectId pins = getPins(); ArrayObject<ObjectId> *pins_vector = addr<ArrayObject<ObjectId>>(pins); std::vector<Box> box_vector; for (int j = 0; pins_vector && j < pins_vector->getSize(); j++) { ObjectId pin_id = (*pins_vector)[j]; Pin *pin = addr<Pin>(pin_id); if (!pin) { continue; } std::cout << "DEBUG_transform: " << getName() << "/" << pin->getName() << std::endl; pin->getBoxVector(box_vector); for (int index = 0; index < box_vector.size(); ++index) { std::cout << "Box#" << index << " ( " << box_vector[index].getLLX() << " " << box_vector[index].getLLY() << " " << box_vector[index].getURX() << " " << box_vector[index].getURY() << " )." << std::endl; } box_vector.clear(); } } void Inst::print(IOManager &io_manager) { Cell *cell = getMaster(); if (!cell) { message->issueMsg("DB", 22, kError, getName().c_str()); return; } io_manager.write("- %s %s", getName().c_str(), cell->getName().c_str()); if (getHasEeqMaster()) { Cell *eeq_cell = getEeqMaster(); if (!eeq_cell) { message->issueMsg("DB", 23, kError, getName().c_str()); return; } io_manager.write("\n + EEQMASTER %s", eeq_cell->getName().c_str()); } if (getHasSource()) { io_manager.write("\n + SOURCE %s", toString(source_).c_str()); } if ((getStatus() == PlaceStatus::kFixed) || (getStatus() == PlaceStatus::kCover) || (getStatus() == PlaceStatus::kPlaced)) { std::string status_string = toString(getStatus()); toUpper(status_string); io_manager.write("\n + %s", status_string.c_str()); Point point = getLocation(); Orient orient = getOrient(); io_manager.write(" ( %d %d ) %s", point.getX(), point.getY(), toString(orient).c_str()); } if (getStatus() == PlaceStatus::kUnplaced) { io_manager.write("\n + UNPLACED"); } if (getHasMaskShift()) { Cell *owner_cell = addr<Cell>(getOwnerId()); ediAssert(owner_cell != nullptr); int num_mask_shift_layers = owner_cell->getNumMaskShiftLayers(); io_manager.write("\n + MASKSHIFT "); for (int i = 0; i < num_mask_shift_layers; ++i) { io_manager.write("%x", getMaskShift(i)); } } if (getHasHalo()) { io_manager.write("\n + HALO"); if (getHasSoft()) { io_manager.write(" SOFT"); Box box = getHalo(); io_manager.write(" %d %d %d %d", box.getLLX(), box.getLLY(), box.getURX(), box.getURY()); } } if (getHasRouteHalo()) { Layer *min_layer = cell->getLayerByLayerId(getMinLayerId()); Layer *max_layer = cell->getLayerByLayerId(getMaxLayerId()); io_manager.write("\n + ROUTEHALO %d %s %s", getRouteHaloDist(), min_layer->getName(), max_layer->getName()); } if (getHasWeight()) { io_manager.write("\n + WEIGHT %d", getWeight()); } if (getHasRegion()) { io_manager.write("\n + REGION %s", getRegion()->getName().c_str()); } Cell *top_cell = getTopCell(); if (top_cell) { PropertyManager* table = top_cell->getPropertyManager(); std::vector<std::string> properties; table->getSparsePropertyList<Inst>(this, properties); if (properties.size() > 0) { for(int i = 0; i < properties.size(); i++) { Property* prop = table->getSparseProperty<Inst>(this, properties.at(i).c_str()); prop->printDEF(io_manager); } } } io_manager.write(" ;\n"); } OStreamBase &operator<<(OStreamBase &os, Inst const &rhs) { os << DataTypeName(className(rhs)) << DataBegin("("); os << DataFieldName("cell_"); if (rhs.owner_) { os << rhs.owner_; } else { os << UNINIT_OBJECT_ID; } os << DataDelimiter(); os << rhs.numPins(); os << DataBegin("["); auto delimiter = DataDelimiter(""); os << DataEnd("]") << DataDelimiter(); os << DataEnd(")"); return os; } IStreamBase &operator>>(IStreamBase &is, Inst &rhs) { is >> DataTypeName(className(rhs)) >> DataBegin("("); auto context = is.getContext(); // add current context to Inst is.addContext(&rhs); // read cell_ auto &db = is.getDb(); InstAttr::IndexType cell_id; is >> DataFieldName("cell_") >> cell_id >> DataDelimiter(); if (cell_id == 0) { rhs.owner_ = 0; } else { /* remove-database rhs.cell_ = db.getCell(cell_id); */ } Inst::IndexType size; is >> size; is >> DataBegin("["); auto delimiter = DataDelimiter(""); is >> DataEnd("]") >> DataDelimiter(); // pop current context is.popContext(); is >> DataEnd(")"); return is; } } // namespace db } // namespace open_edi
28.724551
96
0.59605
lbz007
725fa44d04ba00d9e9cf81419465ba9ff93feb8d
1,985
hpp
C++
shadow/algorithm/detect_mtcnn.hpp
junluan/shadow
067d1c51d7c38bc1c985008a2e2e1599bbf11a8c
[ "Apache-2.0" ]
20
2017-07-04T11:22:47.000Z
2022-01-16T03:58:32.000Z
shadow/algorithm/detect_mtcnn.hpp
junluan/shadow
067d1c51d7c38bc1c985008a2e2e1599bbf11a8c
[ "Apache-2.0" ]
2
2017-12-03T13:07:39.000Z
2021-01-13T11:11:52.000Z
shadow/algorithm/detect_mtcnn.hpp
junluan/shadow
067d1c51d7c38bc1c985008a2e2e1599bbf11a8c
[ "Apache-2.0" ]
10
2017-09-30T05:06:30.000Z
2020-11-13T05:43:44.000Z
#ifndef SHADOW_ALGORITHM_DETECT_MTCNN_HPP_ #define SHADOW_ALGORITHM_DETECT_MTCNN_HPP_ #include "method.hpp" #include "core/network.hpp" namespace Shadow { struct BoxInfo { BoxF box; float box_reg[4], landmark[10]; }; using VecBoxInfo = std::vector<BoxInfo>; class DetectMTCNN final : public Method { public: DetectMTCNN() = default; void Setup(const std::string& model_file) override; void Predict(const cv::Mat& im_mat, const RectF& roi, VecBoxF* boxes, std::vector<VecPointF>* Gpoints) override; private: void Process_net_p(const float* data, const VecInt& in_shape, float threshold, float scale, VecBoxInfo* boxes); void Process_net_r(const float* data, const VecInt& in_shape, float threshold, const VecBoxInfo& net_12_boxes, VecBoxInfo* boxes); void Process_net_o(const float* data, const VecInt& in_shape, float threshold, const VecBoxInfo& net_24_boxes, VecBoxInfo* boxes); void CalculateScales(float height, float width, float factor, float max_side, float min_side, VecFloat* scales); void BoxRegression(VecBoxInfo& boxes); void Box2SquareWithConstrain(VecBoxInfo& boxes, float height, float width); void BoxWithConstrain(VecBoxInfo& boxes, float height, float width); Network net_p_, net_r_, net_o_; VecFloat net_p_in_data_, net_r_in_data_, net_o_in_data_, thresholds_, scales_; VecInt net_p_in_shape_, net_r_in_shape_, net_o_in_shape_; VecBoxInfo net_p_boxes_, net_r_boxes_, net_o_boxes_; std::string in_p_str_, in_r_str_, in_o_str_, net_p_conv4_2_, net_p_prob1_, net_r_conv5_2_, net_r_prob1_, net_o_conv6_2_, net_o_conv6_3_, net_o_prob1_; int net_p_stride_, net_p_cell_size_; int net_r_in_c_, net_r_in_h_, net_r_in_w_, net_r_in_num_; int net_o_in_c_, net_o_in_h_, net_o_in_w_, net_o_in_num_; float factor_, max_side_, min_side_; }; } // namespace Shadow #endif // SHADOW_ALGORITHM_DETECT_MTCNN_HPP_
34.224138
80
0.741058
junluan
7260b0ae81ff011f6d102433ad97a9994ca8e885
4,068
cpp
C++
modules/physics/bullet/src/components/rigidbody.cpp
weblate/thunder
e9b741b7f23e18cea79cee964c8a62ed9248fbf2
[ "Apache-2.0" ]
1
2022-03-20T16:13:53.000Z
2022-03-20T16:13:53.000Z
modules/physics/bullet/src/components/rigidbody.cpp
weblate/thunder
e9b741b7f23e18cea79cee964c8a62ed9248fbf2
[ "Apache-2.0" ]
null
null
null
modules/physics/bullet/src/components/rigidbody.cpp
weblate/thunder
e9b741b7f23e18cea79cee964c8a62ed9248fbf2
[ "Apache-2.0" ]
null
null
null
#include "components/rigidbody.h" #include <components/actor.h> #include <components/transform.h> #include "components/volumecollider.h" #include "resources/physicmaterial.h" RigidBody::RigidBody() : m_Mass(1.0f), m_LockPosition(0), m_LockRotation(0) { } RigidBody::~RigidBody() { if(m_pWorld) { m_pWorld->removeRigidBody(static_cast<btRigidBody *>(m_pCollisionObject)); } } float RigidBody::mass() const { return m_Mass; } void RigidBody::setMass(float mass) { m_Mass = mass; if(m_pCollisionObject) { bool dynamic = (m_Mass != 0.0f); btVector3 localInertia(0, 0, 0); if(dynamic) { m_pCollisionShape->calculateLocalInertia(m_Mass, localInertia); } static_cast<btRigidBody *>(m_pCollisionObject)->setMassProps(m_Mass, localInertia); } } void RigidBody::applyForce(const Vector3 &force, const Vector3 &point) { static_cast<btRigidBody *>(m_pCollisionObject)->applyForce(btVector3(force.x, force.y, force.z), btVector3(point.x, point.y, point.z)); } void RigidBody::applyImpulse(const Vector3 &impulse, const Vector3 &point) { m_pCollisionObject->activate(true); static_cast<btRigidBody *>(m_pCollisionObject)->applyImpulse(btVector3(impulse.x, impulse.y, impulse.z), btVector3(point.x, point.y, point.z)); } int RigidBody::lockPosition() const { return m_LockPosition; } void RigidBody::setLockPosition(int flags) { m_LockPosition = flags; } int RigidBody::lockRotation() const { return m_LockRotation; } void RigidBody::setLockRotation(int flags) { m_LockRotation = flags; } void RigidBody::getWorldTransform(btTransform &worldTrans) const { Actor *a = actor(); if(a) { Transform *t = a->transform(); const Quaternion &q = t->rotation(); Vector3 p = t->position(); worldTrans.setRotation(btQuaternion(q.x, q.y, q.z, q.w)); worldTrans.setOrigin(btVector3(p.x, p.y, p.z)); } } void RigidBody::setWorldTransform(const btTransform &worldTrans) { Actor *a = actor(); if(a) { Transform *t = a->transform(); btQuaternion q = worldTrans.getRotation(); Quaternion rot; rot.x = q.getX(); rot.y = q.getY(); rot.z = q.getZ(); rot.w = q.getW(); t->setRotation(rot); btVector3 p = worldTrans.getOrigin(); t->setPosition(Vector3(p.x(), p.y(), p.z())); } } void RigidBody::createCollider() { btCompoundShape *compound = new btCompoundShape; PhysicMaterial *mat = nullptr; for(auto &it : actor()->findChildren<VolumeCollider *>(false)) { if(!it->trigger()) { btTransform transform; transform.setIdentity(); transform.setOrigin(btVector3(0, 0, 0)); compound->addChildShape(transform, it->shape()); if(mat == nullptr) { mat = it->material(); } } } m_pCollisionShape = compound; btRigidBody *body = new btRigidBody(m_Mass, this, m_pCollisionShape); body->setCollisionShape(m_pCollisionShape); body->setUserPointer(this); body->setLinearFactor(btVector3((m_LockPosition & AXIS_X) ? 0.0 : 1.0, (m_LockPosition & AXIS_Y) ? 0.0 : 1.0, (m_LockPosition & AXIS_Z) ? 0.0 : 1.0)); body->setAngularFactor(btVector3((m_LockRotation & AXIS_X) ? 0.0 : 1.0, (m_LockRotation & AXIS_Y) ? 0.0 : 1.0, (m_LockRotation & AXIS_Z) ? 0.0 : 1.0)); m_pCollisionObject = body; float mass = m_Mass; if(mat) { body->setFriction(mat->friction()); body->setRestitution(mat->restitution()); mass *= mat->density(); } setMass(mass); if(m_pCollisionObject) { m_pWorld->addRigidBody(static_cast<btRigidBody *>(m_pCollisionObject)); } }
28.851064
108
0.592183
weblate
7268cb408e412a14a2f92ad2999469cedda1957d
1,701
cc
C++
oflog/libsrc/lloguser.cc
jcfr/DCMTK
0e42647975cb5e2d00e0ee0c5aba635f0f1db181
[ "BSD-3-Clause" ]
null
null
null
oflog/libsrc/lloguser.cc
jcfr/DCMTK
0e42647975cb5e2d00e0ee0c5aba635f0f1db181
[ "BSD-3-Clause" ]
null
null
null
oflog/libsrc/lloguser.cc
jcfr/DCMTK
0e42647975cb5e2d00e0ee0c5aba635f0f1db181
[ "BSD-3-Clause" ]
null
null
null
// Module: Log4CPLUS // File: logloguser.cxx // Created: 6/2003 // Author: Tad E. Smith // // // Copyright (C) Tad E. Smith All rights reserved. // // This software is published under the terms of the Apache Software // License version 1.1, a copy of which has been included with this // distribution in the LICENSE.APL file. // #include "dcmtk/oflog/streams.h" #include "dcmtk/oflog/helpers/lloguser.h" #include "dcmtk/oflog/helpers/loglog.h" using namespace std; using namespace log4cplus; using namespace log4cplus::helpers; typedef SharedObjectPtr<LogLog> LogLogPtr; /////////////////////////////////////////////////////////////////////////////// // log4cplus::helpers::LogLogUser ctor and dtor /////////////////////////////////////////////////////////////////////////////// LogLogUser::LogLogUser() { loglogRef = new SharedObjectPtr<LogLog>(LogLog::getLogLog()); } LogLogUser::LogLogUser(const LogLogUser& rhs) { loglogRef = new SharedObjectPtr<LogLog>(*static_cast<LogLogPtr*>(rhs.loglogRef)); } LogLogUser::~LogLogUser() { delete static_cast<LogLogPtr*>(loglogRef); } /////////////////////////////////////////////////////////////////////////////// // log4cplus::helpers::LogLogUser public methods /////////////////////////////////////////////////////////////////////////////// LogLog& LogLogUser::getLogLog() const { LogLogPtr* ptr = static_cast<LogLogPtr*>(loglogRef); return **ptr; } LogLogUser& LogLogUser::operator=(const LogLogUser& rhs) { if(this == &rhs) { return *this; } delete static_cast<LogLogPtr*>(loglogRef); loglogRef = new SharedObjectPtr<LogLog>(*static_cast<LogLogPtr*>(rhs.loglogRef)); return *this; }
23.30137
85
0.579071
jcfr
72690fe5b0e4f61eae99f3f881d26987ff38599f
10,025
cpp
C++
seepage_flows/src/seepageflow/main.cpp
RaymondMcGuire/sph_seepage_flows
2b135a609abaca4cf02e0538b2818db21478f3f3
[ "MIT" ]
2
2021-10-02T15:23:27.000Z
2022-03-14T07:16:58.000Z
seepage_flows/src/seepageflow/main.cpp
RaymondMcGuire/sph_seepage_flows
2b135a609abaca4cf02e0538b2818db21478f3f3
[ "MIT" ]
null
null
null
seepage_flows/src/seepageflow/main.cpp
RaymondMcGuire/sph_seepage_flows
2b135a609abaca4cf02e0538b2818db21478f3f3
[ "MIT" ]
null
null
null
/*** * @Author: Xu.WANG * @Date: 2020-10-27 00:49:33 * @LastEditTime: 2021-08-27 23:50:13 * @LastEditors: Xu.WANG * @Description: * @FilePath: \sph_seepage_flows\seepage_flows\src\seepageflow\main.cpp */ #include <sf_cuda_define.h> #include <kiri_utils.h> using namespace KIRI; // global params const UInt RunLiquidNumber = 0; const UInt TotalFrameNumber = 300; UInt SimCount = 0; float TotalFrameTime = 0.f; float RenderInterval = 1.f / 30.f; KiriTimer PerFrameTimer; CudaSFSystemPtr SFSystem; void SetupParams() { KIRI_LOG_DEBUG("Seepageflow: SetupParams"); strcpy(CUDA_SEEPAGEFLOW_APP_PARAMS.bgeo_export_folder, (String(EXPORT_PATH) + "bgeo/seepageflow_bunny_wcsph").c_str()); // scene config auto cuda_lowest_point = make_float3(0.f); auto cuda_highest_point = make_float3(1.5f, 1.5f, 2.5f); auto cuda_world_size = cuda_highest_point - cuda_lowest_point; auto cuda_world_center = (cuda_highest_point + cuda_lowest_point) / 2.f; CUDA_SEEPAGEFLOW_APP_PARAMS.max_num = 500000; // sph params CUDA_SEEPAGEFLOW_PARAMS.sph_density = 1000.f; CUDA_SEEPAGEFLOW_PARAMS.sph_particle_radius = 0.01f; CUDA_SEEPAGEFLOW_PARAMS.sph_kernel_radius = 4.f * CUDA_SEEPAGEFLOW_PARAMS.sph_particle_radius; auto diam = 2.f * CUDA_SEEPAGEFLOW_PARAMS.sph_particle_radius; CUDA_SEEPAGEFLOW_PARAMS.sph_mass = 0.8f * diam * diam * diam * CUDA_SEEPAGEFLOW_PARAMS.sph_density; auto visc = 0.05f; auto sound_speed = 100.f; auto nu = (visc + visc) * CUDA_SEEPAGEFLOW_PARAMS.sph_kernel_radius * sound_speed; auto boundary_friction = 0.2f; auto bnu = boundary_friction * CUDA_SEEPAGEFLOW_PARAMS.sph_kernel_radius * sound_speed; CUDA_SEEPAGEFLOW_PARAMS.sph_stiff = 0.001f * sound_speed * sound_speed * CUDA_SEEPAGEFLOW_PARAMS.sph_density / 7.f; CUDA_SEEPAGEFLOW_PARAMS.sph_visc = visc; CUDA_SEEPAGEFLOW_PARAMS.sph_nu = nu; CUDA_SEEPAGEFLOW_PARAMS.sph_bnu = bnu; // dem params CUDA_SEEPAGEFLOW_PARAMS.dem_density = 2700.f; CUDA_SEEPAGEFLOW_PARAMS.dem_particle_radius = 0.005f; CUDA_SEEPAGEFLOW_PARAMS.dem_mass = CUDA_SEEPAGEFLOW_PARAMS.dem_density * ((4.f / 3.f) * 3.1415926f * std::powf(CUDA_SEEPAGEFLOW_PARAMS.dem_particle_radius, 3.f)); CUDA_SEEPAGEFLOW_PARAMS.dem_young = 1e5f; CUDA_SEEPAGEFLOW_PARAMS.dem_poisson = 0.3f; CUDA_SEEPAGEFLOW_PARAMS.dem_tan_friction_angle = 0.5f; CUDA_SEEPAGEFLOW_PARAMS.dem_damping = 0.4f; CUDA_SEEPAGEFLOW_PARAMS.sf_c0 = 0.7f; CUDA_SEEPAGEFLOW_PARAMS.sf_cd = 0.5f; CUDA_SEEPAGEFLOW_PARAMS.sf_csat = 0.f; CUDA_SEEPAGEFLOW_PARAMS.sf_cmc = 1.f; CUDA_SEEPAGEFLOW_PARAMS.sf_cmc_p = 0.01f; CUDA_SEEPAGEFLOW_PARAMS.sf_a0 = 0.f; CUDA_SEEPAGEFLOW_PARAMS.sf_asat = 0.8f; CUDA_SEEPAGEFLOW_PARAMS.sf_amc = 1.5f; CUDA_SEEPAGEFLOW_PARAMS.sf_amc_p = 0.5f; CUDA_SEEPAGEFLOW_PARAMS.sf_dry_sand_color = make_float3(0.88f, 0.79552f, 0.5984f); CUDA_SEEPAGEFLOW_PARAMS.sf_wet_sand_color = make_float3(0.38f, 0.29f, 0.14f); CUDA_SEEPAGEFLOW_PARAMS.dt = 0.5f * CUDA_SEEPAGEFLOW_PARAMS.dem_particle_radius / std::sqrtf(CUDA_SEEPAGEFLOW_PARAMS.dem_young / CUDA_SEEPAGEFLOW_PARAMS.dem_density); CUDA_SEEPAGEFLOW_PARAMS.gravity = make_float3(0.0f, -9.8f, 0.0f); // sph emitter CUDA_SPH_EMITTER_PARAMS.enable = true; CUDA_SPH_EMITTER_PARAMS.run = false; CUDA_SPH_EMITTER_PARAMS.emit_pos = make_float3(cuda_world_center.x + cuda_world_size.x / 10.f, cuda_world_center.y + cuda_world_size.y / 5.f, cuda_world_center.z + cuda_world_size.z / 2.3f); CUDA_SPH_EMITTER_PARAMS.emit_vel = make_float3(0.f, 0.f, -5.f); CUDA_SPH_EMITTER_PARAMS.emit_col = make_float3(127.f, 205.f, 255.f) / 255.f; CUDA_SPH_EMITTER_PARAMS.emit_radius = 0.17f; CUDA_SPH_EMITTER_PARAMS.emit_width = 0.22f; CUDA_SPH_EMITTER_PARAMS.emit_height = 0.18f; CUDA_SPH_EMITTER_PARAMS.emit_type = CudaSphEmitterType::CIRCLE; // scene data CUDA_BOUNDARY_PARAMS.lowest_point = cuda_lowest_point; CUDA_BOUNDARY_PARAMS.highest_point = cuda_highest_point; CUDA_BOUNDARY_PARAMS.world_size = cuda_world_size; CUDA_BOUNDARY_PARAMS.world_center = cuda_world_center; CUDA_BOUNDARY_PARAMS.kernel_radius = CUDA_SEEPAGEFLOW_PARAMS.sph_kernel_radius; CUDA_BOUNDARY_PARAMS.grid_size = make_int3((CUDA_BOUNDARY_PARAMS.highest_point - CUDA_BOUNDARY_PARAMS.lowest_point) / CUDA_BOUNDARY_PARAMS.kernel_radius); // init emitter CudaEmitterPtr emitter = std::make_shared<CudaEmitter>( CUDA_SPH_EMITTER_PARAMS.emit_pos, CUDA_SPH_EMITTER_PARAMS.emit_vel, CUDA_SPH_EMITTER_PARAMS.enable); // boundary sampling BoundaryData boundaryData; auto boundaryEmitter = std::make_shared<CudaBoundaryEmitter>(); boundaryEmitter->BuildWorldBoundary(boundaryData, CUDA_BOUNDARY_PARAMS.lowest_point, CUDA_BOUNDARY_PARAMS.highest_point, CUDA_SEEPAGEFLOW_PARAMS.sph_particle_radius); // shape sampling SeepageflowVolumeData volumeData; auto volumeEmitter = std::make_shared<CudaVolumeEmitter>(); Vec_String shape_folders, shape_files; shape_folders.emplace_back("bunny"); shape_files.emplace_back("bunny"); auto sandShapes = ReadMultiBgeoFilesForGPU(shape_folders, shape_files); volumeEmitter->BuildSeepageflowShapeVolume( volumeData, sandShapes, CUDA_SEEPAGEFLOW_PARAMS.sf_dry_sand_color, CUDA_SEEPAGEFLOW_PARAMS.dem_density, true, CUDA_BOUNDARY_PARAMS.lowest_point.y); // dt CUDA_SEEPAGEFLOW_PARAMS.dem_particle_radius = volumeData.sandMinRadius; CUDA_SEEPAGEFLOW_PARAMS.dt = 0.5f * volumeData.sandMinRadius / std::sqrtf(CUDA_SEEPAGEFLOW_PARAMS.dem_young / CUDA_SEEPAGEFLOW_PARAMS.dem_density); KIRI_LOG_INFO("Number of total particles = {0}, dt={1}", volumeData.pos.size(), CUDA_SEEPAGEFLOW_PARAMS.dt); // spatial searcher & particles CudaSFParticlesPtr particles; particles = std::make_shared<CudaSFParticles>( CUDA_SEEPAGEFLOW_APP_PARAMS.max_num, volumeData.pos, volumeData.col, volumeData.label, volumeData.mass, volumeData.radius); CudaGNSearcherPtr searcher; searcher = std::make_shared<CudaGNSearcher>( CUDA_BOUNDARY_PARAMS.lowest_point, CUDA_BOUNDARY_PARAMS.highest_point, particles->MaxSize(), CUDA_BOUNDARY_PARAMS.kernel_radius, SearcherParticleType::SEEPAGE); auto boundary_particles = std::make_shared<CudaBoundaryParticles>(boundaryData.pos, boundaryData.label); KIRI_LOG_INFO("Number of Boundary Particles = {0}", boundary_particles->Size()); // wcsph bool adaptive_sub_timestep = true; CudaSphSFSolverPtr pSolver; pSolver = std::make_shared<CudaWCSphSFSolver>( particles->MaxSize()); CUDA_SEEPAGEFLOW_PARAMS.solver_type = WCSPH_SOLVER; KIRI_LOG_INFO("Current Fluid Solver= WCSPH"); // bgeo file export & render FPS CUDA_SEEPAGEFLOW_APP_PARAMS.bgeo_export = true; CudaGNBoundarySearcherPtr boundary_searcher = std::make_shared<CudaGNBoundarySearcher>( CUDA_BOUNDARY_PARAMS.lowest_point, CUDA_BOUNDARY_PARAMS.highest_point, boundary_particles->MaxSize(), CUDA_BOUNDARY_PARAMS.kernel_radius); SFSystem = std::make_shared<CudaSFSystem>( particles, boundary_particles, pSolver, searcher, boundary_searcher, emitter, adaptive_sub_timestep); } void Update() { if (CUDA_SEEPAGEFLOW_APP_PARAMS.run && SimCount < TotalFrameNumber + RunLiquidNumber) { if (SimCount == RunLiquidNumber) { // export bgeo file CUDA_SEEPAGEFLOW_APP_PARAMS.bgeo_export = CUDA_SEEPAGEFLOW_APP_PARAMS.run; if (CUDA_SPH_EMITTER_PARAMS.enable) CUDA_SPH_EMITTER_PARAMS.run = CUDA_SEEPAGEFLOW_APP_PARAMS.run; } if (SFSystem->GetAdaptiveSubTimeStep()) { float remaining_time = RenderInterval; KIRI_LOG_INFO("Simulation Frame={0}, Adaptive Sub-Simulation", ++SimCount); PerFrameTimer.Restart(); size_t i = 0; while (remaining_time > KIRI_EPSILON) { KIRI_LOG_INFO("Current Sub-Simulation RemainTime={0},Sub-Simulation Step={1}", remaining_time, ++i); SFSystem->UpdateSystem(remaining_time); remaining_time -= remaining_time / static_cast<float>(SFSystem->GetNumOfSubTimeSteps()); } } else { auto numOfSubTimeSteps = SFSystem->GetNumOfSubTimeSteps(); KIRI_LOG_INFO("Simulation Frame={0}, Sub-Simulation Total Number={1}", ++SimCount, numOfSubTimeSteps); PerFrameTimer.Restart(); for (size_t i = 0; i < numOfSubTimeSteps; i++) { KIRI_LOG_INFO("Current Sub-Simulation/ Total Number ={0}/{1}", i + 1, numOfSubTimeSteps); SFSystem->UpdateSystem(RenderInterval); } } KIRI_LOG_INFO("Time Per Frame={0}", PerFrameTimer.Elapsed()); TotalFrameTime += PerFrameTimer.Elapsed(); if (CUDA_SEEPAGEFLOW_APP_PARAMS.bgeo_export) { auto particles = SFSystem->GetSFParticles(); ExportBgeoFileCUDA( CUDA_SEEPAGEFLOW_APP_PARAMS.bgeo_export_folder, UInt2Str4Digit(SimCount - RunLiquidNumber), particles->GetPosPtr(), particles->GetColPtr(), particles->GetRadiusPtr(), particles->GetLabelPtr(), particles->Size()); } } else if (CUDA_SEEPAGEFLOW_APP_PARAMS.run) { CUDA_SEEPAGEFLOW_APP_PARAMS.run = false; KIRI_LOG_INFO("Average Per Frame={0}", TotalFrameTime / (TotalFrameNumber + RunLiquidNumber)); } } void main() { KiriLog::Init(); SetupParams(); CUDA_SEEPAGEFLOW_APP_PARAMS.run = true; while (CUDA_SEEPAGEFLOW_APP_PARAMS.run) Update(); return; }
37.973485
194
0.70813
RaymondMcGuire
726927b926bc4174acea00bd8f90d18b7fb02ad8
4,669
cpp
C++
common/src/keyfile/LicenceeInfo.cpp
waddlesplash/WonderBrush-v2
df20b6a43115d02e4606c71f27d0712ac2aebb62
[ "MIT" ]
null
null
null
common/src/keyfile/LicenceeInfo.cpp
waddlesplash/WonderBrush-v2
df20b6a43115d02e4606c71f27d0712ac2aebb62
[ "MIT" ]
null
null
null
common/src/keyfile/LicenceeInfo.cpp
waddlesplash/WonderBrush-v2
df20b6a43115d02e4606c71f27d0712ac2aebb62
[ "MIT" ]
null
null
null
// LicenceeInfo.cpp #include <cstdio> #include <Message.h> #include "TimeSupport.h" #include "LicenceeInfo.h" // constants for default values const char* const kDefaultName = "no name"; const char* const kDefaultApplicationID = "no application"; const uint32 kDefaultApplicationVersion = 0; const bigtime_t kDefaultRegistrationTime = 0; const bigtime_t kDefaultExpirationTime = 0; const int32 kDefaultLicenseType = 0; // constructor LicenceeInfo::LicenceeInfo() : fName(kDefaultName), fApplicationID(kDefaultApplicationID), fApplicationVersion(kDefaultApplicationVersion), fRegistrationTime(kDefaultRegistrationTime), fExpirationTime(kDefaultExpirationTime), fLicenseType(kDefaultLicenseType) { } // unarchiving constructor LicenceeInfo::LicenceeInfo(BMessage* archive) : fName(kDefaultName), fApplicationID(kDefaultApplicationID), fApplicationVersion(kDefaultApplicationVersion), fRegistrationTime(kDefaultRegistrationTime), fExpirationTime(kDefaultExpirationTime), fLicenseType(kDefaultLicenseType) { archive->FindString("MyClass::Name", &fName); archive->FindString("MyClass::ApplicationID", &fApplicationID); archive->FindInt32("MyClass::ApplicationVersion", (int32*)&fApplicationVersion); archive->FindInt64("MyClass::RegistrationTime", &fRegistrationTime); archive->FindInt64("MyClass::ExpirationTime", &fExpirationTime); archive->FindInt32("MyClass::LicenseType", &fLicenseType); } // destructor LicenceeInfo::~LicenceeInfo() { } // SetName void LicenceeInfo::SetName(const char* name) { fName = name; } // GetName const char* LicenceeInfo::GetName() const { return fName.String(); } // SetApplicationID void LicenceeInfo::SetApplicationID(const char* id) { fApplicationID = id; } // GetApplicationID const char* LicenceeInfo::GetApplicationID() const { return fApplicationID.String(); } // SetApplicationVersion void LicenceeInfo::SetApplicationVersion(uint32 version) { fApplicationVersion = version; } // GetApplicationVersion uint32 LicenceeInfo::GetApplicationVersion() const { return fApplicationVersion; } // SetRegistrationTime void LicenceeInfo::SetRegistrationTime(bigtime_t time) { fRegistrationTime = time; } // GetRegistrationTime bigtime_t LicenceeInfo::GetRegistrationTime() const { return fRegistrationTime; } // SetExpirationTime void LicenceeInfo::SetExpirationTime(bigtime_t time) { fExpirationTime = time; } // GetExpirationTime bigtime_t LicenceeInfo::GetExpirationTime() const { return fExpirationTime; } // SetLicenseType void LicenceeInfo::SetLicenseType(int32 type) { fLicenseType = type; } // GetLicenseType int32 LicenceeInfo::GetLicenseType() const { return fLicenseType; } // PrintToStream void LicenceeInfo::PrintToStream() const { printf("LicenceeInfo:\n"); printf(" name : `%s'\n", GetName()); printf(" application ID : `%s'\n", GetApplicationID()); printf(" application version: %lu\n", GetApplicationVersion()); // printf(" registration time : %Ld\n", GetRegistrationTime()); // printf(" expiration time : %Ld\n", GetExpirationTime()); printf(" registration time : "); print_time(GetRegistrationTime()); printf("\n"); printf(" expiration time : "); print_time(GetExpirationTime()); printf("\n"); const char* licenseString = "unknown"; int32 licenseType = GetLicenseType(); switch (licenseType) { case LICENSE_STUDENT: licenseString = "noncommercial, student"; break; case LICENSE_COMMERCIAL_SINGLE: licenseString = "commercial, single user"; break; case LICENSE_COMMERCIAL_MULTI: licenseString = "commercial, multiple users"; break; default: break; } printf(" license type : %ld (%s)\n", licenseType, licenseString); } // Archive status_t LicenceeInfo::Archive(BMessage* archive, bool deep) const { status_t error = B_OK; error = BArchivable::Archive(archive, deep); if (error == B_OK) error = archive->AddString("MyClass::Name", fName); if (error == B_OK) error = archive->AddString("MyClass::ApplicationID", fApplicationID); if (error == B_OK) { error = archive->AddInt32("MyClass::ApplicationVersion", fApplicationVersion); } if (error == B_OK) { error = archive->AddInt64("MyClass::RegistrationTime", fRegistrationTime); } if (error == B_OK) error = archive->AddInt64("MyClass::ExpirationTime", fExpirationTime); if (error == B_OK) error = archive->AddInt32("MyClass::LicenseType", fLicenseType); return error; } // Instantiate _EXPORT BArchivable* LicenceeInfo::Instantiate(BMessage* archive) { if (!validate_instantiation(archive, "LicenceeInfo")) return NULL; return new LicenceeInfo(archive); }
22.665049
73
0.74063
waddlesplash
7269f9fc8966cc916d265529063cd86484078d22
1,499
hpp
C++
src/rdf4cpp/rdf/storage/node/BackendNodeHandle.hpp
rdf4cpp/rdf4cpp
559bf3742871fdf5c2f9dad634193f97e1198c9b
[ "MIT" ]
3
2022-01-10T10:35:44.000Z
2022-02-18T00:38:38.000Z
src/rdf4cpp/rdf/storage/node/BackendNodeHandle.hpp
rdf4cpp/rdf4cpp
559bf3742871fdf5c2f9dad634193f97e1198c9b
[ "MIT" ]
8
2021-06-06T17:45:14.000Z
2022-02-06T17:45:45.000Z
src/rdf4cpp/rdf/storage/node/BackendNodeHandle.hpp
rdf4cpp/rdf4cpp
559bf3742871fdf5c2f9dad634193f97e1198c9b
[ "MIT" ]
4
2021-09-16T12:49:09.000Z
2022-02-18T01:58:57.000Z
#ifndef RDF4CPP_BACKENDNODEHANDLE_HPP #define RDF4CPP_BACKENDNODEHANDLE_HPP #include <rdf4cpp/rdf/storage/node/NodeStorage.hpp> #include <compare> #include <cstddef> namespace rdf4cpp::rdf::storage::node { class BackendNodeHandle { NodeID node_id_; public: BackendNodeHandle() = default; explicit BackendNodeHandle(NodeID node_id); [[nodiscard]] RDFNodeType type() const noexcept; [[nodiscard]] bool is_iri() const noexcept; [[nodiscard]] bool is_literal() const noexcept; [[nodiscard]] bool is_blank_node() const noexcept; [[nodiscard]] bool is_variable() const noexcept; [[nodiscard]] bool empty() const noexcept; [[nodiscard]] NodeStorage node_storage() const; [[nodiscard]] NodeID id() const noexcept; [[nodiscard]] IRIBackend &iri_backend() const; [[nodiscard]] LiteralBackend &literal_backend() const; [[nodiscard]] BNodeBackend &bnode_backend() const; [[nodiscard]] VariableBackend &variable_backend() const; bool operator==(const BackendNodeHandle &other) const = default; auto operator<=>(const BackendNodeHandle &other) const = default; // TODO: support value retrieval from basic XSD datatypes }; } // namespace rdf4cpp::rdf::storage::node template<> struct std::hash<rdf4cpp::rdf::storage::node::BackendNodeHandle> { inline size_t operator()(rdf4cpp::rdf::storage::node::BackendNodeHandle const &v) const noexcept { return v.id().raw(); } }; #endif //RDF4CPP_BACKENDNODEHANDLE_HPP
28.826923
102
0.717145
rdf4cpp
726a6abe147dc0d1426714af19b47026789721c6
1,441
cpp
C++
SampleApplication/src/ExperienceManager/SenseHAT/LEDController/DrawContext.cpp
isabella232/max-toolkit
6fc0b416efa064094ffc98daf6ee8755c3ec73fe
[ "Apache-2.0" ]
4
2021-09-10T18:35:11.000Z
2022-01-07T11:33:10.000Z
SampleApplication/src/ExperienceManager/SenseHAT/LEDController/DrawContext.cpp
alexa/max-toolkit
6fc0b416efa064094ffc98daf6ee8755c3ec73fe
[ "Apache-2.0" ]
1
2022-02-08T19:22:12.000Z
2022-02-08T20:42:28.000Z
SampleApplication/src/ExperienceManager/SenseHAT/LEDController/DrawContext.cpp
isabella232/max-toolkit
6fc0b416efa064094ffc98daf6ee8755c3ec73fe
[ "Apache-2.0" ]
3
2021-09-20T22:11:32.000Z
2022-02-08T17:26:53.000Z
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0/ * * or in the "license" file accompanying this file. This file 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 "SampleApplication/ExperienceManager/SenseHAT/LEDController/DrawContext.h" namespace multiAgentExperience { namespace sampleApplication { namespace experienceManager { namespace senseHat { namespace ledController { void DrawContext::clear() { fill(0); } void DrawContext::fill(PixelValue color) { for (size_t i = 0; i < m_buffer.getWidth(); i++) { for (size_t j = 0; j < m_buffer.getHeight(); j++) { m_buffer[i][j] = 0; } } } void DrawContext::setPenColor(PixelValue color) { m_penColor = color; } void DrawContext::drawHLine(size_t row) { for (size_t i = 0; i < m_buffer.getWidth(); i++) { m_buffer[row][i] = m_penColor; } } } // namespace ledController } // namespace senseHat } // namespace experienceManager } // namespace sampleApplication } // namespace multiAgentExperience
28.254902
83
0.696738
isabella232
726c2b7c94a78617c6f2d8025c5a0acc3f44059c
1,214
cpp
C++
test/widgets/form.cpp
mattwood-microchip/egt
6cf491008684feb200585ad1e323a9a02085d9bf
[ "Apache-2.0" ]
36
2019-08-06T06:29:18.000Z
2022-03-31T09:26:28.000Z
test/widgets/form.cpp
mattwood-microchip/egt
6cf491008684feb200585ad1e323a9a02085d9bf
[ "Apache-2.0" ]
19
2019-12-06T00:25:35.000Z
2022-03-28T00:22:27.000Z
test/widgets/form.cpp
mattwood-microchip/egt
6cf491008684feb200585ad1e323a9a02085d9bf
[ "Apache-2.0" ]
14
2019-08-09T07:23:25.000Z
2021-09-22T20:08:12.000Z
/* * Copyright (C) 2018 Microchip Technology Inc. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 */ #include <egt/ui> #include <gtest/gtest.h> using ::testing::Combine; using ::testing::TestWithParam; using ::testing::Values; using ::testing::Range; class FormTest : public testing::TestWithParam<int> {}; TEST_P(FormTest, TestWidget) { egt::Application app; egt::TopWindow win; egt::Frame frame; std::shared_ptr<egt::experimental::Form> widget; int type = GetParam(); if (type == 0) { EXPECT_NO_THROW(widget.reset(new egt::experimental::Form("Form Title "))); EXPECT_NO_THROW(win.add(expand(widget))); } else if (type == 1) { EXPECT_NO_THROW(widget.reset(new egt::experimental::Form(frame, "Form Title "))); } widget->add_group("Group Tiltle"); for (int i = 0; i < 5; i++) { auto text1 = std::make_shared<egt::TextBox>("textBox " + std::to_string(i)); widget->add_option(text1); widget->group_align(egt::AlignFlag::center); widget->name_align(egt::AlignFlag::right); widget->remove_options(); } } INSTANTIATE_TEST_SUITE_P(FormTestGroup, FormTest, Values(0, 1));
25.291667
89
0.640033
mattwood-microchip
726dc1830a34c721af79b6dbd64d07966894f077
2,830
hpp
C++
node_modules/node-lemmer/include/turglem/morph_compiler.hpp
noduslabs/un1v3r53
7684f57721dc16b01f4776f37301e0e1913b60ba
[ "MIT" ]
2
2019-04-17T04:41:00.000Z
2021-04-01T15:37:04.000Z
node_modules/node-lemmer/include/turglem/morph_compiler.hpp
noduslabs/un1v3r53
7684f57721dc16b01f4776f37301e0e1913b60ba
[ "MIT" ]
null
null
null
node_modules/node-lemmer/include/turglem/morph_compiler.hpp
noduslabs/un1v3r53
7684f57721dc16b01f4776f37301e0e1913b60ba
[ "MIT" ]
null
null
null
/* * Copyright (C) 2007, libturglem development team. * * This file is released under the LGPL. */ #ifndef __MORPH_COMPILER___ #define __MORPH_COMPILER___ #include <txml/txml.hpp> #include <MAFSA/daciuk.hpp> namespace MAFSA { typedef std::basic_string<MAFSA_letter> l_string; } namespace turglem { template<typename _ABC> class morph_compiler { struct paradigms_xml_loader : public txml::determination_object { struct ROOT : public txml::determination_object { struct PARADIGM : public txml::determination_object { struct FORM : public txml::determination_object { std::string prefix; std::string suffix; u_int32_t pos; u_int64_t grammem; u_int32_t id; void determine(txml::parser *parser) { parser->determineMember("s", suffix); parser->determineMember("ps", pos); parser->determineMember("g", grammem); parser->determineMember("p", prefix); parser->determineMember("id", id); } }; std::vector<FORM> forms; void determine(txml::parser *parser) { parser->determineMember("f", forms); } }; std::vector<PARADIGM> paradigms; void determine(txml::parser *parser) { parser->determineMember("paradigm", paradigms); } }; ROOT root; void determine(txml::parser *parser) { parser->determineMember("paradigms", root); } } paradigms_loader; struct lemmas_xml_loader : public txml::determination_object { struct ROOT : public txml::determination_object { struct LEMMA : public txml::determination_object { std::string word; std::string prefix; u_int32_t idx; void determine(txml::parser *parser) { std::string tmp; parser->determineMember("id", word); parser->determineMember("p", idx); parser->determineMember("prefix", prefix); } }; std::vector<LEMMA> ls; void determine(txml::parser *parser) { parser->determineMember("l", ls); } }; ROOT root; void determine(txml::parser *parser) { parser->determineMember("lemmas", root); } } lemmas_loader; std::map<MAFSA::l_string, std::map<std::pair<uint, uint>, uint> > prediction_data; void process_stat_data(); void add_stats(const MAFSA::l_string& s, uint flex, uint form, uint max_pref_suf_len); void save_prediction_dict(const char * predict_out); void save_main_dict(const char * dict_out); public: bool load_and_convert_paradigms(const char * xml_source, const char * bin_out); bool load_lemmas(const char * xml_source); //if predict_out == 0 then prediction dict is not generated bool process_and_save_dicts(const char * dict_out, const char * predict_out); }; #include <turglem/morph_compiler.tcc> } // namespace turglem #endif //__MORPH_COMPILER___
21.278195
87
0.671025
noduslabs
726e70415fc9114323b1ae718c012bab12933cfb
581
cpp
C++
skia/docs/examples/Path_setLastPt.cpp
jiangkang/renderer-dog
8081732e2b4dbdb97c8d1f5e23f9e52c6362ff85
[ "MIT" ]
1
2019-03-25T15:37:48.000Z
2019-03-25T15:37:48.000Z
docs/examples/Path_setLastPt.cpp
bryphe/esy-skia
9810a02f28270535de10b584bffc536182224c83
[ "BSD-3-Clause" ]
1
2020-09-13T11:08:17.000Z
2020-09-13T11:08:17.000Z
skia/docs/examples/Path_setLastPt.cpp
jiangkang/renderer-dog
8081732e2b4dbdb97c8d1f5e23f9e52c6362ff85
[ "MIT" ]
null
null
null
#if 0 // Disabled until updated to use current API. // Copyright 2019 Google LLC. // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #include "fiddle/examples.h" // HASH=542c5afaea5f57baa11d0561dd402e18 REG_FIDDLE(Path_setLastPt, 256, 128, false, 0) { void draw(SkCanvas* canvas) { SkPaint paint; paint.setTextSize(128); SkPath path; paint.getTextPath("@", 1, 60, 100, &path); path.setLastPt(20, 120); canvas->drawPath(path, paint); } } // END FIDDLE #endif // Disabled until updated to use current API.
34.176471
100
0.70568
jiangkang
726ec423f6bcd6e9ad5b329780e45c28a248b2f9
1,599
cpp
C++
codeforces/919C : Seat Arrangements.cpp
him1411/algorithmic-coding-and-data-structures
685aa95539692daca68ce79c20467c335aa9bb7f
[ "MIT" ]
null
null
null
codeforces/919C : Seat Arrangements.cpp
him1411/algorithmic-coding-and-data-structures
685aa95539692daca68ce79c20467c335aa9bb7f
[ "MIT" ]
null
null
null
codeforces/919C : Seat Arrangements.cpp
him1411/algorithmic-coding-and-data-structures
685aa95539692daca68ce79c20467c335aa9bb7f
[ "MIT" ]
2
2018-10-04T19:01:52.000Z
2018-10-05T08:49:57.000Z
#include <bits/stdc++.h> #include<string.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define Max(x,y,z) max(x,max(y,z)) #define Min(x,y,z) min(x,min(y,z)) #define ll long long #define trace1(x) cerr<<#x<<": "<<x<<endl #define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl #define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl #define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl int32_t main() { IOS; ll n,m,k,count=0,l,flag; cin>>n>>m>>k; char a[n+1][m+1]; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin>>a[i][j]; } } for (int i = 0; i < n; i++) { flag =0; for (int j = 0; j < m; j++) { if (k != 1) { if (a[i][j] == '.') { flag++; if (flag>=k) { count++; } } else if (a[i][j] != '.') { flag =0; } } if (k==1) { if (a[i][j] == '.') count++; } } } if (k!=1) { for (int j = 0; j < m; j++) { flag =0; for (int i = 0; i < n; i++) { if (k != 1) { if (a[i][j] == '.') { flag++; if (flag>=k) { count++; } } else if (a[i][j] != '.') { flag =0; } } } } } cout<<count; return 0; }
17.966292
110
0.317699
him1411
726f0fc9a56bfd2cfa2b5de400c7489d4451af3e
626
hpp
C++
include/threepp/lights/light_interfaces.hpp
maidamai0/threepp
9b50e2c0f2a7bb3ebfd3ffeef61dbefcd54c7071
[ "MIT" ]
null
null
null
include/threepp/lights/light_interfaces.hpp
maidamai0/threepp
9b50e2c0f2a7bb3ebfd3ffeef61dbefcd54c7071
[ "MIT" ]
null
null
null
include/threepp/lights/light_interfaces.hpp
maidamai0/threepp
9b50e2c0f2a7bb3ebfd3ffeef61dbefcd54c7071
[ "MIT" ]
null
null
null
#ifndef THREEPP_LIGHT_INTERFACES_HPP #define THREEPP_LIGHT_INTERFACES_HPP #include "LightShadow.hpp" namespace threepp { template <class LightShadowType> class LightWithShadow { public: std::shared_ptr<LightShadowType> shadow; virtual ~LightWithShadow() = default; protected: explicit LightWithShadow(const std::shared_ptr<LightShadowType> &shadow) : shadow(shadow) {} }; class LightWithTarget { public: std::shared_ptr<Object3D> target{Object3D::create()}; virtual ~LightWithTarget() = default; }; } #endif//THREEPP_LIGHT_INTERFACES_HPP
17.388889
100
0.693291
maidamai0
72714850c7e336f726ad49889c75562f7c549b58
1,640
cpp
C++
src/Map/MapMovableGameObject.cpp
tizian/Cendric2
5b0438c73a751bcc0d63c3af839af04ab0fb21a3
[ "MIT" ]
279
2015-05-06T19:04:07.000Z
2022-03-21T21:33:38.000Z
src/Map/MapMovableGameObject.cpp
tizian/Cendric2
5b0438c73a751bcc0d63c3af839af04ab0fb21a3
[ "MIT" ]
222
2016-10-26T15:56:25.000Z
2021-10-03T15:30:18.000Z
src/Map/MapMovableGameObject.cpp
tizian/Cendric2
5b0438c73a751bcc0d63c3af839af04ab0fb21a3
[ "MIT" ]
49
2015-10-01T21:23:03.000Z
2022-03-19T20:11:31.000Z
#include "Map/MapMovableGameObject.h" MapMovableGameObject::MapMovableGameObject(const Map* map) : MovableGameObject() { m_map = map; } MapMovableGameObject::~MapMovableGameObject() { } void MapMovableGameObject::updateAnimation(const sf::Time& frameTime) { // calculate new game state and set animation. GameObjectState newState = m_state; if (getVelocity().y < -Epsilon && (std::abs(getVelocity().x) < std::abs(getVelocity().y))) { newState = GameObjectState::Walking_up; } else if (getVelocity().y >= Epsilon && (std::abs(getVelocity().x) <= std::abs(getVelocity().y))) { newState = GameObjectState::Walking_down; } else if (getVelocity().x < -Epsilon && (std::abs(getVelocity().x) > std::abs(getVelocity().y))) { newState = GameObjectState::Walking_left; } else if (getVelocity().x >= Epsilon && (std::abs(getVelocity().x) >= std::abs(getVelocity().y))) { newState = GameObjectState::Walking_right; } // check if char is standing still if (getVelocity().x == 0.0f && getVelocity().y == 0.0f) { if (m_state == GameObjectState::Walking_down) { newState = GameObjectState::Idle_down; } else if (m_state == GameObjectState::Walking_up) { newState = GameObjectState::Idle_up; } else if (m_state == GameObjectState::Walking_right) { newState = GameObjectState::Idle_right; } else if (m_state == GameObjectState::Walking_left) { newState = GameObjectState::Idle_left; } } // only update animation if we need to if (m_state != newState) { m_state = newState; setCurrentAnimation(getAnimation(m_state), false); } } const Map* MapMovableGameObject::getMap() const { return m_map; }
31.538462
99
0.698171
tizian
7274f16ba62b32c192035329fa6b30f3d026f976
1,844
cpp
C++
stm32/bluepill/bluepill.cpp
lupyuen/send-altitude-cocoos
77f33be2ddf3d243056f78e30a1c86c71b8a9d81
[ "MIT" ]
24
2018-08-16T09:57:44.000Z
2020-12-18T22:32:48.000Z
stm32/bluepill/bluepill.cpp
lupyuen/send-altitude-cocoos
77f33be2ddf3d243056f78e30a1c86c71b8a9d81
[ "MIT" ]
1
2019-04-13T14:37:06.000Z
2019-04-17T06:34:03.000Z
stm32/bluepill/bluepill.cpp
lupyuen/send-altitude-cocoos
77f33be2ddf3d243056f78e30a1c86c71b8a9d81
[ "MIT" ]
6
2018-09-10T19:48:05.000Z
2020-12-14T23:12:07.000Z
// Defines functions specific to the STM32 Blue Pill platform. #include <libopencm3/cm3/cortex.h> #include <libopencm3/stm32/rcc.h> #include <logger.h> #include "bluepill.h" // Debugging is off by default. Developer must switch it on with enable_debug(). static bool debugEnabled = false; void platform_setup(void) { // Initialise the STM32 platform. At startup, the onboard LED will blink on-off-on-off-on and stays on. // If LED blinks on-off-on-off and stays off, then debug mode is enabled and no debugger is connected. rcc_clock_setup_in_hse_8mhz_out_72mhz(); led_setup(); if (debugEnabled) { led_on(); led_wait(); led_off(); led_wait(); led_on(); led_wait(); led_off(); led_wait(); // This line will call ARM Semihosting and may hang until debugger is connected. debug_println("----platform_setup"); led_on(); } } void enable_debug(void) { // Enable ARM Semihosting for displaying debug messages. debugEnabled = true; enable_log(); } void disable_debug(void) { // Disable ARM Semihosting for displaying debug messages. debugEnabled = false; disable_log(); } // For Legacy Arduino Support only... #define ALL_PINS_SIZE (sizeof(allPins) / sizeof(uint32_t)) static const uint32_t allPins[] = { // Map Arduino pin number to STM32 port ID. 0, // Unknown pin. SPI1, SPI2, I2C1, I2C2, USART1, USART2, }; // TODO: Support STM32 alternate port mapping. uint32_t convert_pin_to_port(uint8_t pin) { // Map Arduino Pin to STM32 Port, e.g. 1 becomes SPI1 if (pin < 1 || pin >= ALL_PINS_SIZE) { return 0; } // Invalid pin. return allPins[pin]; } uint8_t convert_port_to_pin(uint32_t port_id) { // Map STM32 port to Arduino Pin, e.g. SPI1 becomes 1 for (uint8_t pin = 1; pin < ALL_PINS_SIZE; pin++) { if (port_id == allPins[pin]) { return pin; } } return 0; // Invalid port. }
28.8125
108
0.703905
lupyuen
72787f476fe49ffcf936c61363935d72ed7f4b1c
1,276
cpp
C++
src/paraboloid.cpp
dkirkby/batoid
734dccc289eb7abab77a62cdc14563ed5981753b
[ "BSD-2-Clause" ]
null
null
null
src/paraboloid.cpp
dkirkby/batoid
734dccc289eb7abab77a62cdc14563ed5981753b
[ "BSD-2-Clause" ]
null
null
null
src/paraboloid.cpp
dkirkby/batoid
734dccc289eb7abab77a62cdc14563ed5981753b
[ "BSD-2-Clause" ]
null
null
null
#include "paraboloid.h" #include "utils.h" #include <cmath> namespace batoid { Paraboloid::Paraboloid(double R) : _R(R), _Rinv(1./R), _2Rinv(1./2/R) {} double Paraboloid::sag(double x, double y) const { if (_R != 0) { double r2 = x*x + y*y; return r2*_2Rinv; } return 0.0; } Vector3d Paraboloid::normal(double x, double y) const { if (_R == 0) return Vector3d(0,0,1); return Vector3d(-x*_Rinv, -y*_Rinv, 1).normalized(); } bool Paraboloid::timeToIntersect(const Ray& r, double& t) const { double a = (r.v[0]*r.v[0] + r.v[1]*r.v[1])*_2Rinv; double b = (r.r[0]*r.v[0] + r.r[1]*r.v[1])*_Rinv - r.v[2]; double c = (r.r[0]*r.r[0] + r.r[1]*r.r[1])*_2Rinv - r.r[2]; double r1, r2; int n = solveQuadratic(a, b, c, r1, r2); if (n == 0) return false; else if (n == 1) { if (r1 < 0) return false; t = r1; } else { if (r1 < 0) { if (r2 < 0) return false; else t = r2; } else t = std::min(r1, r2); } t += r.t; return true; } }
26.040816
76
0.431034
dkirkby
727a34112dabd03c4ca0d4abbd1bb6170f6e946d
1,234
cpp
C++
src/models/metasprite/compiler/romdata.cpp
undisbeliever/untech-editor
8598097baf6b2ac0b5580bc000e9adc3bf682043
[ "MIT" ]
13
2016-05-02T09:00:42.000Z
2020-11-07T11:21:07.000Z
src/models/metasprite/compiler/romdata.cpp
undisbeliever/untech-editor
8598097baf6b2ac0b5580bc000e9adc3bf682043
[ "MIT" ]
3
2016-09-28T13:36:29.000Z
2020-12-22T12:22:43.000Z
src/models/metasprite/compiler/romdata.cpp
undisbeliever/untech-editor
8598097baf6b2ac0b5580bc000e9adc3bf682043
[ "MIT" ]
1
2016-05-08T09:26:01.000Z
2016-05-08T09:26:01.000Z
/* * This file is part of the UnTech Editor Suite. * Copyright (c) 2016 - 2021, Marcus Rowe <undisbeliever@gmail.com>. * Distributed under The MIT License: https://opensource.org/licenses/MIT */ #include "romdata.h" #include <iomanip> namespace UnTech::MetaSprite::Compiler { void RomAddrTable::writeToIncFile(std::ostream& out) const { out << _label << ":"; if (_nullableType) { out << "\tassert(pc() & 0xffff != 0)\n"; } auto oldWidth = out.width(); auto oldFlags = out.flags(); auto oldFill = out.fill(); auto writeOffset = [&](unsigned i) { uint32_t v = _offsets[i]; if (v <= 0xFFFF) { out << _dataLabel << " + " << v; } else { out << '0'; } }; for (unsigned i = 0; i < _offsets.size(); i += ADDR_PER_LINE) { out << "\n\tdw\t"; writeOffset(i); const unsigned end = std::min<unsigned>(i + ADDR_PER_LINE, _offsets.size()); for (unsigned j = i + 1; j < end; j++) { out << ", "; writeOffset(j); } } out << "\n\n"; out.width(oldWidth); out.flags(oldFlags); out.fill(oldFill); } }
22.851852
73
0.509724
undisbeliever
727f7dd484bf398f797c732ccc6ae43ed8ec1ccb
1,680
cpp
C++
PPP/drill8/drill82.cpp
siddheshpai/hello-world
291456962d46c6ce857d75be86bc23634625925f
[ "Apache-2.0" ]
null
null
null
PPP/drill8/drill82.cpp
siddheshpai/hello-world
291456962d46c6ce857d75be86bc23634625925f
[ "Apache-2.0" ]
null
null
null
PPP/drill8/drill82.cpp
siddheshpai/hello-world
291456962d46c6ce857d75be86bc23634625925f
[ "Apache-2.0" ]
null
null
null
#include <iostream> using namespace std; void swap_v(int a, int b) { int temp; temp = a; a = b; b = temp; return; } void swap_r(int & a, int & b) { int temp; temp = a; a = b; b = temp; return; } /* This will not compile since we are trying to change constant references void swap_cr(const int & a, const int & b) { int temp; temp = a; a = b; b = temp; return; } */ int main() { int x = 7, y = 9; swap_v(x, y); cout << "After swap_v(), x is : " << x << " and y is : " << y << endl; swap_r(x, y); cout << "After swap_r(), x is : " << x << " and y is : " << y << endl; //swap_cr(x, y); //cout << "After swap_cr(), x is : " << x << " and y is : " << y << endl; swap_v(7, 9); cout << "After swap_v(), x is : " << x << " and y is : " << y << endl; //swap_r(7, 9); //Will not compile due to literals being passed to (references to variables) //cout << "After swap_r(), x is : " << x << " and y is : " << y << endl; //swap_cr(7, 9); //cout << "After swap_cr(), x is : " << x << " and y is : " << y << endl; const int cx = 7, cy = 9; swap_v(cx, cy); cout << "After swap_v(), cx is : " << cx << " and cy is : " << cy << endl; //Will not compile since "binding reference of type ‘int&’ to ‘const int’ discards qualifiers" //swap_r(cx, cy); //cout << "After swap_r(), cx is : " << cx << " and cy is : " << cy << endl; double dx = 7.7, dy = 9.9; swap_v(dx, dy); cout << "After swap_v(), dx is : " << dx << " and dy is : " << dy << endl; //Will not compile since we are trying to set reference of int to double //swap_r(dx, dy); //cout << "After swap_r(), dx is : " << dx << " and dy is : " << dy << endl; return 0; }
22.4
95
0.523214
siddheshpai
728050a4406be9e017ad8b906836e4fc3fd98b5d
13,064
cpp
C++
src/sweepc/source/swp_constant_inception.cpp
sm453/MOpS
f1a706c6552bbdf3ceab504121a02391a1b51ede
[ "MIT" ]
3
2020-09-08T14:06:33.000Z
2020-12-04T07:52:19.000Z
src/sweepc/source/swp_constant_inception.cpp
sm453/MOpS
f1a706c6552bbdf3ceab504121a02391a1b51ede
[ "MIT" ]
null
null
null
src/sweepc/source/swp_constant_inception.cpp
sm453/MOpS
f1a706c6552bbdf3ceab504121a02391a1b51ede
[ "MIT" ]
3
2021-11-15T05:18:26.000Z
2022-03-01T13:51:20.000Z
/*! * \file swp_constant_inception.cpp * \author Robert I A Patterson * * \brief Class for inception at a constant rate * * Copyright (C) 2010 Robert I A Patterson. Licence: This file is part of "sweepc". sweepc is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Contact: Dr Markus Kraft Dept of Chemical Engineering University of Cambridge New Museums Site Pembroke Street Cambridge CB2 3RA UK Email: mk306@cam.ac.uk Website: http://como.cheng.cam.ac.uk */ #include "swp_constant_inception.h" #include "swp_mechanism.h" #include "swp_primary.h" #include "local_geometry1d.h" #include <boost/random/uniform_01.hpp> #include <boost/random/lognormal_distribution.hpp> // CONSTRUCTORS AND DESTRUCTORS. // Default constructor (private). Sweep::Processes::ConstantInception::ConstantInception() : Inception() , mUseFixedPosition(false) , mFixedPosition(0.0) { m_name = "ConstantInception"; } /*! * Initialising constructor * * @param[in] mech Mechanism of which process will be part * @param[in] rate Rate of inception jumps * @param[in] locations Location parameters for lognormal component distributions, ordered to match the components in the mechanism * @param[in] scales Scale parameters for lognormal component distributions, ordered to match the components in the mechanism * * @exception std::runtime_error Distribution parameters not specified for all components */ Sweep::Processes::ConstantInception::ConstantInception(const Sweep::Mechanism &mech, const double rate, const std::vector<double>& locations, const std::vector<double>& scales) : Inception(mech) , mUseFixedPosition(false) , mFixedPosition(0.0) , mComponentDistributions(mech.ComponentCount()) { if((mech.ComponentCount() != locations.size()) || (mech.ComponentCount() != scales.size())) throw std::runtime_error("Details must be supplied for all components in ConstantInception::ConstantInception"); SetA(rate); m_name = "ConstantInception"; // It is important that the ordering corresponding to the ordering of the components in the mechanism, // just having the same number of entries is necessary, but not sufficient. for(unsigned i = 0; i < mech.ComponentCount(); ++i) { mComponentDistributions[i] = std::make_pair(locations[i], scales[i]); SetParticleComp(i, exp(locations[i] + 0.5 * scales[i] * scales[i])); } } // Copy constructor. Sweep::Processes::ConstantInception::ConstantInception(const ConstantInception &copy) { *this = copy; } // Stream-reading constructor. Sweep::Processes::ConstantInception::ConstantInception(std::istream &in, const Sweep::Mechanism &mech) { Deserialize(in, mech); } // Default destructor. Sweep::Processes::ConstantInception::~ConstantInception(void) { } // OPERATOR OVERLOADS. // Assignment operator. Sweep::Processes::ConstantInception &Sweep::Processes::ConstantInception::operator =(const ConstantInception &rhs) { if (this != &rhs) { Inception::operator =(rhs); } mUseFixedPosition = rhs.mUseFixedPosition; mFixedPosition = rhs.mFixedPosition; mComponentDistributions = rhs.mComponentDistributions; return *this; } /*! * Create a new particle and add it to the ensemble with position uniformly * distributed over the grid cell, if it is of positive size. * * The iterm parameter is included because it will be needed for many process * types and this function is meant to have a general signature. * * \param[in] t Time * \param[in,out] sys System to update * \param[in] local_geom Details of local phsyical layout * \param[in] iterm Process term responsible for this event * \param[in,out] rng Random number generator * * \return 0 on success, otherwise negative. */ int Sweep::Processes::ConstantInception::Perform(const double t, Cell &sys, const Geometry::LocalGeometry1d &local_geom, const unsigned int iterm, rng_type &rng) const { // Position of newly incepted particle double posn; if(mUseFixedPosition) { // If there is a fixed position the rate should only be positive for the cell containing the fixed position if(local_geom.isInCell(mFixedPosition)) posn = mFixedPosition; else return 0; } else { // Get the cell vertices fvector vertices = local_geom.cellVertices(); // Sample a uniformly distributed position, note that this method // works whether the vertices come in increasing or decreasing order, // but 1d is assumed for now. posn = vertices.front(); const double width = vertices.back() - posn; boost::uniform_01<rng_type&, double> unifDistrib(rng); posn += width * unifDistrib(); } // Initialise the new particle. std::vector<double> newComposition(mComponentDistributions.size()); for(unsigned i = 0; i < mComponentDistributions.size(); ++i) { // Construct the distribution on the fly. If this becomes a performance // bottleneck some optimisations might be possible, but caching the distribution // object in the mechanism is a bad idea, because the mechanism is potentially // shared between threads, which is very dangerous for cached data! newComposition[i] = boost::random::lognormal_distribution<double>(mComponentDistributions[i].first, mComponentDistributions[i].second)(rng); } // Check if using hybrid particle-number/particle model // If hybrid_flag is active, track the number of particles in a list // Otherwise add particle to system's ensemble. if (!m_mech->IsHybrid()) { // Create a new particle of the type specified // by the system ensemble. Particle * sp = m_mech->CreateParticle(t); sp->setPositionAndTime(posn, t); sp->Primary()->SetComposition(newComposition); sp->Primary()->SetValues(ParticleTrackers()); sp->UpdateCache(); sys.Particles().Add(*sp, rng); // Update gas-phase chemistry of system. if (!sys.GetIsAdiabaticFlag()) adjustGas(sys, sp->getStatisticalWeight()); // Update gas-phase chemistry and temperature of system. else adjustParticleTemperature(sys, sp->getStatisticalWeight(), 1, ParticleComp()[0], 1); } else { // Adjust particle number properties sys.Particles().UpdateNumberAtIndex(ParticleComp()[0], 1); sys.Particles().UpdateTotalParticleNumber(1); sys.Particles().UpdateTotalsWithIndex(ParticleComp()[0], 1.0); // Update gas-phase chemistry of system. if (!sys.GetIsAdiabaticFlag()) adjustGas(sys, 1); // Update gas-phase chemistry and temperature of system. else adjustParticleTemperature(sys, 1, 1, ParticleComp()[0], 1); } return 0; } // TOTAL RATE CALCULATIONS. /*! *@param[in] t Time at which rate is being calculated *@param[in] sys System for which rate is to be calculated *@param[in] local_geom Spatial configuration information (ignored) * *@return Process rate */ double Sweep::Processes::ConstantInception::Rate(double t, const Cell &sys, const Geometry::LocalGeometry1d &local_geom) const { double rate = A() * sys.SampleVolume(); if(mUseFixedPosition) { if(local_geom.isInCell(mFixedPosition)) { // Dividing by cell volume (which is distinct from the sample volume) // seems to be the right thing to do, because the concentration // is averaged over the whole cell and thus is proportional to the // amount of reactor covered by the cell rate /= local_geom.cellVolume(); } else rate = 0.0; } return rate; } // RATE TERM CALCULATIONS. // Returns the number of rate terms for this process (one). unsigned int Sweep::Processes::ConstantInception::TermCount() const {return 1;} // Calculates the rate terms given an iterator to a double vector. The // iterator is advanced to the position after the last term for this // process. Returns the sum of all terms. double Sweep::Processes::ConstantInception::RateTerms(const double t, const Cell &sys, const Geometry::LocalGeometry1d &local_geom, fvector::iterator &iterm) const { // Calculate the single rate term and advance iterator. *iterm = Rate(t, sys, local_geom); return *(iterm++); } // READ/WRITE/COPY. // Creates a copy of the inception. Sweep::Processes::ConstantInception *const Sweep::Processes::ConstantInception::Clone() const { return new ConstantInception(*this); } // Returns the process type. Used to identify different // processes and for serialisation. Sweep::Processes::ProcessType Sweep::Processes::ConstantInception::ID() const { return Constant_Inception_ID; } // Writes the object to a binary stream. void Sweep::Processes::ConstantInception::Serialize(std::ostream &out) const { if (out.good()) { // Output the version ID (=0 at the moment). const unsigned int version = 0; out.write(reinterpret_cast<const char*>(&version), sizeof(version)); // Serialize base class. Inception::Serialize(out); // Fixed position support out.write(reinterpret_cast<const char*>(&mUseFixedPosition), sizeof(mUseFixedPosition)); out.write(reinterpret_cast<const char*>(&mFixedPosition), sizeof(mFixedPosition)); // Component distributions const unsigned int n = mComponentDistributions.size(); out.write(reinterpret_cast<const char*>(&n), sizeof(n)); for(unsigned int i = 0; i < n; ++i) { out.write(reinterpret_cast<const char*>(&mComponentDistributions[i].first), sizeof(mComponentDistributions[i].first)); out.write(reinterpret_cast<const char*>(&mComponentDistributions[i].second), sizeof(mComponentDistributions[i].second)); } } else { throw std::invalid_argument("Output stream not ready (Sweep, Sweep::Processes::ConstantInception::Serialize)."); } } // Reads the object from a binary stream. void Sweep::Processes::ConstantInception::Deserialize(std::istream &in, const Sweep::Mechanism &mech) { if (in.good()) { // Read the output version. Currently there is only one // output version, so we don't do anything with this variable. // Still needs to be read though. unsigned int version = 0; in.read(reinterpret_cast<char*>(&version), sizeof(version)); switch (version) { case 0: { // Deserialize base class. Inception::Deserialize(in, mech); // Fixed position support in.read(reinterpret_cast<char*>(&mUseFixedPosition), sizeof(mUseFixedPosition)); in.read(reinterpret_cast<char*>(&mFixedPosition), sizeof(mFixedPosition)); // Component distributions unsigned int n = 0; in.read(reinterpret_cast<char*>(&n), sizeof(n)); mComponentDistributions.resize(n); for(unsigned int i = 0; i < n; ++i) { in.read(reinterpret_cast<char*>(&mComponentDistributions[i].first), sizeof(mComponentDistributions[i].first)); in.read(reinterpret_cast<char*>(&mComponentDistributions[i].second), sizeof(mComponentDistributions[i].second)); } break; } default: throw std::runtime_error("Serialized version number is invalid (Sweep, Sweep::Processes::ConstantInception::Deserialize)."); } } else { throw std::invalid_argument("Input stream not ready (Sweep, Sweep::Processes::ConstantInception::Deserialize)."); } }
36.8
140
0.648653
sm453
72810e77c91b08e79a4f0165c72a1f1ae8c4102f
3,231
cxx
C++
src/atxmega256a3u/device.cxx
DX-MON/dragonUSB
e3b43d786f767577822ba5e777d01328cd92a80d
[ "BSD-3-Clause" ]
4
2021-06-20T02:20:03.000Z
2021-12-30T01:43:02.000Z
src/atxmega256a3u/device.cxx
DX-MON/dragonUSB
e3b43d786f767577822ba5e777d01328cd92a80d
[ "BSD-3-Clause" ]
null
null
null
src/atxmega256a3u/device.cxx
DX-MON/dragonUSB
e3b43d786f767577822ba5e777d01328cd92a80d
[ "BSD-3-Clause" ]
null
null
null
// SPDX-License-Identifier: BSD-3-Clause #include "usb/platform.hxx" #include "usb/internal/core.hxx" #include "usb/platforms/atxmega256a3u/core.hxx" #include "usb/internal/device.hxx" using namespace usb::constants; using namespace usb::types; using namespace usb::core; using namespace usb::core::internal; using namespace usb::descriptors; using namespace usb::device::internal; namespace usb::device { namespace endpoint { uint8_t mapType(const usbEndpointType_t type) { switch (type) { case usbEndpointType_t::isochronous: return USB_EP_TYPE_ISOCHRONOUS_gc; case usbEndpointType_t::control: return USB_EP_TYPE_CONTROL_gc; default: break; } return USB_EP_TYPE_BULK_gc; } uint8_t mapMaxSize(const uint16_t size) { if (size <= 8) return USB_EP_BUFSIZE_8_gc; else if (size <= 16) return USB_EP_BUFSIZE_16_gc; else if (size <= 32) return USB_EP_BUFSIZE_32_gc; else if (size <= 64) return USB_EP_BUFSIZE_64_gc; // This should never happen.. return USB_EP_BUFSIZE_1023_gc; } } // namespace endpoint void setupEndpoint(const usbEndpointDescriptor_t &endpoint) { if (endpoint.endpointType == usbEndpointType_t::control) return; const auto direction{static_cast<endpointDir_t>(endpoint.endpointAddress & ~usb::descriptors::endpointDirMask)}; const auto endpointNumber{uint8_t(endpoint.endpointAddress & usb::descriptors::endpointDirMask)}; auto &epCtrl { [direction](endpointCtrl_t &endpointCtrl) -> USB_EP_t & { if (direction == endpointDir_t::controllerIn) return endpointCtrl.controllerIn; else return endpointCtrl.controllerOut; }(endpoints[endpointNumber]) }; epCtrl.CNT = 0; epCtrl.CTRL = endpoint::mapType(endpoint.endpointType) | endpoint::mapMaxSize(endpoint.maxPacketSize); } namespace internal { bool handleSetConfiguration() noexcept { usb::core::resetEPs(epReset_t::user); usb::core::deinitHandlers(); const auto config{packet.value.asConfiguration()}; if (config > configsCount) return false; activeConfig = config; if (activeConfig == 0) usbState = deviceState_t::addressed; else { const auto descriptors{*configDescriptors[activeConfig - 1U]}; for (const auto &part : descriptors) { flash_t<char *> descriptor{static_cast<const char *>(part.descriptor)}; usbDescriptor_t type{static_cast<usbDescriptor_t>(descriptor[1])}; if (type == usbDescriptor_t::endpoint) { const auto endpoint{*flash_t<usbEndpointDescriptor_t *>(part.descriptor)}; setupEndpoint(endpoint); } } usb::core::initHandlers(); } return true; } } // namespace internal void handleControlPacket() noexcept { // If we received a packet.. if (usbPacket.dir() == endpointDir_t::controllerOut) { const auto status{endpoints[0].controllerOut.STATUS}; if (status & vals::usb::usbEPStatusSetupComplete) USB.INTFLAGSBCLR = vals::usb::itrStatusSetup; if (usbCtrlState == ctrlState_t::idle) handleSetupPacket(); else handleControllerOutPacket(); } else { handleControllerInPacket(); endpoints[0].controllerIn.STATUS &= uint8_t(~vals::usb::usbEPStatusIOComplete); } } } // namespace usb::device
26.483607
114
0.717425
DX-MON
7283572a416e3d99935afad05c9ac83c928cdc08
1,688
cpp
C++
QTP/main.cpp
Qu3tzal/TpQt
a741c64659d4808693c92de217261c75ed5fe17a
[ "MIT" ]
null
null
null
QTP/main.cpp
Qu3tzal/TpQt
a741c64659d4808693c92de217261c75ed5fe17a
[ "MIT" ]
null
null
null
QTP/main.cpp
Qu3tzal/TpQt
a741c64659d4808693c92de217261c75ed5fe17a
[ "MIT" ]
1
2018-09-30T10:39:37.000Z
2018-09-30T10:39:37.000Z
#include "mainwindow.h" #include "authentificationdialog.h" #include <QApplication> #include <QDebug> #include <iostream> #include <map> #include <string> #include <utility> #include "model/databasecreator.h" #include "model/staffmodel.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); // Uncomment only to create the database. DatabaseCreator::createDB(); /** Multimap. */ std::multimap<int, std::string> myMap; myMap.insert(std::pair<int, std::string>(1, "titi")); myMap.insert(std::pair<int, std::string>(4, "toto")); myMap.insert(std::pair<int, std::string>(3, "tutu")); myMap.insert(std::pair<int, std::string>(4, "tata")); std::multimap<int, std::string>::iterator elementItr = myMap.find(3); if(elementItr != myMap.end()) myMap.erase(elementItr); myMap.insert(std::pair<int, std::string>(0, "tete")); for(std::multimap<int, std::string>::iterator i(myMap.begin()) ; i != myMap.end() ; i++) { std::cout << i->second << std::endl; } /** End of multimap. */ // Launches the authentification dialog. AuthentificationDialog authentification; // Once we got the authentification success, we launch the main window. if(authentification.exec() == QDialog::Accepted) { MainWindow w; w.show(); // We need to do the application exec here, otherwise the MainWindow would get out of scope. int result = a.exec(); std::cout << "Nombre d'insert : " << DatabaseCreator::insertNumber << std::endl; return result; } else { std::cout << "Nombre d'insert : " << DatabaseCreator::insertNumber << std::endl; // Return 1 (= login failure). return 1; } }
27.225806
94
0.64455
Qu3tzal
7284539a6a216c96d9fa222abb84fce41f73cd2d
6,285
cpp
C++
guacservice/src/GuacLogger.cpp
ofiriluz/guacamole-server-windows
6f0230f3053e13536433bbd5fb728c248bab41fd
[ "Apache-2.0" ]
2
2020-10-27T03:50:42.000Z
2022-01-14T06:01:40.000Z
guacservice/src/GuacLogger.cpp
ofiriluz/guacamole-server-windows
6f0230f3053e13536433bbd5fb728c248bab41fd
[ "Apache-2.0" ]
2
2018-10-12T15:45:24.000Z
2020-06-16T10:08:26.000Z
guacservice/src/GuacLogger.cpp
ofiriluz/guacamole-server-windows
6f0230f3053e13536433bbd5fb728c248bab41fd
[ "Apache-2.0" ]
2
2021-05-21T11:53:43.000Z
2021-11-07T18:36:32.000Z
// // Created by oiluz on 9/5/2017. // #include <guacservice/GuacLogger.h> GuacLogger::GuacLogger() : m_Initialized(false), m_IgnoreLogs(false), m_WithConsole(false) { } boost::shared_ptr<GuacLogger> GuacLogger::GetInstance() { static boost::shared_ptr<GuacLogger> logger(new GuacLogger()); return logger; } void GuacLogger::SetConsoleColorBySeverity(boost::log::trivial::severity_level eLevel) { #ifdef WIN32 WORD color; switch (eLevel) { case boost::log::trivial::trace: color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; break; case boost::log::trivial::debug: color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; break; case boost::log::trivial::info: color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break; case boost::log::trivial::warning: color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; break; case boost::log::trivial::error: color = FOREGROUND_RED | FOREGROUND_INTENSITY; break; case boost::log::trivial::fatal: color = FOREGROUND_RED | FOREGROUND_INTENSITY; break; default: color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break; } HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsole, &m_ConsoleInfo); SetConsoleTextAttribute(hConsole, color); #elif defined __linux__ switch (eLevel) { case boost::log::trivial::trace: case boost::log::trivial::debug: std::cout << "\e[39m"; case boost::log::trivial::info: std::cout << "\e[34m"; break; case boost::log::trivial::warning: std::cout << "\e[33m"; break; case boost::log::trivial::error: case boost::log::trivial::fatal: std::cout << "\e[31m"; break; default: break; } #endif } void GuacLogger::ClearConsoleColor() { #ifdef WIN32 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hConsole, m_ConsoleInfo.wAttributes); #elif defined __linux__ std::cout << "\e[39m"; #endif } void GuacLogger::InitializeLog(const std::string & stLogFolder, const std::string & stLogFilePrefix, boost::log::trivial::severity_level eMaxSeverityLevel, bool bWithConsoleOutput, bool bWithFileOutput) { try { // Create log folder if does not exist and with file output if (!boost::filesystem::exists(boost::filesystem::path(stLogFolder)) && bWithFileOutput) { boost::system::error_code ec; boost::filesystem::create_directories(boost::filesystem::path(stLogFolder), ec); if (ec) { bWithFileOutput = false; } } // Add common attributes to the log and set its max log level boost::log::add_common_attributes(); boost::log::core::get()->set_filter(boost::log::trivial::severity >= eMaxSeverityLevel); // Create the formatters auto fmtTimeStamp = boost::log::expressions::format_date_time<boost::posix_time::ptime>("TimeStamp", "%Y-%m-%d %H:%M:%S.%f"); auto fmtProcessId = boost::log::expressions::attr<boost::log::attributes::current_process_id::value_type>( "ProcessID"); auto fmtThreadId = boost::log::expressions::attr<boost::log::attributes::current_thread_id::value_type>("ThreadID"); auto fmtSeverity = boost::log::expressions::attr<boost::log::trivial::severity_level>("Severity"); boost::log::formatter logFmt = boost::log::expressions::format("[%1%] [%2%(%3%)] [%4%] => %5%") % fmtTimeStamp % fmtProcessId % fmtThreadId % fmtSeverity % boost::log::expressions::smessage; // Add console sink if needed if (bWithConsoleOutput) { auto consoleSink = boost::log::add_console_log(std::clog); consoleSink->set_formatter(logFmt); } // Add File sink if (bWithFileOutput) { auto fsSink = boost::log::add_file_log( boost::log::keywords::file_name = stLogFolder + "/" + stLogFilePrefix + "_%Y-%m-%d_%H-%M-%S.%N.log", boost::log::keywords::rotation_size = 10 * 1024 * 1024, boost::log::keywords::min_free_space = 30 * 1024 * 1024, boost::log::keywords::open_mode = std::ios_base::app, boost::log::keywords::auto_flush = true); fsSink->set_formatter(logFmt); } m_Initialized = true; m_WithConsole = bWithConsoleOutput; m_IgnoreLogs = !(bWithConsoleOutput || bWithFileOutput); } catch (...) { m_Initialized = false; } } void GuacLogger::LogMessage(const std::string & stMessage, boost::log::trivial::severity_level eLevel) { if(!m_Initialized || m_IgnoreLogs) { return; } try { // Set the console color if with console if (m_WithConsole) { SetConsoleColorBySeverity(eLevel); } // Write log depending on the severity type switch(eLevel) { case boost::log::trivial::trace: BOOST_LOG_TRIVIAL(trace) << stMessage; break; case boost::log::trivial::debug: BOOST_LOG_TRIVIAL(debug) << stMessage; break; case boost::log::trivial::info: BOOST_LOG_TRIVIAL(info) << stMessage; break; case boost::log::trivial::warning: BOOST_LOG_TRIVIAL(warning) << stMessage; break; case boost::log::trivial::error: BOOST_LOG_TRIVIAL(error) << stMessage; break; case boost::log::trivial::fatal: BOOST_LOG_TRIVIAL(fatal) << stMessage; break; } // Clear the console color if (m_WithConsole) { ClearConsoleColor(); } } catch(...) { } } GuacLog GuacLogger::Trace() const { return GuacLog(boost::log::trivial::trace); } GuacLog GuacLogger::Debug() const { return GuacLog(boost::log::trivial::debug); } GuacLog GuacLogger::Info() const { return GuacLog(boost::log::trivial::info); } GuacLog GuacLogger::Warning() const { return GuacLog(boost::log::trivial::warning); } GuacLog GuacLogger::Error() const { return GuacLog(boost::log::trivial::error); } GuacLog GuacLogger::Fatal() const { return GuacLog(boost::log::trivial::fatal); } GuacLog::GuacLog(boost::log::trivial::severity_level eLevel) { m_eLevel = eLevel; } GuacLog::GuacLog(const GuacLog & rOther) { m_eLevel = rOther.m_eLevel; m_SS << rOther.m_SS.str(); } GuacLog::~GuacLog() { GuacLogger::GetInstance()->LogMessage(m_SS.str(), m_eLevel); }
26.297071
118
0.669212
ofiriluz
7288b15e6b0d0caf1465360225709e3a5227ed68
17,020
hpp
C++
src/Infrastructure/Mesh/src/Moab/moab/GeomTopoTool.hpp
Formatted/esmf
94561c6a1d539917da5595a8de867e43f43bcafe
[ "NCSA" ]
null
null
null
src/Infrastructure/Mesh/src/Moab/moab/GeomTopoTool.hpp
Formatted/esmf
94561c6a1d539917da5595a8de867e43f43bcafe
[ "NCSA" ]
null
null
null
src/Infrastructure/Mesh/src/Moab/moab/GeomTopoTool.hpp
Formatted/esmf
94561c6a1d539917da5595a8de867e43f43bcafe
[ "NCSA" ]
null
null
null
/** * MOAB, a Mesh-Oriented datABase, is a software component for creating, * storing and accessing finite element mesh data. * * Copyright 2004 Sandia Corporation. Under the terms of Contract * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government * retains certain rights in this software. * * 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. * */ #ifndef MOAB_GEOM_TOPO_TOOL_HPP #define MOAB_GEOM_TOPO_TOOL_HPP #include "moab/Forward.hpp" #include "moab/Range.hpp" #include <map> #include <assert.h> namespace moab { // forward declare this class to avoid the header leaking in here class OrientedBoxTreeTool; class GeomQueryTool; /** \class GeomTopoTool * \brief Tool for interpreting geometric topology sets in MOAB database * Tool for interpreting geometric topology sets in MOAB database; see MOAB metadata_info * document for information on how geometric topology sets are read and represented. */ class GeomTopoTool { public: /** \brief Constructor (creates a GTT object) \ * Construct a GeomTopoTool object and search for geometric EntitySets if they * exist in the provided moab instance. * \param impl MOAB instance the GeomTopoTool will operate on. * \param find_geoments if specified as True, geometric objects in the provided MOAB instance will be searched for and added to the GTT. \param modelRootSet the GTT will operate only on geometric EntitySets contained by this EntitySet. If unprovided, the default value for the modelRootSet is the MOAB instance's root set, which contains everything in the instance. \param p_rootSets_vector determines the storage datastructure used to relate geometric EntitySets to their OrientedBoundingBox (OBB) Tree roots. If set to true (default) a vector will be used to store the root sets along with an EntityHandle offset for fast lookup of the root sets. If set to false, then a map will be used to link geometric EntitySets (keys) to the OBB Tree root sets (values). \param restore_rootSets determines whether or not to restore the internal index that links geomSets to their corresponding OBB Root. Only relevant if find_geoments is true. (default = true) */ GeomTopoTool(Interface *impl, bool find_geoments = false, EntityHandle modelRootSet = 0, bool p_rootSets_vector = true, bool restore_rootSets = true); ~GeomTopoTool(); //! Restore parent/child links between GEOM_TOPO mesh sets ErrorCode restore_topology_from_adjacency(); //! Store sense of entity relative to wrt_entity. //!\return MB_MULTIPLE_ENTITIES_FOUND if surface already has a forward volume. //! MB_SUCCESS if successful //! otherwise whatever internal error code occured. ErrorCode set_sense( EntityHandle entity, EntityHandle wrt_entity, int sense); //! Get the sense of entity with respect to wrt_entity //! Returns MB_ENTITY_NOT_FOUND if no relationship found ErrorCode get_sense( EntityHandle entity, EntityHandle wrt_entity, int & sense ); //! Get the sense of the surface(s) with respect to the volume ErrorCode get_surface_senses( EntityHandle volume, int num_surfs, const EntityHandle* surfs, int* senses_out); //! Get the senses of a surface with respect to its volumes ErrorCode get_surface_senses(EntityHandle surface_ent, EntityHandle &forward_vol, EntityHandle &reverse_vol); //! Set the senses of a surface with respect to its volumes ErrorCode set_surface_senses(EntityHandle surface_ent, EntityHandle forward_vol, EntityHandle reverse_vol); //! Get the senses of the lower dimension entity handle wrt the higher dimension entities ErrorCode get_senses (EntityHandle entity, std::vector<EntityHandle> &wrt_entities, std::vector<int> &senses); //! Set the senses of the entity wrt multiple higher dimension entities ErrorCode set_senses (EntityHandle entity, std::vector<EntityHandle> &wrt_entities, std::vector<int> &senses); /** \brief Get the volume on the other side of a surface * * @param A surface to query * @param old_volume A volume on one side of surface * @param new_volume Output parameter for volume on the other side of surface * @return MB_SUCCESS if new_volume was set successfully, error if not. */ ErrorCode next_vol( EntityHandle surface, EntityHandle old_volume, EntityHandle& new_volume ); //! Retrieve geometry sets of desired dimension from model set // 0 = verts, 1 = curves, 2 = surfs, 3 = vols ErrorCode get_gsets_by_dimension( int dim, Range &gset); /** \brief Build obb tree for the entity set given; entity can be surface or volume * * @param eh EntityHandle of the volume or surface to construct the OBB tree around */ ErrorCode construct_obb_tree(EntityHandle eh); /** \brief Get the bouding points from a bounding box * * @param volume The volume for which the bounding coordinates are requested * @param minPt Location of the min xyz corner of the volume's axis-aligned bounding box * @param maxPt Location of the max xyz corner of the volume's axis-aligned bounding box */ ErrorCode get_bounding_coords(EntityHandle volume, double minPt[3], double maxPt[3]); /** \brief Get the center point and three vectors for the OBB of a given volume * * @param volume The volume for which the OBB axes will be returned * @param center coordinates of the oriented bounding box's center point * @param axis1 scaled axis one of the oriented bounding box * @param axis2 scaled axis two of the oriented bounding box * @param axis3 scaled axis three of the oriented bounding box */ ErrorCode get_obb(EntityHandle volume, double center[3], double axis1[3], double axis2[3], double axis3[3]); /** \brief Get the other (d-1)-dimensional entity bounding a set across a (d-2)-dimensional entity * * Given a d-dimensional entity and one (d-1)-dimensional entity, return the (d-1) dimensional * entity across a specified (d-2)-dimensional entity. For example, given a surface, edge, and vertex, * returns the other edge bounding the surface sharing the vertex. In the case of degenerate results, * e.g. two loops bounding a surface and sharing a vertex, tries to step in positively-oriented * direction. This won't always work; in those cases, will return MB_MULTIPLE_ENTITIES_FOUND. * * In the special case where bounded is a curve, then not_this can be a vertex and across zero. * This function returns the other vertex on the curve. */ ErrorCode other_entity(EntityHandle bounded, EntityHandle not_this, EntityHandle across, EntityHandle &other); /** \brief Return the dimension of the set, or -1 if it's not a geom_dimension set */ int dimension(EntityHandle this_set); /** \brief Return the global ID of a given entity set * * @param this_set EntitySet for which the global ID will be returned */ int global_id(EntityHandle this_set); //! Map from dimension & global ID to EntityHandle EntityHandle entity_by_id(int dimension, int id); ErrorCode find_geomsets(Range *ranges = NULL); //! Restore the internal cross-referencing of geometry sets and OBB roots // The EntityHandle of an OBB Root can be tagged onto the geoemtry EntitySet // that it represents so that this relationship can be recovered across // write to/read from file. Since finding the OBB Root for a given geomset // is frequent, a faster lookup capability is enabled through data structures // in GeomTopoTool (i.e. rootSets or mapRootSets). This data structure // needs to be populated upon file read. ErrorCode restore_obb_index(); //! Build obb trees for all surfaces and volumes in model set. // If make_one_vol true, joins trees from all surfaces in model into single // volume obb tree. ErrorCode construct_obb_trees(bool make_one_vol = false); //! Delete the OBB tree of a volume or surface. // If the passed entity is a volume, and the bool 'vol_only' // is True, function will delete the volume OBB tree, but // OBB trees of the surfaces that compose (are children of) // the volume will remain in tact. If the entity is a volume and // 'vol_only' is False, function will delete the volume OBB tree // along with all child surface OBB trees. ErrorCode delete_obb_tree(EntityHandle gset, bool vol_only = false); ErrorCode delete_all_obb_trees(); //! Delete the root of the obb tree from the set of all roots ErrorCode remove_root(EntityHandle vol_or_surf); //! Get the root of the obbtree for a given entity ErrorCode get_root(EntityHandle vol_or_surf, EntityHandle &root); //! If constructing one volume obb tree by joining all surface trees, // get the root of that tree EntityHandle get_one_vol_root(); //! Pointer to Oriented Box Tree Tool class OrientedBoxTreeTool *obb_tree() {return obbTree;} //! Adds a geometry set to the range of all geometry sets, the model set, and root set // Make sure the set has the proper geometry dimension tag // This could make the obb tree out of date ErrorCode add_geo_set(EntityHandle set, int dimension, int global_id = 0); //! Will assume no geo sets are defined for this surface // Will output a mesh_set that contains everything (all sets of interest), for proper output ErrorCode geometrize_surface_set(EntityHandle surface, EntityHandle & output); //! Checks to see if the entity is part of the model set ErrorCode is_owned_set(EntityHandle eh); //! This would be a deep copy, into a new geom topo tool // sets will be duplicated, but entities not // modelSet will be a new one; // will take as input a pointer to a std::vector of gents (surfaces and volumes, usually), // which will serve to filter the gents from modelSet (only dependents will be part of the new gtt) // if the pointer is null, all gsets in the original modelSet are duplicated ErrorCode duplicate_model(GeomTopoTool *& duplicate, std::vector<EntityHandle> * pvGEnts = NULL); //! Return the model set handle (this is the full geometry) EntityHandle get_root_model_set() { return modelSet; } //! Checks that all geometric entities were created properly bool check_model(); //! Should be used instead of keeping multiple ranges, for example in FBEngine const Range * geoRanges() { return geomRanges ; } //! Return pointer to moab instance Interface* get_moab_instance() { return mdbImpl; } //! Returns the sense tag (sense2Tag) from check_face_sense_tag Tag get_sense_tag(); //! Returns the global ID tag (gidTag) from check_gid_tag Tag get_gid_tag(); //! Returns the geometry dimension tag (geomTag) from check_geom_tag Tag get_geom_tag(); //! Returns true if obb trees have been added to the rootset bool have_obb_tree(); //! returns the number of entities in the modelSet with specified geometric dimension int num_ents_of_dim(int dim); //! sets the implicit complement handle for this tool ErrorCode setup_implicit_complement(); //! Get (or optionally, create) the implicit complement handle ErrorCode get_implicit_complement(EntityHandle &implicit_complement); //! detection method for the implicit complement bool is_implicit_complement(EntityHandle volume); /** \brief Discover and store the topological relationships among a set of volumes * This method may be used to discover the hierarchy that exists in a range of * volumes, that have no previous sense of hierarchy, and store it according * to the conventions of GeomTopoTool. * The following requirements about the range of flat_volumes must be met: * 1. Each volume must be represented by a single, closed surface * a. The surface meshsets have triangles and vertices as members. * b. For each "flat volume", there must be two meshsets: one for the * volume and another for the surface that encloses it. These must be * linked by a parent-child relationship. * c. The SENSE_FORWARD tag on the surface meshset must be set to be * the volume meshset it encloses. * 2. The surfaces must not touch or overlap * * After the hierarchy is established, the topological relationships between * surfaces and the volumes that enclose them are set. This involves: * 1. Setting parent-child relationship between surfaces and the volumes that * enclose them. * 2. Setting the SENSE_REVERSE tag on the surfaces to be the volume that * encloses them. * */ ErrorCode restore_topology_from_geometric_inclusion(const Range &flat_volumes); private: Interface *mdbImpl; Tag sense2Tag; Tag senseNEntsTag, senseNSensesTag; Tag geomTag; Tag gidTag; Tag nameTag; Tag obbRootTag; Tag obbGsetTag; // the model set encompasses a full topological model EntityHandle modelSet; // implicit complement handle cache EntityHandle impl_compl_handle; Range geomRanges[5];// add one more dimension, for set of gentities; by default, they will // have geom_dimension 4 int maxGlobalId[5]; // one max global id for each dimension bool updated; OrientedBoxTreeTool* obbTree; EntityHandle setOffset; std::vector<EntityHandle> rootSets; bool m_rootSets_vector; std::map<EntityHandle, EntityHandle> mapRootSets; EntityHandle oneVolRootSet; //! Creates a volume for undefined space in the model // The implicit complement is composed of all surfaces that only // have one parent volume, i.e. surfaces that are in contact with the outside // world ErrorCode generate_implicit_complement(EntityHandle &implicit_complement_set); //! Compute vertices inclusive and put on tag on sets in geom_sets ErrorCode construct_vertex_ranges(const Range &geom_sets, const Tag verts_tag); //! Given a range of geom topology sets, separate by dimension ErrorCode separate_by_dimension(const Range &geom_sets); //! Verify global id tag ErrorCode check_gid_tag(bool create = false); //! Verify geometry tag ErrorCode check_geom_tag(bool create = false); //! Verify sense face tag ErrorCode check_face_sense_tag(bool create = false); //! Verify sense edge tags ErrorCode check_edge_sense_tags(bool create = false); ErrorCode resize_rootSets(); ErrorCode set_root_set(EntityHandle vol_or_surf, EntityHandle root); //! Return a range of children of a desired geometric dimension Range get_ct_children_by_dimension(const EntityHandle parent, const int desired_dimension); //! Test if volume A is enclosed by volume B // This will only produce the correct result if the conventions about // volumes listed in the restore_topology_from_geometric_inclusion are // upheld bool A_is_in_B(const EntityHandle volume_A, const EntityHandle volume_B, GeomQueryTool* GQT); //! Used by restore_topology_from_geometric_inclusion to generate the // hierarchical tree of volumes ErrorCode insert_in_tree(const EntityHandle ct_root, const EntityHandle volume, GeomQueryTool* GQT); }; inline int GeomTopoTool::num_ents_of_dim(int dim) { assert(0 <= dim && 3 >= dim); return geomRanges[dim].size(); } // get the root of the obbtree for a given entity inline ErrorCode GeomTopoTool::get_root(EntityHandle vol_or_surf, EntityHandle &root) { if(m_rootSets_vector) { unsigned int index = vol_or_surf - setOffset; root = (index < rootSets.size() ? rootSets[index] : 0); } else root = mapRootSets[vol_or_surf]; return (root ? MB_SUCCESS : MB_INDEX_OUT_OF_RANGE); } inline EntityHandle GeomTopoTool::get_one_vol_root() { return oneVolRootSet; } inline Tag GeomTopoTool::get_sense_tag() { check_face_sense_tag(true); return sense2Tag; } inline Tag GeomTopoTool::get_gid_tag() { check_gid_tag(true); return gidTag; } inline Tag GeomTopoTool::get_geom_tag() { check_geom_tag(true); return geomTag; } inline bool GeomTopoTool::is_implicit_complement(EntityHandle volume) { return volume == impl_compl_handle; } } // namespace moab #endif
42.763819
109
0.710693
Formatted
728bbfd3b353f824eab7ca1245ec584c69b435bf
5,137
cpp
C++
glui_checkbox.cpp
brainoverflow98/glui
1e3efbea09a63c053a00d7388f105c58178f149a
[ "Zlib" ]
168
2015-09-24T12:41:54.000Z
2022-03-30T00:59:52.000Z
glui_checkbox.cpp
brainoverflow98/glui
1e3efbea09a63c053a00d7388f105c58178f149a
[ "Zlib" ]
101
2015-09-13T05:48:17.000Z
2021-08-10T02:28:31.000Z
glui_checkbox.cpp
brainoverflow98/glui
1e3efbea09a63c053a00d7388f105c58178f149a
[ "Zlib" ]
86
2015-09-24T12:34:47.000Z
2022-02-20T22:34:32.000Z
/**************************************************************************** GLUI User Interface Toolkit --------------------------- glui_checkbox - GLUI_Checkbox control class -------------------------------------------------- Copyright (c) 1998 Paul Rademacher WWW: https://github.com/libglui/glui Issues: https://github.com/libglui/glui/issues This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. *****************************************************************************/ #include "glui_internal_control.h" #include "tinyformat.h" /****************************** GLUI_Checkbox::GLUI_Checkbox() **********/ GLUI_Checkbox::GLUI_Checkbox( GLUI_Node *parent, const GLUI_String &name, int *value_ptr, int id, GLUI_CB cb ) { common_init(); set_ptr_val( value_ptr ); set_name( name ); user_id = id; callback = cb; parent->add_control( this ); init_live(); } void GLUI_Checkbox::common_init() { name = tfm::format("Checkbox: %p", this); w = 100; h = GLUI_CHECKBOX_SIZE; orig_value = -1; text_x_offset = 18; can_activate = true; live_type = GLUI_LIVE_INT; /* This control has an 'int' live var */ } /****************************** GLUI_Checkbox::mouse_down_handler() **********/ int GLUI_Checkbox::mouse_down_handler( int local_x, int local_y ) { orig_value = int_val; int_val = !int_val; currently_inside = true; redraw(); return false; } /****************************** GLUI_Checkbox::mouse_up_handler() **********/ int GLUI_Checkbox::mouse_up_handler( int local_x, int local_y, bool inside ) { if ( NOT inside ) { /* undo effect on value */ int_val = orig_value; } else { set_int_val( int_val ); /*** Invoke the callback ***/ execute_callback(); } return false; } /****************************** GLUI_Checkbox::mouse_held_down_handler() ******/ int GLUI_Checkbox::mouse_held_down_handler( int local_x, int local_y, bool inside) { /********** Toggle checked and unchecked bitmap if we're entering or leaving the checkbox area **********/ if ( inside != currently_inside ) { int_val = !int_val; currently_inside = inside; redraw(); } return false; } /****************************** GLUI_Checkbox::key_handler() **********/ int GLUI_Checkbox::key_handler( unsigned char key,int modifiers ) { return false; } /****************************** GLUI_Checkbox::draw() **********/ void GLUI_Checkbox::draw( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM if ( int_val != 0 ) { if ( enabled ) glui->std_bitmaps.draw( GLUI_STDBITMAP_CHECKBOX_ON, 0, 0 ); else glui->std_bitmaps.draw( GLUI_STDBITMAP_CHECKBOX_ON_DIS, 0, 0 ); } else { if ( enabled ) glui->std_bitmaps.draw( GLUI_STDBITMAP_CHECKBOX_OFF, 0, 0 ); else glui->std_bitmaps.draw( GLUI_STDBITMAP_CHECKBOX_OFF_DIS, 0, 0 ); } draw_active_area(); draw_name( text_x_offset, 10); } /**************************** GLUI_Checkbox::draw_active_area() **************/ void GLUI_Checkbox::draw_active_area() { GLUI_DRAWINGSENTINAL_IDIOM int text_width, left, right; text_width = _glutBitmapWidthString( glui->font, name.c_str() ); left = text_x_offset-3; right = left + 7 + text_width; if ( active ) { glEnable( GL_LINE_STIPPLE ); glLineStipple( 1, 0x5555 ); glColor3f( 0., 0., 0. ); } else { glColor3ubv( glui->bkgd_color ); } glBegin( GL_LINE_LOOP ); glVertex2i(left,0); glVertex2i( right,0); glVertex2i(right,h+1); glVertex2i( left,h+1); glEnd(); glDisable( GL_LINE_STIPPLE ); } /************************************ GLUI_Checkbox::update_size() **********/ void GLUI_Checkbox::update_size() { int text_size; if ( NOT glui ) return; text_size = _glutBitmapWidthString( glui->font, name.c_str() ); /* if ( w < text_x_offset + text_size + 6 ) */ w = text_x_offset + text_size + 6 ; } /********************************* GLUI_Checkbox::set_int_val() **************/ void GLUI_Checkbox::set_int_val( int new_val ) { int_val = new_val; /*** Update the variable we're (possibly) pointing to ***/ output_live(true); redraw(); }
25.181373
80
0.581078
brainoverflow98
728ca92ed223acacb3019ef7a297546a24aa050f
3,630
cpp
C++
5_GraphTheory/6_BinaryMatch/4_kuhn_munkres.cpp
JasongLee/Way-to-Algorithm-1
249a320845a960d942ae742cb5bd273e814a9e85
[ "MIT" ]
1
2017-04-16T15:23:29.000Z
2017-04-16T15:23:29.000Z
5_GraphTheory/6_BinaryMatch/4_kuhn_munkres.cpp
JasongLee/Way-to-Algorithm-1
249a320845a960d942ae742cb5bd273e814a9e85
[ "MIT" ]
null
null
null
5_GraphTheory/6_BinaryMatch/4_kuhn_munkres.cpp
JasongLee/Way-to-Algorithm-1
249a320845a960d942ae742cb5bd273e814a9e85
[ "MIT" ]
1
2018-07-19T00:52:39.000Z
2018-07-19T00:52:39.000Z
//Kuhn-Munkres算法 //kuhn_munkres.cpp //二分图B中的每条边都拥有一个正权值,为了方便该权值为正整数 //求二分带权图的具有最大权的完备匹配(也称最优匹配,最佳匹配) //1)基础概念 //二分带权图的最大权完备匹配问题是应用Kuhn-Munkres(简称KM)算法的典型场景 //顶点标号技术: //对于二分图B=<X,Y,E>的X集合中节点设置顶点标号A,Y集合中节点设置顶点标号B //即设置数组a_label和b_label,a_label[i](b_label[i])指代X(Y)集合中节点i的标号 //可行顶点标号: //对于二分图B中的每条边e,一个端点i属于X集合,另一个端点j属于Y集合 //标号都满足a_label[i] + b_label[j] >= value(e) //保证可行顶点标号总是存在的,设置一种平凡可行标号: //即设置X集合中每个节点i,其标号a_label[i]是节点i的所有邻边中权值最大的边的权值 //而Y集合中所有节点的标号b_label值都设置为0 //等价子图,相等子图: //二分图B的顶点标号中满足a_label[i]+b_label[j]=value(e)的边所组成的边集 //该边集的生成子图即为图B的相等子图 //需要注意:相等子图的节点集与原图B的节点集是相同的,即相等子图没有比原图B减少节点 //相等子图定理: //若二分图B的相等子图有完备匹配M,则M是二分图B的最大全完备匹配 // //由相等子图定理可知,欲求二分图的最大权完备匹配,只需求某个相等子图的完备匹配即可 //而完备匹配可以使用匈牙利算法求得 //Kuhn-Munkres算法使用一个方法对标号进行修改,使得新的相等子图的最大匹配逐渐扩大 //最终得到有完备匹配的相等子图,即求得最大全完备匹配 //当二分带权图中所有边的权值都是1时,该问题退化为二分完备匹配问题 // //2)具体实现 //设置数组a_label为X集合中的节点标号,数组b_label为Y集合中的节点标号 //初始时设置X中节点标号a_laebl为其所有邻边中最大的权值,Y中标号都为0 //对X中每个节点i重复以下步骤: //用匈牙利算法中dfs遍历的方法求当前标号下的等价子图B'的最大匹配 //在遍历过程中,如果从节点i出发的dfs找不到增广轨 //则从该节点出发的增广轨不存在完备匹配,按照以下方法对节点i出发的增广轨进行修改: //找到改进量d=min(A[i]+B[j]-value(e)),其中节点i属于a_label,节点j不属于b_label //然后改进节点的标号:A[i]=A[i]-d,B[j]=B[j]-d,其中i属于a_label,j属于b_label //然后继续进行匈牙利算法,直到求出完备匹配为止 // //该算法是二分图中最为难懂的算法,网上主要有两篇文档即本文最后列出的两篇 // //3)补注 //本文的代码中有一处判断条件与文档“带权二分图的最优匹配 Kuhn-Munkres算法(转)”不一致 //我在实际测试时发现原文档的代码由于缺少一处判断条件而得到错误答案 //在本文的代码中进行了修正 // //本文引用了“带权二分图的最优匹配 Kuhn-Munkres算法(转)”,作者“yulin11” //“Kuhn-Munkres算法(NOCOW)”,作者“Maigo” //“图论讲义 第3章(匹配问题)”,作者“高随祥” #include "general_head.h" #include "graph.h" void construct_s(bipartite b, int *a_label, int *b_label); int dfs_path(bipartite b, int *visit_x, int *visit_y, int p, int *ymatch, int *a_label, int *b_label); int kuhn_munkres(bipartite b, int *ymatch) {//二分图B存在完备匹配,故它的X和Y集合节点数量相同 //X集合有b_xn个节点,下标从0到b_xn-1,Y集合有b_yn个节点,下标从0到b_yn-1 //b_g[i][j]指代节点i和节点j之间的边的权值,其中节点i属于X集合,节点j属于Y集合 memset(ymatch, -1, MAX * sizeof(int)); //数组a_label和b_label为节点标号 //数组visit_x(visit_y)标记X(Y)集合中节点是否被访问过 int a_label[MAX], b_label[MAX], visit_x[MAX], visit_y[MAX]; //初始化节点标号数组a_label和b_label //X集合中每个节点i的标号初始化为其所有邻边中最大的权值,Y集合中所有节点i标号为0 //从而保证对于每条边e都有A[i]+B[i]>=value(e) construct_s(b, a_label, b_label); for(int i = 0; i < b.b_xn; ++ i) while(1){ memset(visit_x, 0, MAX * sizeof(int)); memset(visit_y, 0, MAX * sizeof(int)); if(dfs_path(b, visit_x, visit_y, i, ymatch, a_label, b_label)) break; int tmp_label(INF); for(int j = 0; j < b.b_xn; ++ j) if(visit_x[j]) for(int k = 0; k < b.b_yn; ++ k) if(!visit_y[k]) tmp_label = min(tmp_label, a_label[j] + b_label[k] - b.b_g[j][k]); for(int j = 0; j < b.b_xn; ++ j){ if(visit_x[j]) a_label[j] -= tmp_label; if(visit_y[j]) b_label[j] += tmp_label; } } int max_match(0); for(int i = 0; i < b.b_yn; ++ i) max_match += b.b_g[ymatch[i]][i]; return(max_match); } void construct_s(bipartite b, int *a_label, int *b_label) { memset(a_label, 0, MAX * sizeof(int)); memset(b_label, 0, MAX * sizeof(int)); for(int i = 0; i < b.b_xn; ++ i) for(int j = 0; j < b.b_yn; ++ j) a_label[i] = max(a_label[i], b.b_g[i][j]); } int dfs_path(bipartite b, int *visit_x, int *visit_y, int p, int *ymatch, int *a_label, int *b_label) { visit_x[p] = 1; for(int i = 0; i < b.b_yn; ++ i) if(!visit_y[i] && b.b_g[p][i] && a_label[p] + b_label[i] == b.b_g[p][i]){ //“带权二分图的最优匹配 Kuhn-Munkres算法(转)”中缺少的判断条件是 //b.b_g[p][i]这一句,即判断节点p与节点i之间存在边 //本文之前的若干二分图算法的代码中都有这个判断,此处应该是原作者的失误 visit_y[i] = 1; if(ymatch[i] == -1 || dfs_path(b, visit_x, visit_y, ymatch[i], ymatch, a_label, b_label)){ ymatch[i] = p; return(1); } } return(0); }
29.04
65
0.696694
JasongLee
728de9f4655a0306ccf2ffd3fc67f8739d17b720
3,512
inl
C++
cpp/win/include/ktn/stringw.inl
kittttttan/ktn
70ff0848ea7c97a9fa2ad85e2adfb48312037d58
[ "MIT" ]
null
null
null
cpp/win/include/ktn/stringw.inl
kittttttan/ktn
70ff0848ea7c97a9fa2ad85e2adfb48312037d58
[ "MIT" ]
null
null
null
cpp/win/include/ktn/stringw.inl
kittttttan/ktn
70ff0848ea7c97a9fa2ad85e2adfb48312037d58
[ "MIT" ]
null
null
null
#pragma once #include "ktn/dbg.h" #include "ktn/util.h" #include <assert.h> #include <locale.h> #include <stdio.h> #include <algorithm> #include <sstream> namespace ktn { inline StringW& StringW::operator=(const StringW& s) { if (this == &s) { return *this; } str_ = s.str_; return *this; } inline std::wostream& operator<<(std::wostream& os, const StringW& s) { return os << s.str_.c_str(); } inline std::wistream& operator>>(std::wistream& is, StringW& s) { std::wstring str; is >> str; s.str_ = str; return is; } inline wchar_t& StringW::operator[](int index) { if (index < 0) { index += static_cast<int>(str_.size()); } return str_[index]; } inline bool StringW::operator!() const { return str_.empty(); } inline StringW StringW::operator-() const { StringW res(*this); std::reverse(res.str_.begin(), res.str_.end()); return res; } inline size_t StringW::indexOf(const wchar_t c, int from) const { return str_.find(c); } inline size_t StringW::lastIndexOf(const wchar_t c, int from) const { return str_.rfind(c); } inline StringW& StringW::toUpperCase() { std::transform(str_.begin(), str_.end(), str_.begin(), ::toupper); return *this; } inline StringW& StringW::toLowerCase() { std::transform(str_.begin(), str_.end(), str_.begin(), ::tolower); return *this; } inline StringW& StringW::substr(int from, int length) { str_ = str_.substr(from, length); return *this; } inline StringW& StringW::slice(int from, int to) { if (str_.empty()) return *this; int size = static_cast<int>(str_.size()); assert(size); from %= size; to %= size; if (from < 0) { from += size; } if (to < 0) { to += size; } int length = to - from + 1; if (length <= 0) { str_ = L""; return *this; } return substr(from, length); } inline StringW& StringW::trimLeft(const wchar_t* delim) { const size_t p1 = str_.find_first_not_of(delim); if (p1 == std::string::npos) { str_ = L""; return *this; } str_ = str_.substr(p1); return *this; } inline StringW& StringW::trimRight(const wchar_t* delim) { const size_t p2 = str_.find_last_not_of(delim); str_ = str_.substr(0, p2 + 1); return *this; } inline StringW& StringW::trim(const wchar_t* delim) { const size_t p1 = str_.find_first_not_of(delim); if (p1 == std::string::npos) { str_ = L""; return *this; } const size_t p2 = str_.find_last_not_of(delim); str_ = str_.substr(p1, p2 - p1 + 1); return *this; } inline StringW StringW::operator+(const StringW& s) const { std::wstring n(str_); n += s.str_; return StringW(n); } inline StringW& StringW::operator+=(const StringW& b) { str_ += b.str_; return *this; } inline StringW& StringW::operator+=(const wchar_t* b) { str_ += b; return *this; } inline StringW& StringW::operator-=(const wchar_t c) { str_.erase( std::remove_if(str_.begin(), str_.end(), [c](wchar_t ch) -> bool { return ch == c; }), str_.end() ); return *this; } inline StringW& StringW::operator*=(int times) { if (!times) { str_ = L""; return *this; } std::wstring str(str_); if (times < 0) { for (int i = 1; i < -times; ++i) { str_ += str; } std::reverse(str_.begin(), str_.end()); } else { for (int i = 1; i < times; ++i) { str_ += str; } } return *this; } inline bool StringW::operator==(const StringW& s) const { if (this == &s) { return true; } return str_.compare(s.str_) == 0; } inline bool StringW::operator!=(const StringW& s) const { if (this == &s) { return false; } return str_.compare(s.str_) != 0; } } // namespace ktn
17.827411
69
0.639237
kittttttan
728f19ff5d8f3f0b8ff62a652f2e6f83528db037
431
hpp
C++
obs-studio/UI/double-slider.hpp
noelemahcz/libobspp
029472b973e5a1985f883242f249848385df83a3
[ "MIT" ]
null
null
null
obs-studio/UI/double-slider.hpp
noelemahcz/libobspp
029472b973e5a1985f883242f249848385df83a3
[ "MIT" ]
null
null
null
obs-studio/UI/double-slider.hpp
noelemahcz/libobspp
029472b973e5a1985f883242f249848385df83a3
[ "MIT" ]
null
null
null
#pragma once #include <QSlider> #include "slider-ignorewheel.hpp" class DoubleSlider : public SliderIgnoreScroll { Q_OBJECT double minVal, maxVal, minStep; public: DoubleSlider(QWidget *parent = nullptr); void setDoubleConstraints(double newMin, double newMax, double newStep, double val); signals: void doubleValChanged(double val); public slots: void intValChanged(int val); void setDoubleVal(double val); };
17.958333
72
0.761021
noelemahcz
7291161e0ce6363ab4a456ea9301afe94fef1c95
685,719
cpp
C++
test/generated/tailoring_rule_test_zh_zhuyin_004.cpp
Ryan-rsm-McKenzie/text
15aaea4297e00ec4c74295e7913ead79c90e1502
[ "BSL-1.0" ]
265
2017-07-09T23:23:48.000Z
2022-03-24T10:14:19.000Z
test/generated/tailoring_rule_test_zh_zhuyin_004.cpp
Ryan-rsm-McKenzie/text
15aaea4297e00ec4c74295e7913ead79c90e1502
[ "BSL-1.0" ]
185
2017-08-30T16:44:51.000Z
2021-08-13T12:02:46.000Z
test/generated/tailoring_rule_test_zh_zhuyin_004.cpp
Ryan-rsm-McKenzie/text
15aaea4297e00ec4c74295e7913ead79c90e1502
[ "BSL-1.0" ]
25
2017-08-29T23:07:23.000Z
2021-09-03T06:31:29.000Z
// Copyright (C) 2020 T. Zachary Laine // // 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) // 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 = [](std::string const & s) { std::cout << s; }; auto const warning = [](std::string const & s) {}; collation_table make_save_load_table() { #ifdef LIMIT_TESTING_FOR_CI std::string const table_str(data::zh::zhuyin_collation_tailoring()); return tailored_collation_table( table_str, "zh::zhuyin_collation_tailoring()", error, warning); #else if (!exists(boost::filesystem::path("zh_zhuyin.table"))) { std::string const table_str(data::zh::zhuyin_collation_tailoring()); collation_table table = tailored_collation_table( table_str, "zh::zhuyin_collation_tailoring()", error, warning); save_table(table, "zh_zhuyin.table.4"); boost::filesystem::rename("zh_zhuyin.table.4", "zh_zhuyin.table"); } return load_table("zh_zhuyin.table"); #endif } collation_table const & table() { static collation_table retval = make_save_load_table(); return retval; } TEST(tailoring, zh_zhuyin_003_000) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4eb8); auto const rel = std::vector<uint32_t>(1, 0x937a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x937a); auto const rel = std::vector<uint32_t>(1, 0x8ec3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ec3); auto const rel = std::vector<uint32_t>(1, 0x56b2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x5972); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x5234); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5234); auto const rel = std::vector<uint32_t>(1, 0x5241); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5241); auto const rel = std::vector<uint32_t>(1, 0x9973); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9973); auto const rel = std::vector<uint32_t>(1, 0x5c2e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c2e); auto const rel = std::vector<uint32_t>(1, 0x67c1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67c1); auto const rel = std::vector<uint32_t>(1, 0x67ee); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67ee); auto const rel = std::vector<uint32_t>(1, 0x70a8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70a8); auto const rel = std::vector<uint32_t>(1, 0x964a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x964a); auto const rel = std::vector<uint32_t>(1, 0x964f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x964f); auto const rel = std::vector<uint32_t>(1, 0x6857); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6857); auto const rel = std::vector<uint32_t>(1, 0x5815); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5815); auto const rel = std::vector<uint32_t>(1, 0x8235); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8235); auto const rel = std::vector<uint32_t>(1, 0x60f0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60f0); auto const rel = std::vector<uint32_t>(1, 0x8de2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8de2); auto const rel = std::vector<uint32_t>(1, 0x8de5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8de5); auto const rel = std::vector<uint32_t>(1, 0x8dfa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dfa); auto const rel = std::vector<uint32_t>(1, 0x98ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98ff); auto const rel = std::vector<uint32_t>(1, 0x3ee7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3ee7); auto const rel = std::vector<uint32_t>(1, 0x58ae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58ae); auto const rel = std::vector<uint32_t>(1, 0x58af); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58af); auto const rel = std::vector<uint32_t>(1, 0x5d9e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d9e); auto const rel = std::vector<uint32_t>(1, 0x9d7d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x67a4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67a4); auto const rel = std::vector<uint32_t>(1, 0x5796); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5796); auto const rel = std::vector<uint32_t>(1, 0x5806); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5806); auto const rel = std::vector<uint32_t>(1, 0x5860); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5860); auto const rel = std::vector<uint32_t>(1, 0x5d5f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d5f); auto const rel = std::vector<uint32_t>(1, 0x75fd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75fd); auto const rel = std::vector<uint32_t>(1, 0x78d3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78d3); auto const rel = std::vector<uint32_t>(1, 0x9d2d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d2d); auto const rel = std::vector<uint32_t>(1, 0x941c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x941c); auto const rel = std::vector<uint32_t>(1, 0x3a03); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3a03); auto const rel = std::vector<uint32_t>(1, 0x9827); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9827); auto const rel = std::vector<uint32_t>(1, 0x5bf9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5bf9); auto const rel = std::vector<uint32_t>(1, 0x961f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x961f); auto const rel = std::vector<uint32_t>(1, 0x514a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x514a); auto const rel = std::vector<uint32_t>(1, 0x514c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x514c); auto const rel = std::vector<uint32_t>(1, 0x5151); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5151); auto const rel = std::vector<uint32_t>(1, 0x5bfe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5bfe); auto const rel = std::vector<uint32_t>(1, 0x603c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x603c); auto const rel = std::vector<uint32_t>(1, 0x794b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x794b); auto const rel = std::vector<uint32_t>(1, 0x966e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x966e); auto const rel = std::vector<uint32_t>(1, 0x968a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x968a); auto const rel = std::vector<uint32_t>(1, 0x7893); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7893); auto const rel = std::vector<uint32_t>(1, 0x41cf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x41cf); auto const rel = std::vector<uint32_t>(1, 0x7d90); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d90); auto const rel = std::vector<uint32_t>(1, 0x5c0d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_001) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c0d); auto const rel = std::vector<uint32_t>(1, 0x619e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x619e); auto const rel = std::vector<uint32_t>(1, 0x619d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x619d); auto const rel = std::vector<uint32_t>(1, 0x6fe7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6fe7); auto const rel = std::vector<uint32_t>(1, 0x9566); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9566); auto const rel = std::vector<uint32_t>(1, 0x61df); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61df); auto const rel = std::vector<uint32_t>(1, 0x8968); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8968); auto const rel = std::vector<uint32_t>(1, 0x3b23); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b23); auto const rel = std::vector<uint32_t>(1, 0x85b1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85b1); auto const rel = std::vector<uint32_t>(1, 0x7029); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7029); auto const rel = std::vector<uint32_t>(1, 0x8b48); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b48); auto const rel = std::vector<uint32_t>(1, 0x9413); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x8011); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8011); auto const rel = std::vector<uint32_t>(1, 0x5073); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5073); auto const rel = std::vector<uint32_t>(1, 0x526c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x526c); auto const rel = std::vector<uint32_t>(1, 0x5a8f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a8f); auto const rel = std::vector<uint32_t>(1, 0x7aef); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7aef); auto const rel = std::vector<uint32_t>(1, 0x890d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x890d); auto const rel = std::vector<uint32_t>(1, 0x9374); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9374); auto const rel = std::vector<uint32_t>(1, 0x22b43); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x22b43); auto const rel = std::vector<uint32_t>(1, 0x77ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77ed); auto const rel = std::vector<uint32_t>(1, 0x6bb5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bb5); auto const rel = std::vector<uint32_t>(1, 0x65ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65ad); auto const rel = std::vector<uint32_t>(1, 0x5845); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5845); auto const rel = std::vector<uint32_t>(1, 0x7f0e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f0e); auto const rel = std::vector<uint32_t>(1, 0x6934); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6934); auto const rel = std::vector<uint32_t>(1, 0x7145); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7145); auto const rel = std::vector<uint32_t>(1, 0x7456); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7456); auto const rel = std::vector<uint32_t>(1, 0x8176); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8176); auto const rel = std::vector<uint32_t>(1, 0x846e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x846e); auto const rel = std::vector<uint32_t>(1, 0x78ab); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78ab); auto const rel = std::vector<uint32_t>(1, 0x953b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x953b); auto const rel = std::vector<uint32_t>(1, 0x7dde); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7dde); auto const rel = std::vector<uint32_t>(1, 0x6bc8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bc8); auto const rel = std::vector<uint32_t>(1, 0x7c16); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c16); auto const rel = std::vector<uint32_t>(1, 0x935b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x935b); auto const rel = std::vector<uint32_t>(1, 0x65b7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65b7); auto const rel = std::vector<uint32_t>(1, 0x8e96); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x7c6a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x5428); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5428); auto const rel = std::vector<uint32_t>(1, 0x60c7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60c7); auto const rel = std::vector<uint32_t>(1, 0x6566); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6566); auto const rel = std::vector<uint32_t>(1, 0x8733); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8733); auto const rel = std::vector<uint32_t>(1, 0x58a9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58a9); auto const rel = std::vector<uint32_t>(1, 0x58aa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58aa); auto const rel = std::vector<uint32_t>(1, 0x64b4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64b4); auto const rel = std::vector<uint32_t>(1, 0x7364); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7364); auto const rel = std::vector<uint32_t>(1, 0x5678); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5678); auto const rel = std::vector<uint32_t>(1, 0x6489); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6489); auto const rel = std::vector<uint32_t>(1, 0x6a54); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a54); auto const rel = std::vector<uint32_t>(1, 0x729c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x729c); auto const rel = std::vector<uint32_t>(1, 0x7905); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_002) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7905); auto const rel = std::vector<uint32_t>(1, 0x453b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x453b); auto const rel = std::vector<uint32_t>(1, 0x8e72); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e72); auto const rel = std::vector<uint32_t>(1, 0x8e7e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e7e); auto const rel = std::vector<uint32_t>(1, 0x9a50); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x233b4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x233b4); auto const rel = std::vector<uint32_t>(1, 0x76f9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76f9); auto const rel = std::vector<uint32_t>(1, 0x8db8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8db8); auto const rel = std::vector<uint32_t>(1, 0x8e89); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e89); auto const rel = std::vector<uint32_t>(1, 0x4f05); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f05); auto const rel = std::vector<uint32_t>(1, 0x56e4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56e4); auto const rel = std::vector<uint32_t>(1, 0x5e89); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e89); auto const rel = std::vector<uint32_t>(1, 0x6c8c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c8c); auto const rel = std::vector<uint32_t>(1, 0x7096); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7096); auto const rel = std::vector<uint32_t>(1, 0x76fe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76fe); auto const rel = std::vector<uint32_t>(1, 0x7818); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7818); auto const rel = std::vector<uint32_t>(1, 0x949d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x949d); auto const rel = std::vector<uint32_t>(1, 0x9007); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9007); auto const rel = std::vector<uint32_t>(1, 0x987f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x987f); auto const rel = std::vector<uint32_t>(1, 0x920d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x920d); auto const rel = std::vector<uint32_t>(1, 0x696f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x696f); auto const rel = std::vector<uint32_t>(1, 0x9041); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9041); auto const rel = std::vector<uint32_t>(1, 0x9813); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9813); auto const rel = std::vector<uint32_t>(1, 0x6f61); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f61); auto const rel = std::vector<uint32_t>(1, 0x906f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x906f); auto const rel = std::vector<uint32_t>(1, 0x71c9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71c9); auto const rel = std::vector<uint32_t>(1, 0x8e32); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e32); auto const rel = std::vector<uint32_t>(1, 0x78b7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78b7); auto const rel = std::vector<uint32_t>(1, 0x4e1c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e1c); auto const rel = std::vector<uint32_t>(1, 0x51ac); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x51ac); auto const rel = std::vector<uint32_t>(1, 0x549a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x549a); auto const rel = std::vector<uint32_t>(1, 0x36b5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x36b5); auto const rel = std::vector<uint32_t>(1, 0x5cbd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cbd); auto const rel = std::vector<uint32_t>(1, 0x6771); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6771); auto const rel = std::vector<uint32_t>(1, 0x6638); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6638); auto const rel = std::vector<uint32_t>(1, 0x6c21); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c21); auto const rel = std::vector<uint32_t>(1, 0x82f3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82f3); auto const rel = std::vector<uint32_t>(1, 0x5032); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5032); auto const rel = std::vector<uint32_t>(1, 0x9e2b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e2b); auto const rel = std::vector<uint32_t>(1, 0x57ec); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57ec); auto const rel = std::vector<uint32_t>(1, 0x5a3b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a3b); auto const rel = std::vector<uint32_t>(1, 0x5d20); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d20); auto const rel = std::vector<uint32_t>(1, 0x5d2c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d2c); auto const rel = std::vector<uint32_t>(1, 0x6db7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6db7); auto const rel = std::vector<uint32_t>(1, 0x7b17); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b17); auto const rel = std::vector<uint32_t>(1, 0x5f9a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f9a); auto const rel = std::vector<uint32_t>(1, 0x6c2d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c2d); auto const rel = std::vector<uint32_t>(1, 0x83c4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83c4); auto const rel = std::vector<uint32_t>(1, 0x29093); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x29093); auto const rel = std::vector<uint32_t>(1, 0x8740); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8740); auto const rel = std::vector<uint32_t>(1, 0x9d24); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d24); auto const rel = std::vector<uint32_t>(1, 0x9f15); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_003) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f15); auto const rel = std::vector<uint32_t>(1, 0x9bdf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bdf); auto const rel = std::vector<uint32_t>(1, 0x9d87); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x3a02); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3a02); auto const rel = std::vector<uint32_t>(1, 0x8463); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8463); auto const rel = std::vector<uint32_t>(1, 0x58a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58a5); auto const rel = std::vector<uint32_t>(1, 0x7bbd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7bbd); auto const rel = std::vector<uint32_t>(1, 0x8acc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8acc); auto const rel = std::vector<uint32_t>(1, 0x5b1e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b1e); auto const rel = std::vector<uint32_t>(1, 0x23fc5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x23fc5); auto const rel = std::vector<uint32_t>(1, 0x856b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x856b); auto const rel = std::vector<uint32_t>(1, 0x61c2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61c2); auto const rel = std::vector<uint32_t>(1, 0x52a8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x52a8); auto const rel = std::vector<uint32_t>(1, 0x51bb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x51bb); auto const rel = std::vector<uint32_t>(1, 0x4f97); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f97); auto const rel = std::vector<uint32_t>(1, 0x578c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x578c); auto const rel = std::vector<uint32_t>(1, 0x59db); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x59db); auto const rel = std::vector<uint32_t>(1, 0x5cd2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cd2); auto const rel = std::vector<uint32_t>(1, 0x606b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x606b); auto const rel = std::vector<uint32_t>(1, 0x630f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x630f); auto const rel = std::vector<uint32_t>(1, 0x680b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x680b); auto const rel = std::vector<uint32_t>(1, 0x6d1e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d1e); auto const rel = std::vector<uint32_t>(1, 0x80e8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80e8); auto const rel = std::vector<uint32_t>(1, 0x51cd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x51cd); auto const rel = std::vector<uint32_t>(1, 0x6219); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6219); auto const rel = std::vector<uint32_t>(1, 0x80f4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80f4); auto const rel = std::vector<uint32_t>(1, 0x8ff5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ff5); auto const rel = std::vector<uint32_t>(1, 0x52d5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x52d5); auto const rel = std::vector<uint32_t>(1, 0x7850); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7850); auto const rel = std::vector<uint32_t>(1, 0x68df); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x68df); auto const rel = std::vector<uint32_t>(1, 0x6e69); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e69); auto const rel = std::vector<uint32_t>(1, 0x7d67); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d67); auto const rel = std::vector<uint32_t>(1, 0x8156); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8156); auto const rel = std::vector<uint32_t>(1, 0x50cd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x50cd); auto const rel = std::vector<uint32_t>(1, 0x99e7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99e7); auto const rel = std::vector<uint32_t>(1, 0x9718); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9718); auto const rel = std::vector<uint32_t>(1, 0x9b97); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b97); auto const rel = std::vector<uint32_t>(1, 0x9dab); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dab); auto const rel = std::vector<uint32_t>{0xfdd0, 0x310a}; std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>{0xfdd0, 0x310a}; auto const rel = std::vector<uint32_t>(1, 0x4ed6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ed6); auto const rel = std::vector<uint32_t>(1, 0x5b83); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b83); auto const rel = std::vector<uint32_t>(1, 0x5979); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5979); auto const rel = std::vector<uint32_t>(1, 0x7260); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7260); auto const rel = std::vector<uint32_t>(1, 0x7942); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7942); auto const rel = std::vector<uint32_t>(1, 0x94ca); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94ca); auto const rel = std::vector<uint32_t>(1, 0x8dbf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dbf); auto const rel = std::vector<uint32_t>(1, 0x584c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x584c); auto const rel = std::vector<uint32_t>(1, 0x6ebb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ebb); auto const rel = std::vector<uint32_t>(1, 0x6999); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6999); auto const rel = std::vector<uint32_t>(1, 0x891f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x891f); auto const rel = std::vector<uint32_t>(1, 0x5683); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5683); auto const rel = std::vector<uint32_t>(1, 0x95e7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_004) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95e7); auto const rel = std::vector<uint32_t>(1, 0x8e79); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e79); auto const rel = std::vector<uint32_t>(1, 0x5854); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5854); auto const rel = std::vector<uint32_t>(1, 0x6e9a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e9a); auto const rel = std::vector<uint32_t>(1, 0x5896); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5896); auto const rel = std::vector<uint32_t>(1, 0x35f3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x35f3); auto const rel = std::vector<uint32_t>(1, 0x736d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x736d); auto const rel = std::vector<uint32_t>(1, 0x9cce); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9cce); auto const rel = std::vector<uint32_t>(1, 0x737a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x737a); auto const rel = std::vector<uint32_t>(1, 0x9c28); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x4ea3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ea3); auto const rel = std::vector<uint32_t>(1, 0x62d3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62d3); auto const rel = std::vector<uint32_t>(1, 0x631e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x631e); auto const rel = std::vector<uint32_t>(1, 0x72e7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72e7); auto const rel = std::vector<uint32_t>(1, 0x95fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95fc); auto const rel = std::vector<uint32_t>(1, 0x20d32); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x20d32); auto const rel = std::vector<uint32_t>(1, 0x36e5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x36e5); auto const rel = std::vector<uint32_t>(1, 0x5d09); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d09); auto const rel = std::vector<uint32_t>(1, 0x6dbe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6dbe); auto const rel = std::vector<uint32_t>(1, 0x3b7c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b7c); auto const rel = std::vector<uint32_t>(1, 0x6428); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6428); auto const rel = std::vector<uint32_t>(1, 0x40bf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x40bf); auto const rel = std::vector<uint32_t>(1, 0x8df6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8df6); auto const rel = std::vector<uint32_t>(1, 0x69bb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x69bb); auto const rel = std::vector<uint32_t>(1, 0x6bfe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bfe); auto const rel = std::vector<uint32_t>(1, 0x420b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x420b); auto const rel = std::vector<uint32_t>(1, 0x905d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x905d); auto const rel = std::vector<uint32_t>(1, 0x9062); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9062); auto const rel = std::vector<uint32_t>(1, 0x3493); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3493); auto const rel = std::vector<uint32_t>(1, 0x79a2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79a2); auto const rel = std::vector<uint32_t>(1, 0x8abb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8abb); auto const rel = std::vector<uint32_t>(1, 0x8e0f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e0f); auto const rel = std::vector<uint32_t>(1, 0x64bb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64bb); auto const rel = std::vector<uint32_t>(1, 0x6fbe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6fbe); auto const rel = std::vector<uint32_t>(1, 0x9314); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9314); auto const rel = std::vector<uint32_t>(1, 0x6a7d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a7d); auto const rel = std::vector<uint32_t>(1, 0x6fcc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6fcc); auto const rel = std::vector<uint32_t>(1, 0x8e4b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e4b); auto const rel = std::vector<uint32_t>(1, 0x979c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x979c); auto const rel = std::vector<uint32_t>(1, 0x9b99); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b99); auto const rel = std::vector<uint32_t>(1, 0x3ff9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3ff9); auto const rel = std::vector<uint32_t>(1, 0x95d2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95d2); auto const rel = std::vector<uint32_t>(1, 0x97b3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97b3); auto const rel = std::vector<uint32_t>(1, 0x56ba); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56ba); auto const rel = std::vector<uint32_t>(1, 0x8b76); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b76); auto const rel = std::vector<uint32_t>(1, 0x95e5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x2a601); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2a601); auto const rel = std::vector<uint32_t>(1, 0x8ea2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ea2); auto const rel = std::vector<uint32_t>(1, 0x4fa4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4fa4); auto const rel = std::vector<uint32_t>(1, 0x549c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x549c); auto const rel = std::vector<uint32_t>(1, 0x5fd1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fd1); auto const rel = std::vector<uint32_t>(1, 0x5fd2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_005) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fd2); auto const rel = std::vector<uint32_t>(1, 0x7279); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7279); auto const rel = std::vector<uint32_t>(1, 0x8ca3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ca3); auto const rel = std::vector<uint32_t>(1, 0x86ae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x86ae); auto const rel = std::vector<uint32_t>(1, 0x94fd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94fd); auto const rel = std::vector<uint32_t>(1, 0x615d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x615d); auto const rel = std::vector<uint32_t>(1, 0x92f1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92f1); auto const rel = std::vector<uint32_t>(1, 0x87a3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x87a3); auto const rel = std::vector<uint32_t>(1, 0x87d8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x87d8); auto const rel = std::vector<uint32_t>(1, 0x56fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56fc); auto const rel = std::vector<uint32_t>(1, 0x5b61); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b61); auto const rel = std::vector<uint32_t>(1, 0x80ce); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80ce); auto const rel = std::vector<uint32_t>(1, 0x51ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x51ad); auto const rel = std::vector<uint32_t>(1, 0x53f0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x53f0); auto const rel = std::vector<uint32_t>(1, 0x65f2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65f2); auto const rel = std::vector<uint32_t>(1, 0x576e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x576e); auto const rel = std::vector<uint32_t>(1, 0x62ac); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62ac); auto const rel = std::vector<uint32_t>(1, 0x90b0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x90b0); auto const rel = std::vector<uint32_t>(1, 0x67b1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67b1); auto const rel = std::vector<uint32_t>(1, 0x70b1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70b1); auto const rel = std::vector<uint32_t>(1, 0x70b2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70b2); auto const rel = std::vector<uint32_t>(1, 0x82d4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82d4); auto const rel = std::vector<uint32_t>(1, 0x83ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83ed); auto const rel = std::vector<uint32_t>(1, 0x8dc6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dc6); auto const rel = std::vector<uint32_t>(1, 0x3b03); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b03); auto const rel = std::vector<uint32_t>(1, 0x9c90); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c90); auto const rel = std::vector<uint32_t>(1, 0x7b88); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b88); auto const rel = std::vector<uint32_t>(1, 0x81fa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81fa); auto const rel = std::vector<uint32_t>(1, 0x98b1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98b1); auto const rel = std::vector<uint32_t>(1, 0x421a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x421a); auto const rel = std::vector<uint32_t>(1, 0x99d8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99d8); auto const rel = std::vector<uint32_t>(1, 0x5113); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5113); auto const rel = std::vector<uint32_t>(1, 0x9b90); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b90); auto const rel = std::vector<uint32_t>(1, 0x5b2f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b2f); auto const rel = std::vector<uint32_t>(1, 0x64e1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64e1); auto const rel = std::vector<uint32_t>(1, 0x3e00); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3e00); auto const rel = std::vector<uint32_t>(1, 0x6aaf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aaf); auto const rel = std::vector<uint32_t>(1, 0x85b9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85b9); auto const rel = std::vector<uint32_t>(1, 0x7c49); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x592a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x592a); auto const rel = std::vector<uint32_t>(1, 0x5933); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5933); auto const rel = std::vector<uint32_t>(1, 0x5ff2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ff2); auto const rel = std::vector<uint32_t>(1, 0x6c70); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c70); auto const rel = std::vector<uint32_t>(1, 0x6001); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6001); auto const rel = std::vector<uint32_t>(1, 0x80bd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80bd); auto const rel = std::vector<uint32_t>(1, 0x949b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x949b); auto const rel = std::vector<uint32_t>(1, 0x6cf0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cf0); auto const rel = std::vector<uint32_t>(1, 0x8226); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8226); auto const rel = std::vector<uint32_t>(1, 0x48ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x48ed); auto const rel = std::vector<uint32_t>(1, 0x915e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x915e); auto const rel = std::vector<uint32_t>(1, 0x9226); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9226); auto const rel = std::vector<uint32_t>(1, 0x6e99); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_006) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e99); auto const rel = std::vector<uint32_t>(1, 0x614b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x614b); auto const rel = std::vector<uint32_t>(1, 0x71e4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71e4); auto const rel = std::vector<uint32_t>(1, 0x7c8f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c8f); auto const rel = std::vector<uint32_t>(1, 0x5932); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5932); auto const rel = std::vector<uint32_t>(1, 0x5f22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f22); auto const rel = std::vector<uint32_t>(1, 0x6d9b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d9b); auto const rel = std::vector<uint32_t>(1, 0x7ee6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ee6); auto const rel = std::vector<uint32_t>(1, 0x638f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x638f); auto const rel = std::vector<uint32_t>(1, 0x8a5c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a5c); auto const rel = std::vector<uint32_t>(1, 0x5acd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5acd); auto const rel = std::vector<uint32_t>(1, 0x5e4d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e4d); auto const rel = std::vector<uint32_t>(1, 0x6146); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6146); auto const rel = std::vector<uint32_t>(1, 0x642f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x642f); auto const rel = std::vector<uint32_t>(1, 0x6ed4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ed4); auto const rel = std::vector<uint32_t>(1, 0x7d5b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d5b); auto const rel = std::vector<uint32_t>(1, 0x69c4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x69c4); auto const rel = std::vector<uint32_t>(1, 0x746b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x746b); auto const rel = std::vector<uint32_t>(1, 0x97ec); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97ec); auto const rel = std::vector<uint32_t>(1, 0x98f8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98f8); auto const rel = std::vector<uint32_t>(1, 0x4231); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4231); auto const rel = std::vector<uint32_t>(1, 0x7e1a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e1a); auto const rel = std::vector<uint32_t>(1, 0x7e27); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e27); auto const rel = std::vector<uint32_t>(1, 0x6fe4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6fe4); auto const rel = std::vector<uint32_t>(1, 0x8b1f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b1f); auto const rel = std::vector<uint32_t>(1, 0x8f41); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f41); auto const rel = std::vector<uint32_t>(1, 0x493e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x493e); auto const rel = std::vector<uint32_t>(1, 0x97b1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97b1); auto const rel = std::vector<uint32_t>(1, 0x97dc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97dc); auto const rel = std::vector<uint32_t>(1, 0x9955); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9955); auto const rel = std::vector<uint32_t>(1, 0x530b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x530b); auto const rel = std::vector<uint32_t>(1, 0x54b7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x54b7); auto const rel = std::vector<uint32_t>(1, 0x6d2e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d2e); auto const rel = std::vector<uint32_t>(1, 0x8fef); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fef); auto const rel = std::vector<uint32_t>(1, 0x6843); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6843); auto const rel = std::vector<uint32_t>(1, 0x9003); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9003); auto const rel = std::vector<uint32_t>(1, 0x5555); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5555); auto const rel = std::vector<uint32_t>(1, 0x68bc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x68bc); auto const rel = std::vector<uint32_t>(1, 0x6dd8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6dd8); auto const rel = std::vector<uint32_t>(1, 0x413b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x413b); auto const rel = std::vector<uint32_t>(1, 0x7ef9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ef9); auto const rel = std::vector<uint32_t>(1, 0x9676); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9676); auto const rel = std::vector<uint32_t>(1, 0x8404); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8404); auto const rel = std::vector<uint32_t>(1, 0x7979); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7979); auto const rel = std::vector<uint32_t>(1, 0x7daf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7daf); auto const rel = std::vector<uint32_t>(1, 0x872a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x872a); auto const rel = std::vector<uint32_t>(1, 0x88ea); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x88ea); auto const rel = std::vector<uint32_t>(1, 0x9780); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9780); auto const rel = std::vector<uint32_t>(1, 0x9184); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9184); auto const rel = std::vector<uint32_t>(1, 0x9789); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9789); auto const rel = std::vector<uint32_t>(1, 0x92fe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92fe); auto const rel = std::vector<uint32_t>(1, 0x932d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_007) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x932d); auto const rel = std::vector<uint32_t>(1, 0x99e3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99e3); auto const rel = std::vector<uint32_t>(1, 0x6aae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aae); auto const rel = std::vector<uint32_t>(1, 0x9940); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9940); auto const rel = std::vector<uint32_t>(1, 0x9a0a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a0a); auto const rel = std::vector<uint32_t>(1, 0x9f17); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f17); auto const rel = std::vector<uint32_t>(1, 0x8ba8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ba8); auto const rel = std::vector<uint32_t>(1, 0x8a0e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a0e); auto const rel = std::vector<uint32_t>(1, 0x5957); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5957); auto const rel = std::vector<uint32_t>(1, 0x5077); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5077); auto const rel = std::vector<uint32_t>(1, 0x5078); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5078); auto const rel = std::vector<uint32_t>(1, 0x5a7e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a7e); auto const rel = std::vector<uint32_t>(1, 0x5aae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5aae); auto const rel = std::vector<uint32_t>(1, 0x92c0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92c0); auto const rel = std::vector<uint32_t>(1, 0x936e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x936e); auto const rel = std::vector<uint32_t>(1, 0x4ea0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ea0); auto const rel = std::vector<uint32_t>(1, 0x5934); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5934); auto const rel = std::vector<uint32_t>(1, 0x6295); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6295); auto const rel = std::vector<uint32_t>(1, 0x9ab0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ab0); auto const rel = std::vector<uint32_t>(1, 0x7df0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7df0); auto const rel = std::vector<uint32_t>(1, 0x982d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x982d); auto const rel = std::vector<uint32_t>(1, 0x59b5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x59b5); auto const rel = std::vector<uint32_t>(1, 0x94ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94ad); auto const rel = std::vector<uint32_t>(1, 0x7d0f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d0f); auto const rel = std::vector<uint32_t>(1, 0x3a97); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3a97); auto const rel = std::vector<uint32_t>(1, 0x6568); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6568); auto const rel = std::vector<uint32_t>(1, 0x98f3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98f3); auto const rel = std::vector<uint32_t>(1, 0x9ec8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ec8); auto const rel = std::vector<uint32_t>(1, 0x8623); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x900f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x900f); auto const rel = std::vector<uint32_t>(1, 0x7d89); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d89); auto const rel = std::vector<uint32_t>(1, 0x574d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x574d); auto const rel = std::vector<uint32_t>(1, 0x3631); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3631); auto const rel = std::vector<uint32_t>(1, 0x62a9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62a9); auto const rel = std::vector<uint32_t>(1, 0x8d2a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d2a); auto const rel = std::vector<uint32_t>(1, 0x6039); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6039); auto const rel = std::vector<uint32_t>(1, 0x75d1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75d1); auto const rel = std::vector<uint32_t>(1, 0x8211); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8211); auto const rel = std::vector<uint32_t>(1, 0x8caa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8caa); auto const rel = std::vector<uint32_t>(1, 0x644a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x644a); auto const rel = std::vector<uint32_t>(1, 0x6ee9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ee9); auto const rel = std::vector<uint32_t>(1, 0x762b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x762b); auto const rel = std::vector<uint32_t>(1, 0x64f9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64f9); auto const rel = std::vector<uint32_t>(1, 0x6524); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6524); auto const rel = std::vector<uint32_t>(1, 0x7058); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7058); auto const rel = std::vector<uint32_t>(1, 0x7671); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7671); auto const rel = std::vector<uint32_t>(1, 0x575b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x575b); auto const rel = std::vector<uint32_t>(1, 0x212a8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x212a8); auto const rel = std::vector<uint32_t>(1, 0x6619); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6619); auto const rel = std::vector<uint32_t>(1, 0x5013); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5013); auto const rel = std::vector<uint32_t>(1, 0x8c08); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c08); auto const rel = std::vector<uint32_t>(1, 0x5a52); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_008) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a52); auto const rel = std::vector<uint32_t>(1, 0x60d4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60d4); auto const rel = std::vector<uint32_t>(1, 0x90ef); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x90ef); auto const rel = std::vector<uint32_t>(1, 0x8983); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8983); auto const rel = std::vector<uint32_t>(1, 0x6983); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6983); auto const rel = std::vector<uint32_t>(1, 0x75f0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75f0); auto const rel = std::vector<uint32_t>(1, 0x952c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x952c); auto const rel = std::vector<uint32_t>(1, 0x8c2d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c2d); auto const rel = std::vector<uint32_t>(1, 0x58b0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58b0); auto const rel = std::vector<uint32_t>(1, 0x58b5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58b5); auto const rel = std::vector<uint32_t>(1, 0x619b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x619b); auto const rel = std::vector<uint32_t>(1, 0x6f6d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f6d); auto const rel = std::vector<uint32_t>(1, 0x8ac7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ac7); auto const rel = std::vector<uint32_t>(1, 0x9188); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9188); auto const rel = std::vector<uint32_t>(1, 0x58c7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58c7); auto const rel = std::vector<uint32_t>(1, 0x66c7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66c7); auto const rel = std::vector<uint32_t>(1, 0x71c2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71c2); auto const rel = std::vector<uint32_t>(1, 0x931f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x931f); auto const rel = std::vector<uint32_t>(1, 0x9924); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9924); auto const rel = std::vector<uint32_t>(1, 0x6a80); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a80); auto const rel = std::vector<uint32_t>(1, 0x78f9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78f9); auto const rel = std::vector<uint32_t>(1, 0x9843); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9843); auto const rel = std::vector<uint32_t>(1, 0x7f48); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f48); auto const rel = std::vector<uint32_t>(1, 0x58dc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58dc); auto const rel = std::vector<uint32_t>(1, 0x85eb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85eb); auto const rel = std::vector<uint32_t>(1, 0x8b5a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b5a); auto const rel = std::vector<uint32_t>(1, 0x8c9a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c9a); auto const rel = std::vector<uint32_t>(1, 0x91b0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b0); auto const rel = std::vector<uint32_t>(1, 0x8b60); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x7f4e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f4e); auto const rel = std::vector<uint32_t>(1, 0x5fd0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fd0); auto const rel = std::vector<uint32_t>(1, 0x5766); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5766); auto const rel = std::vector<uint32_t>(1, 0x43d9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x43d9); auto const rel = std::vector<uint32_t>(1, 0x94bd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94bd); auto const rel = std::vector<uint32_t>(1, 0x8892); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8892); auto const rel = std::vector<uint32_t>(1, 0x6bef); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bef); auto const rel = std::vector<uint32_t>(1, 0x83fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83fc); auto const rel = std::vector<uint32_t>(1, 0x47a1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x47a1); auto const rel = std::vector<uint32_t>(1, 0x926d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x926d); auto const rel = std::vector<uint32_t>(1, 0x55ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x55ff); auto const rel = std::vector<uint32_t>(1, 0x61b3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61b3); auto const rel = std::vector<uint32_t>(1, 0x61bb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61bb); auto const rel = std::vector<uint32_t>(1, 0x9193); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9193); auto const rel = std::vector<uint32_t>(1, 0x74ae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74ae); auto const rel = std::vector<uint32_t>(1, 0x8962); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8962); auto const rel = std::vector<uint32_t>(1, 0x53f9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x53f9); auto const rel = std::vector<uint32_t>(1, 0x70ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70ad); auto const rel = std::vector<uint32_t>(1, 0x57ee); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57ee); auto const rel = std::vector<uint32_t>(1, 0x63a2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63a2); auto const rel = std::vector<uint32_t>(1, 0x509d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x509d); auto const rel = std::vector<uint32_t>(1, 0x6e60); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e60); auto const rel = std::vector<uint32_t>(1, 0x50cb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_009) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x50cb); auto const rel = std::vector<uint32_t>(1, 0x5606); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5606); auto const rel = std::vector<uint32_t>(1, 0x78b3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78b3); auto const rel = std::vector<uint32_t>(1, 0x8215); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8215); auto const rel = std::vector<uint32_t>(1, 0x6b4e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b4e); auto const rel = std::vector<uint32_t>(1, 0x8ce7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ce7); auto const rel = std::vector<uint32_t>(1, 0x6c64); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c64); auto const rel = std::vector<uint32_t>(1, 0x5763); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5763); auto const rel = std::vector<uint32_t>(1, 0x94f4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94f4); auto const rel = std::vector<uint32_t>(1, 0x6e6f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e6f); auto const rel = std::vector<uint32_t>(1, 0x5621); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5621); auto const rel = std::vector<uint32_t>(1, 0x8025); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8025); auto const rel = std::vector<uint32_t>(1, 0x528f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x528f); auto const rel = std::vector<uint32_t>(1, 0x7fb0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fb0); auto const rel = std::vector<uint32_t>(1, 0x876a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x876a); auto const rel = std::vector<uint32_t>(1, 0x47b6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x47b6); auto const rel = std::vector<uint32_t>(1, 0x4800); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4800); auto const rel = std::vector<uint32_t>(1, 0x9557); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9557); auto const rel = std::vector<uint32_t>(1, 0x859a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x859a); auto const rel = std::vector<uint32_t>(1, 0x8e5a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e5a); auto const rel = std::vector<uint32_t>(1, 0x93dc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93dc); auto const rel = std::vector<uint32_t>(1, 0x940b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x97ba); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97ba); auto const rel = std::vector<uint32_t>(1, 0x9f1e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9967); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9967); auto const rel = std::vector<uint32_t>(1, 0x5510); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5510); auto const rel = std::vector<uint32_t>(1, 0x5802); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5802); auto const rel = std::vector<uint32_t>(1, 0x508f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x508f); auto const rel = std::vector<uint32_t>(1, 0x557a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x557a); auto const rel = std::vector<uint32_t>(1, 0x3b7b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b7b); auto const rel = std::vector<uint32_t>(1, 0x68e0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x68e0); auto const rel = std::vector<uint32_t>(1, 0x347d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x347d); auto const rel = std::vector<uint32_t>(1, 0x5858); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5858); auto const rel = std::vector<uint32_t>(1, 0x370d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x370d); auto const rel = std::vector<uint32_t>(1, 0x642a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x642a); auto const rel = std::vector<uint32_t>(1, 0x6e8f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e8f); auto const rel = std::vector<uint32_t>(1, 0x910c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x910c); auto const rel = std::vector<uint32_t>(1, 0x69b6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x69b6); auto const rel = std::vector<uint32_t>(1, 0x6f1f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f1f); auto const rel = std::vector<uint32_t>(1, 0x717b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x717b); auto const rel = std::vector<uint32_t>(1, 0x746d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x746d); auto const rel = std::vector<uint32_t>(1, 0x8185); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8185); auto const rel = std::vector<uint32_t>(1, 0x84ce); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84ce); auto const rel = std::vector<uint32_t>(1, 0x969a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x969a); auto const rel = std::vector<uint32_t>(1, 0x6a18); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a18); auto const rel = std::vector<uint32_t>(1, 0x2365f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2365f); auto const rel = std::vector<uint32_t>(1, 0x78c4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78c4); auto const rel = std::vector<uint32_t>(1, 0x799f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x799f); auto const rel = std::vector<uint32_t>(1, 0x7cc3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cc3); auto const rel = std::vector<uint32_t>(1, 0x819b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x819b); auto const rel = std::vector<uint32_t>(1, 0x6a56); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a56); auto const rel = std::vector<uint32_t>(1, 0x7bd6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_010) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7bd6); auto const rel = std::vector<uint32_t>(1, 0x7cd6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cd6); auto const rel = std::vector<uint32_t>(1, 0x8797); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8797); auto const rel = std::vector<uint32_t>(1, 0x8e3c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e3c); auto const rel = std::vector<uint32_t>(1, 0x7cdb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cdb); auto const rel = std::vector<uint32_t>(1, 0x87b3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x87b3); auto const rel = std::vector<uint32_t>(1, 0x8d6f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d6f); auto const rel = std::vector<uint32_t>(1, 0x91a3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91a3); auto const rel = std::vector<uint32_t>(1, 0x9933); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9933); auto const rel = std::vector<uint32_t>(1, 0x424e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x424e); auto const rel = std::vector<uint32_t>(1, 0x9395); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9395); auto const rel = std::vector<uint32_t>(1, 0x9939); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9939); auto const rel = std::vector<uint32_t>(1, 0x95db); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95db); auto const rel = std::vector<uint32_t>(1, 0x9944); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9944); auto const rel = std::vector<uint32_t>(1, 0x28189); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x28189); auto const rel = std::vector<uint32_t>(1, 0x9db6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x4f16); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f16); auto const rel = std::vector<uint32_t>(1, 0x5e11); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e11); auto const rel = std::vector<uint32_t>(1, 0x5018); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5018); auto const rel = std::vector<uint32_t>(1, 0x5052); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5052); auto const rel = std::vector<uint32_t>(1, 0x6dcc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6dcc); auto const rel = std::vector<uint32_t>(1, 0x50a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x50a5); auto const rel = std::vector<uint32_t>(1, 0x8eba); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8eba); auto const rel = std::vector<uint32_t>(1, 0x954b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x954b); auto const rel = std::vector<uint32_t>(1, 0x93b2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93b2); auto const rel = std::vector<uint32_t>(1, 0x513b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x513b); auto const rel = std::vector<uint32_t>(1, 0x6203); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x66ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x7223); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x77d8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9482); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x70eb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70eb); auto const rel = std::vector<uint32_t>(1, 0x6465); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6465); auto const rel = std::vector<uint32_t>(1, 0x8d9f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d9f); auto const rel = std::vector<uint32_t>(1, 0x71d9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71d9); auto const rel = std::vector<uint32_t>(1, 0x71a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71a5); auto const rel = std::vector<uint32_t>(1, 0x81af); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81af); auto const rel = std::vector<uint32_t>(1, 0x9f1f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f1f); auto const rel = std::vector<uint32_t>(1, 0x75bc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75bc); auto const rel = std::vector<uint32_t>(1, 0x75cb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75cb); auto const rel = std::vector<uint32_t>(1, 0x5e50); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e50); auto const rel = std::vector<uint32_t>(1, 0x817e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x817e); auto const rel = std::vector<uint32_t>(1, 0x8a8a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a8a); auto const rel = std::vector<uint32_t>(1, 0x6f1b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f1b); auto const rel = std::vector<uint32_t>(1, 0x6ed5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ed5); auto const rel = std::vector<uint32_t>(1, 0x7e22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e22); auto const rel = std::vector<uint32_t>(1, 0x9086); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9086); auto const rel = std::vector<uint32_t>(1, 0x99e6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99e6); auto const rel = std::vector<uint32_t>(1, 0x8b04); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b04); auto const rel = std::vector<uint32_t>(1, 0x512f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x512f); auto const rel = std::vector<uint32_t>(1, 0x85e4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85e4); auto const rel = std::vector<uint32_t>(1, 0x9a30); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_011) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a30); auto const rel = std::vector<uint32_t>(1, 0x7c50); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c50); auto const rel = std::vector<uint32_t>(1, 0x9c27); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c27); auto const rel = std::vector<uint32_t>(1, 0x7c58); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c58); auto const rel = std::vector<uint32_t>(1, 0x9a63); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a63); auto const rel = std::vector<uint32_t>(1, 0x972f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x8645); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8645); auto const rel = std::vector<uint32_t>(1, 0x5254); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5254); auto const rel = std::vector<uint32_t>(1, 0x68af); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x68af); auto const rel = std::vector<uint32_t>(1, 0x3538); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3538); auto const rel = std::vector<uint32_t>(1, 0x9511); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9511); auto const rel = std::vector<uint32_t>(1, 0x8e22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e22); auto const rel = std::vector<uint32_t>(1, 0x64ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64ff); auto const rel = std::vector<uint32_t>(1, 0x9dc8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9dc9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc9); auto const rel = std::vector<uint32_t>(1, 0x5397); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5397); auto const rel = std::vector<uint32_t>(1, 0x82d0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82d0); auto const rel = std::vector<uint32_t>(1, 0x7ee8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ee8); auto const rel = std::vector<uint32_t>(1, 0x8351); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8351); auto const rel = std::vector<uint32_t>(1, 0x504d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x504d); auto const rel = std::vector<uint32_t>(1, 0x557c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x557c); auto const rel = std::vector<uint32_t>(1, 0x5d39); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d39); auto const rel = std::vector<uint32_t>(1, 0x60ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60ff); auto const rel = std::vector<uint32_t>(1, 0x63d0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63d0); auto const rel = std::vector<uint32_t>(1, 0x7a0a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a0a); auto const rel = std::vector<uint32_t>(1, 0x7f07); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f07); auto const rel = std::vector<uint32_t>(1, 0x7f64); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f64); auto const rel = std::vector<uint32_t>(1, 0x9e48); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e48); auto const rel = std::vector<uint32_t>(1, 0x55c1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x55c1); auto const rel = std::vector<uint32_t>(1, 0x7445); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7445); auto const rel = std::vector<uint32_t>(1, 0x7d88); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d88); auto const rel = std::vector<uint32_t>(1, 0x9046); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9046); auto const rel = std::vector<uint32_t>(1, 0x78ae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78ae); auto const rel = std::vector<uint32_t>(1, 0x5fb2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fb2); auto const rel = std::vector<uint32_t>(1, 0x6f3d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f3d); auto const rel = std::vector<uint32_t>(1, 0x7df9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7df9); auto const rel = std::vector<uint32_t>(1, 0x876d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x876d); auto const rel = std::vector<uint32_t>(1, 0x8906); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8906); auto const rel = std::vector<uint32_t>(1, 0x92bb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92bb); auto const rel = std::vector<uint32_t>(1, 0x9898); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9898); auto const rel = std::vector<uint32_t>(1, 0x855b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x855b); auto const rel = std::vector<uint32_t>(1, 0x8da7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8da7); auto const rel = std::vector<uint32_t>(1, 0x8e44); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e44); auto const rel = std::vector<uint32_t>(1, 0x918d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x918d); auto const rel = std::vector<uint32_t>(1, 0x8b15); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b15); auto const rel = std::vector<uint32_t>(1, 0x8e4f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e4f); auto const rel = std::vector<uint32_t>(1, 0x9357); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9357); auto const rel = std::vector<uint32_t>(1, 0x9cc0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9cc0); auto const rel = std::vector<uint32_t>(1, 0x9d3a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d3a); auto const rel = std::vector<uint32_t>(1, 0x984c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x984c); auto const rel = std::vector<uint32_t>(1, 0x9bb7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bb7); auto const rel = std::vector<uint32_t>(1, 0x9d5c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_012) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d5c); auto const rel = std::vector<uint32_t>(1, 0x9a20); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a20); auto const rel = std::vector<uint32_t>(1, 0x9bf7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9d97); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9d99); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x79b5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79b5); auto const rel = std::vector<uint32_t>(1, 0x9de4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x4f53); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f53); auto const rel = std::vector<uint32_t>(1, 0x632e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x632e); auto const rel = std::vector<uint32_t>(1, 0x8eb0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8eb0); auto const rel = std::vector<uint32_t>(1, 0x9ab5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ab5); auto const rel = std::vector<uint32_t>(1, 0x9ba7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ba7); auto const rel = std::vector<uint32_t>(1, 0x8ec6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ec6); auto const rel = std::vector<uint32_t>(1, 0x9ad4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ad4); auto const rel = std::vector<uint32_t>(1, 0x623b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x623b); auto const rel = std::vector<uint32_t>(1, 0x239c2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x239c2); auto const rel = std::vector<uint32_t>(1, 0x5c49); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c49); auto const rel = std::vector<uint32_t>(1, 0x8fcf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fcf); auto const rel = std::vector<uint32_t>(1, 0x5243); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5243); auto const rel = std::vector<uint32_t>(1, 0x6711); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6711); auto const rel = std::vector<uint32_t>(1, 0x6d1f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d1f); auto const rel = std::vector<uint32_t>(1, 0x501c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x501c); auto const rel = std::vector<uint32_t>(1, 0x608c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x608c); auto const rel = std::vector<uint32_t>(1, 0x6d95); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d95); auto const rel = std::vector<uint32_t>(1, 0x5c5c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c5c); auto const rel = std::vector<uint32_t>(1, 0x6090); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6090); auto const rel = std::vector<uint32_t>(1, 0x60d5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60d5); auto const rel = std::vector<uint32_t>(1, 0x63a6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63a6); auto const rel = std::vector<uint32_t>(1, 0x9016); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9016); auto const rel = std::vector<uint32_t>(1, 0x60d6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60d6); auto const rel = std::vector<uint32_t>(1, 0x63e5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63e5); auto const rel = std::vector<uint32_t>(1, 0x66ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66ff); auto const rel = std::vector<uint32_t>(1, 0x9037); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9037); auto const rel = std::vector<uint32_t>(1, 0x6974); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6974); auto const rel = std::vector<uint32_t>(1, 0x88fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x88fc); auto const rel = std::vector<uint32_t>(1, 0x6b52); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b52); auto const rel = std::vector<uint32_t>(1, 0x6ba2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ba2); auto const rel = std::vector<uint32_t>(1, 0x8905); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8905); auto const rel = std::vector<uint32_t>(1, 0x9af0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9af0); auto const rel = std::vector<uint32_t>(1, 0x3b31); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b31); auto const rel = std::vector<uint32_t>(1, 0x568f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x568f); auto const rel = std::vector<uint32_t>(1, 0x8599); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8599); auto const rel = std::vector<uint32_t>(1, 0x9b00); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b00); auto const rel = std::vector<uint32_t>(1, 0x5694); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5694); auto const rel = std::vector<uint32_t>(1, 0x74cb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74cb); auto const rel = std::vector<uint32_t>(1, 0x7c4a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x8daf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x4d91); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4d91); auto const rel = std::vector<uint32_t>(1, 0x7b39); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b39); auto const rel = std::vector<uint32_t>(1, 0x5d5c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d5c); auto const rel = std::vector<uint32_t>(1, 0x5e16); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e16); auto const rel = std::vector<uint32_t>(1, 0x6017); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_013) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6017); auto const rel = std::vector<uint32_t>(1, 0x8d34); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d34); auto const rel = std::vector<uint32_t>(1, 0x8051); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8051); auto const rel = std::vector<uint32_t>(1, 0x841c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x841c); auto const rel = std::vector<uint32_t>(1, 0x8cbc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8cbc); auto const rel = std::vector<uint32_t>(1, 0x94c1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94c1); auto const rel = std::vector<uint32_t>(1, 0x86c8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x86c8); auto const rel = std::vector<uint32_t>(1, 0x50e3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x50e3); auto const rel = std::vector<uint32_t>(1, 0x9295); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9295); auto const rel = std::vector<uint32_t>(1, 0x92e8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92e8); auto const rel = std::vector<uint32_t>(1, 0x9d29); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d29); auto const rel = std::vector<uint32_t>(1, 0x9421); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9421); auto const rel = std::vector<uint32_t>(1, 0x9435); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9435); auto const rel = std::vector<uint32_t>(1, 0x9a56); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x546b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x546b); auto const rel = std::vector<uint32_t>(1, 0x98fb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98fb); auto const rel = std::vector<uint32_t>(1, 0x4d34); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4d34); auto const rel = std::vector<uint32_t>(1, 0x992e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x992e); auto const rel = std::vector<uint32_t>(1, 0x65eb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65eb); auto const rel = std::vector<uint32_t>(1, 0x4f7b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f7b); auto const rel = std::vector<uint32_t>(1, 0x5ea3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ea3); auto const rel = std::vector<uint32_t>(1, 0x604c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x604c); auto const rel = std::vector<uint32_t>(1, 0x6311); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6311); auto const rel = std::vector<uint32_t>(1, 0x7967); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7967); auto const rel = std::vector<uint32_t>(1, 0x3b38); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b38); auto const rel = std::vector<uint32_t>(1, 0x804e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x804e); auto const rel = std::vector<uint32_t>(1, 0x8280); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8280); auto const rel = std::vector<uint32_t>(1, 0x6761); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6761); auto const rel = std::vector<uint32_t>(1, 0x5ca7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ca7); auto const rel = std::vector<uint32_t>(1, 0x5cb9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cb9); auto const rel = std::vector<uint32_t>(1, 0x8fe2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fe2); auto const rel = std::vector<uint32_t>(1, 0x7952); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7952); auto const rel = std::vector<uint32_t>(1, 0x689d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x689d); auto const rel = std::vector<uint32_t>(1, 0x7b24); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b24); auto const rel = std::vector<uint32_t>(1, 0x8414); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8414); auto const rel = std::vector<uint32_t>(1, 0x47ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x47ed); auto const rel = std::vector<uint32_t>(1, 0x8d92); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d92); auto const rel = std::vector<uint32_t>(1, 0x9f86); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f86); auto const rel = std::vector<uint32_t>(1, 0x84da); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84da); auto const rel = std::vector<uint32_t>(1, 0x8729); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8729); auto const rel = std::vector<uint32_t>(1, 0x6a24); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a24); auto const rel = std::vector<uint32_t>(1, 0x84e8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84e8); auto const rel = std::vector<uint32_t>(1, 0x92da); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92da); auto const rel = std::vector<uint32_t>(1, 0x9aeb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9aeb); auto const rel = std::vector<uint32_t>(1, 0x9ca6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ca6); auto const rel = std::vector<uint32_t>(1, 0x9797); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9797); auto const rel = std::vector<uint32_t>(1, 0x93a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93a5); auto const rel = std::vector<uint32_t>(1, 0x9bc8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9bc8); auto const rel = std::vector<uint32_t>(1, 0x9f60); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9c37); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x5ba8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ba8); auto const rel = std::vector<uint32_t>(1, 0x6640); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_014) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6640); auto const rel = std::vector<uint32_t>(1, 0x6713); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6713); auto const rel = std::vector<uint32_t>(1, 0x3e20); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3e20); auto const rel = std::vector<uint32_t>(1, 0x8101); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8101); auto const rel = std::vector<uint32_t>(1, 0x7a95); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a95); auto const rel = std::vector<uint32_t>(1, 0x8a82); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a82); auto const rel = std::vector<uint32_t>(1, 0x4837); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4837); auto const rel = std::vector<uint32_t>(1, 0x7ab1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ab1); auto const rel = std::vector<uint32_t>(1, 0x65a2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65a2); auto const rel = std::vector<uint32_t>(1, 0x5b25); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b25); auto const rel = std::vector<uint32_t>(1, 0x773a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x773a); auto const rel = std::vector<uint32_t>(1, 0x7c9c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c9c); auto const rel = std::vector<uint32_t>(1, 0x7d69); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d69); auto const rel = std::vector<uint32_t>(1, 0x899c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x899c); auto const rel = std::vector<uint32_t>(1, 0x8df3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8df3); auto const rel = std::vector<uint32_t>(1, 0x7cf6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x87a9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x87a9); auto const rel = std::vector<uint32_t>(1, 0x5929); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5929); auto const rel = std::vector<uint32_t>(1, 0x5172); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5172); auto const rel = std::vector<uint32_t>(1, 0x5a56); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a56); auto const rel = std::vector<uint32_t>(1, 0x6dfb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6dfb); auto const rel = std::vector<uint32_t>(1, 0x915f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x915f); auto const rel = std::vector<uint32_t>(1, 0x9754); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9754); auto const rel = std::vector<uint32_t>(1, 0x42ec); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x42ec); auto const rel = std::vector<uint32_t>(1, 0x3b32); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b32); auto const rel = std::vector<uint32_t>(1, 0x9ec7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ec7); auto const rel = std::vector<uint32_t>(1, 0x975d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x975d); auto const rel = std::vector<uint32_t>(1, 0x7530); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7530); auto const rel = std::vector<uint32_t>(1, 0x5c47); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c47); auto const rel = std::vector<uint32_t>(1, 0x6cba); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cba); auto const rel = std::vector<uint32_t>(1, 0x606c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x606c); auto const rel = std::vector<uint32_t>(1, 0x754b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x754b); auto const rel = std::vector<uint32_t>(1, 0x7551); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7551); auto const rel = std::vector<uint32_t>(1, 0x76f7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76f7); auto const rel = std::vector<uint32_t>(1, 0x80cb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80cb); auto const rel = std::vector<uint32_t>(1, 0x7560); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7560); auto const rel = std::vector<uint32_t>(1, 0x751b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x751b); auto const rel = std::vector<uint32_t>(1, 0x751c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x751c); auto const rel = std::vector<uint32_t>(1, 0x6e49); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e49); auto const rel = std::vector<uint32_t>(1, 0x83fe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83fe); auto const rel = std::vector<uint32_t>(1, 0x4852); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4852); auto const rel = std::vector<uint32_t>(1, 0x5861); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5861); auto const rel = std::vector<uint32_t>(1, 0x586b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x586b); auto const rel = std::vector<uint32_t>(1, 0x6437); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6437); auto const rel = std::vector<uint32_t>(1, 0x923f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x923f); auto const rel = std::vector<uint32_t>(1, 0x9617); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9617); auto const rel = std::vector<uint32_t>(1, 0x7dc2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7dc2); auto const rel = std::vector<uint32_t>(1, 0x78cc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78cc); auto const rel = std::vector<uint32_t>(1, 0x7ab4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ab4); auto const rel = std::vector<uint32_t>(1, 0x74b3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74b3); auto const rel = std::vector<uint32_t>(1, 0x95d0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95d0); auto const rel = std::vector<uint32_t>(1, 0x9dc6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_015) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc6); auto const rel = std::vector<uint32_t>(1, 0x9dcf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x5fdd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fdd); auto const rel = std::vector<uint32_t>(1, 0x6b84); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b84); auto const rel = std::vector<uint32_t>(1, 0x500e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x500e); auto const rel = std::vector<uint32_t>(1, 0x35ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x35ad); auto const rel = std::vector<uint32_t>(1, 0x553a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x553a); auto const rel = std::vector<uint32_t>(1, 0x3649); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3649); auto const rel = std::vector<uint32_t>(1, 0x60bf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60bf); auto const rel = std::vector<uint32_t>(1, 0x6ddf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ddf); auto const rel = std::vector<uint32_t>(1, 0x666a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x666a); auto const rel = std::vector<uint32_t>(1, 0x7420); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7420); auto const rel = std::vector<uint32_t>(1, 0x8146); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8146); auto const rel = std::vector<uint32_t>(1, 0x89cd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89cd); auto const rel = std::vector<uint32_t>(1, 0x75f6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75f6); auto const rel = std::vector<uint32_t>(1, 0x7753); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7753); auto const rel = std::vector<uint32_t>(1, 0x8214); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8214); auto const rel = std::vector<uint32_t>(1, 0x9902); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9902); auto const rel = std::vector<uint32_t>(1, 0x89a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89a5); auto const rel = std::vector<uint32_t>(1, 0x8cdf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8cdf); auto const rel = std::vector<uint32_t>(1, 0x932a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x932a); auto const rel = std::vector<uint32_t>(1, 0x9766); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9766); auto const rel = std::vector<uint32_t>(1, 0x9369); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9369); auto const rel = std::vector<uint32_t>(1, 0x3401); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3401); auto const rel = std::vector<uint32_t>(1, 0x63ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63ad); auto const rel = std::vector<uint32_t>(1, 0x777c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x777c); auto const rel = std::vector<uint32_t>(1, 0x821a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x821a); auto const rel = std::vector<uint32_t>(1, 0x78b5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78b5); auto const rel = std::vector<uint32_t>(1, 0x9d2b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d2b); auto const rel = std::vector<uint32_t>(1, 0x5385); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5385); auto const rel = std::vector<uint32_t>(1, 0x5e81); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e81); auto const rel = std::vector<uint32_t>(1, 0x6c40); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c40); auto const rel = std::vector<uint32_t>(1, 0x827c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x827c); auto const rel = std::vector<uint32_t>(1, 0x542c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x542c); auto const rel = std::vector<uint32_t>(1, 0x753a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x753a); auto const rel = std::vector<uint32_t>(1, 0x8013); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8013); auto const rel = std::vector<uint32_t>(1, 0x539b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x539b); auto const rel = std::vector<uint32_t>(1, 0x70c3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70c3); auto const rel = std::vector<uint32_t>(1, 0x686f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x686f); auto const rel = std::vector<uint32_t>(1, 0x70f4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70f4); auto const rel = std::vector<uint32_t>(1, 0x7d8e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d8e); auto const rel = std::vector<uint32_t>(1, 0x42fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x42fc); auto const rel = std::vector<uint32_t>(1, 0x9793); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9793); auto const rel = std::vector<uint32_t>(1, 0x8074); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8074); auto const rel = std::vector<uint32_t>(1, 0x5ef0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ef0); auto const rel = std::vector<uint32_t>(1, 0x807c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x807c); auto const rel = std::vector<uint32_t>(1, 0x807d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x807d); auto const rel = std::vector<uint32_t>(1, 0x5ef3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ef3); auto const rel = std::vector<uint32_t>(1, 0x9092); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9092); auto const rel = std::vector<uint32_t>(1, 0x5ef7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ef7); auto const rel = std::vector<uint32_t>(1, 0x4ead); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ead); auto const rel = std::vector<uint32_t>(1, 0x5ead); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_016) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ead); auto const rel = std::vector<uint32_t>(1, 0x505c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x505c); auto const rel = std::vector<uint32_t>(1, 0x839b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x839b); auto const rel = std::vector<uint32_t>(1, 0x5a77); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a77); auto const rel = std::vector<uint32_t>(1, 0x5d49); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d49); auto const rel = std::vector<uint32_t>(1, 0x6e1f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e1f); auto const rel = std::vector<uint32_t>(1, 0x695f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x695f); auto const rel = std::vector<uint32_t>(1, 0x7b73); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b73); auto const rel = std::vector<uint32_t>(1, 0x8476); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8476); auto const rel = std::vector<uint32_t>(1, 0x8713); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8713); auto const rel = std::vector<uint32_t>(1, 0x69b3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x69b3); auto const rel = std::vector<uint32_t>(1, 0x8064); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8064); auto const rel = std::vector<uint32_t>(1, 0x874f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x874f); auto const rel = std::vector<uint32_t>(1, 0x95ae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95ae); auto const rel = std::vector<uint32_t>(1, 0x9706); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9706); auto const rel = std::vector<uint32_t>(1, 0x8aea); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8aea); auto const rel = std::vector<uint32_t>(1, 0x9f2e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x2123c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2123c); auto const rel = std::vector<uint32_t>(1, 0x5722); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5722); auto const rel = std::vector<uint32_t>(1, 0x753c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x753c); auto const rel = std::vector<uint32_t>(1, 0x4fb9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4fb9); auto const rel = std::vector<uint32_t>(1, 0x5a17); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a17); auto const rel = std::vector<uint32_t>(1, 0x633a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x633a); auto const rel = std::vector<uint32_t>(1, 0x6d8f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d8f); auto const rel = std::vector<uint32_t>(1, 0x6883); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6883); auto const rel = std::vector<uint32_t>(1, 0x70f6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70f6); auto const rel = std::vector<uint32_t>(1, 0x73fd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x73fd); auto const rel = std::vector<uint32_t>(1, 0x8121); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8121); auto const rel = std::vector<uint32_t>(1, 0x988b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x988b); auto const rel = std::vector<uint32_t>(1, 0x8247); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8247); auto const rel = std::vector<uint32_t>(1, 0x8a94); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a94); auto const rel = std::vector<uint32_t>(1, 0x9832); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9832); auto const rel = std::vector<uint32_t>(1, 0x2a2b6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2a2b6); auto const rel = std::vector<uint32_t>(1, 0x51f8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x51f8); auto const rel = std::vector<uint32_t>(1, 0x5b8a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b8a); auto const rel = std::vector<uint32_t>(1, 0x79bf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79bf); auto const rel = std::vector<uint32_t>(1, 0x79c3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79c3); auto const rel = std::vector<uint32_t>(1, 0x6022); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6022); auto const rel = std::vector<uint32_t>(1, 0x7a81); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a81); auto const rel = std::vector<uint32_t>(1, 0x550b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x550b); auto const rel = std::vector<uint32_t>(1, 0x6d8b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d8b); auto const rel = std::vector<uint32_t>(1, 0x6378); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6378); auto const rel = std::vector<uint32_t>(1, 0x5817); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5817); auto const rel = std::vector<uint32_t>(1, 0x6e65); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e65); auto const rel = std::vector<uint32_t>(1, 0x75dc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75dc); auto const rel = std::vector<uint32_t>(1, 0x8456); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8456); auto const rel = std::vector<uint32_t>(1, 0x5d80); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d80); auto const rel = std::vector<uint32_t>(1, 0x92f5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92f5); auto const rel = std::vector<uint32_t>(1, 0x9d5a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d5a); auto const rel = std::vector<uint32_t>(1, 0x9f35); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x56f3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56f3); auto const rel = std::vector<uint32_t>(1, 0x56fe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_017) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56fe); auto const rel = std::vector<uint32_t>(1, 0x51c3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x51c3); auto const rel = std::vector<uint32_t>(1, 0x5cf9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cf9); auto const rel = std::vector<uint32_t>(1, 0x5ea9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ea9); auto const rel = std::vector<uint32_t>(1, 0x5f92); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f92); auto const rel = std::vector<uint32_t>(1, 0x6087); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6087); auto const rel = std::vector<uint32_t>(1, 0x6348); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6348); auto const rel = std::vector<uint32_t>(1, 0x6d82); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d82); auto const rel = std::vector<uint32_t>(1, 0x5c60); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c60); auto const rel = std::vector<uint32_t>(1, 0x688c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x688c); auto const rel = std::vector<uint32_t>(1, 0x3ecc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3ecc); auto const rel = std::vector<uint32_t>(1, 0x837c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x837c); auto const rel = std::vector<uint32_t>(1, 0x9014); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9014); auto const rel = std::vector<uint32_t>(1, 0x63ec); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63ec); auto const rel = std::vector<uint32_t>(1, 0x3b78); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b78); auto const rel = std::vector<uint32_t>(1, 0x7a0c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a0c); auto const rel = std::vector<uint32_t>(1, 0x83df); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83df); auto const rel = std::vector<uint32_t>(1, 0x5715); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5715); auto const rel = std::vector<uint32_t>(1, 0x5857); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5857); auto const rel = std::vector<uint32_t>(1, 0x5d5e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d5e); auto const rel = std::vector<uint32_t>(1, 0x23225); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x23225); auto const rel = std::vector<uint32_t>(1, 0x760f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x760f); auto const rel = std::vector<uint32_t>(1, 0x7b61); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b61); auto const rel = std::vector<uint32_t>(1, 0x816f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x816f); auto const rel = std::vector<uint32_t>(1, 0x922f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x922f); auto const rel = std::vector<uint32_t>(1, 0x5716); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5716); auto const rel = std::vector<uint32_t>(1, 0x5717); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5717); auto const rel = std::vector<uint32_t>(1, 0x5edc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5edc); auto const rel = std::vector<uint32_t>(1, 0x6f73); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f73); auto const rel = std::vector<uint32_t>(1, 0x84a4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84a4); auto const rel = std::vector<uint32_t>(1, 0x8dff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dff); auto const rel = std::vector<uint32_t>(1, 0x9174); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9174); auto const rel = std::vector<uint32_t>(1, 0x48dd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x48dd); auto const rel = std::vector<uint32_t>(1, 0x999f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x999f); auto const rel = std::vector<uint32_t>(1, 0x934e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x934e); auto const rel = std::vector<uint32_t>(1, 0x99fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99fc); auto const rel = std::vector<uint32_t>(1, 0x9d4c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d4c); auto const rel = std::vector<uint32_t>(1, 0x9d9f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9dcb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9df5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x571f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x571f); auto const rel = std::vector<uint32_t>(1, 0x5721); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5721); auto const rel = std::vector<uint32_t>(1, 0x5410); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5410); auto const rel = std::vector<uint32_t>(1, 0x948d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x948d); auto const rel = std::vector<uint32_t>(1, 0x91f7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91f7); auto const rel = std::vector<uint32_t>(1, 0x514e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x514e); auto const rel = std::vector<uint32_t>(1, 0x5154); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5154); auto const rel = std::vector<uint32_t>(1, 0x8fcc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fcc); auto const rel = std::vector<uint32_t>(1, 0x580d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x580d); auto const rel = std::vector<uint32_t>(1, 0x9d75); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x6c62); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c62); auto const rel = std::vector<uint32_t>(1, 0x83b5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_018) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83b5); auto const rel = std::vector<uint32_t>(1, 0x4e47); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e47); auto const rel = std::vector<uint32_t>(1, 0x4edb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4edb); auto const rel = std::vector<uint32_t>(1, 0x8bac); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8bac); auto const rel = std::vector<uint32_t>(1, 0x6258); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6258); auto const rel = std::vector<uint32_t>(1, 0x6261); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6261); auto const rel = std::vector<uint32_t>(1, 0x6c51); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c51); auto const rel = std::vector<uint32_t>(1, 0x9966); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9966); auto const rel = std::vector<uint32_t>(1, 0x6754); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6754); auto const rel = std::vector<uint32_t>(1, 0x4f82); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f82); auto const rel = std::vector<uint32_t>(1, 0x5483); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5483); auto const rel = std::vector<uint32_t>(1, 0x62d5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62d5); auto const rel = std::vector<uint32_t>(1, 0x62d6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62d6); auto const rel = std::vector<uint32_t>(1, 0x6cb0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cb0); auto const rel = std::vector<uint32_t>(1, 0x6329); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6329); auto const rel = std::vector<uint32_t>(1, 0x635d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x635d); auto const rel = std::vector<uint32_t>(1, 0x8a17); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a17); auto const rel = std::vector<uint32_t>(1, 0x6db6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6db6); auto const rel = std::vector<uint32_t>(1, 0x812b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x812b); auto const rel = std::vector<uint32_t>(1, 0x8131); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8131); auto const rel = std::vector<uint32_t>(1, 0x838c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x838c); auto const rel = std::vector<uint32_t>(1, 0x88a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x88a5); auto const rel = std::vector<uint32_t>(1, 0x98e5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98e5); auto const rel = std::vector<uint32_t>(1, 0x9b60); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b60); auto const rel = std::vector<uint32_t>(1, 0x9a5d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a5d); auto const rel = std::vector<uint32_t>(1, 0x9a6e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a6e); auto const rel = std::vector<uint32_t>(1, 0x4f57); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f57); auto const rel = std::vector<uint32_t>(1, 0x5768); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5768); auto const rel = std::vector<uint32_t>(1, 0x5cae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cae); auto const rel = std::vector<uint32_t>(1, 0x6cb1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cb1); auto const rel = std::vector<uint32_t>(1, 0x6cb2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cb2); auto const rel = std::vector<uint32_t>(1, 0x72cf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72cf); auto const rel = std::vector<uint32_t>(1, 0x9640); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9640); auto const rel = std::vector<uint32_t>(1, 0x9641); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9641); auto const rel = std::vector<uint32_t>(1, 0x9a7c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a7c); auto const rel = std::vector<uint32_t>(1, 0x8ff1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ff1); auto const rel = std::vector<uint32_t>(1, 0x7823); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7823); auto const rel = std::vector<uint32_t>(1, 0x7824); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7824); auto const rel = std::vector<uint32_t>(1, 0x9e35); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e35); auto const rel = std::vector<uint32_t>(1, 0x7d3d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7d3d); auto const rel = std::vector<uint32_t>(1, 0x8889); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8889); auto const rel = std::vector<uint32_t>(1, 0x5836); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5836); auto const rel = std::vector<uint32_t>(1, 0x8dce); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dce); auto const rel = std::vector<uint32_t>(1, 0x9161); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9161); auto const rel = std::vector<uint32_t>(1, 0x99b1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99b1); auto const rel = std::vector<uint32_t>(1, 0x69d6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x69d6); auto const rel = std::vector<uint32_t>(1, 0x78a2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x78a2); auto const rel = std::vector<uint32_t>(1, 0x4b7e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4b7e); auto const rel = std::vector<uint32_t>(1, 0x99c4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99c4); auto const rel = std::vector<uint32_t>(1, 0x99dd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99dd); auto const rel = std::vector<uint32_t>(1, 0x99de); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99de); auto const rel = std::vector<uint32_t>(1, 0x6a50); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_004_019) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a50); auto const rel = std::vector<uint32_t>(1, 0x9b80); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b80); auto const rel = std::vector<uint32_t>(1, 0x9d15); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d15); auto const rel = std::vector<uint32_t>(1, 0x9f27); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f27); auto const rel = std::vector<uint32_t>(1, 0x9a28); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a28); auto const rel = std::vector<uint32_t>(1, 0x9f0d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f0d); auto const rel = std::vector<uint32_t>(1, 0x9a52); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x9f09); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x5f75); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f75); auto const rel = std::vector<uint32_t>(1, 0x59a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x59a5); auto const rel = std::vector<uint32_t>(1, 0x5eb9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5eb9); auto const rel = std::vector<uint32_t>(1, 0x5aa0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5aa0); auto const rel = std::vector<uint32_t>(1, 0x692d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x692d); auto const rel = std::vector<uint32_t>(1, 0x6955); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6955); auto const rel = std::vector<uint32_t>(1, 0x5af7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5af7); auto const rel = std::vector<uint32_t>(1, 0x6a62); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a62); auto const rel = std::vector<uint32_t>(1, 0x9d4e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d4e); auto const rel = std::vector<uint32_t>(1, 0x9b0c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b0c); auto const rel = std::vector<uint32_t>(1, 0x9c16); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c16); auto const rel = std::vector<uint32_t>(1, 0x67dd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67dd); auto const rel = std::vector<uint32_t>(1, 0x6be4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6be4); auto const rel = std::vector<uint32_t>(1, 0x553e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x553e); auto const rel = std::vector<uint32_t>(1, 0x841a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x841a); auto const rel = std::vector<uint32_t>(1, 0x8dc5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dc5); auto const rel = std::vector<uint32_t>(1, 0x6bfb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bfb); auto const rel = std::vector<uint32_t>(1, 0x7ba8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ba8); auto const rel = std::vector<uint32_t>(1, 0x8600); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x7c5c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.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, 0x63a8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63a8); auto const rel = std::vector<uint32_t>(1, 0x84f7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84f7); auto const rel = std::vector<uint32_t>(1, 0x85ec); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85ec); auto const rel = std::vector<uint32_t>(1, 0x5f1a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f1a); auto const rel = std::vector<uint32_t>(1, 0x4003); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4003); auto const rel = std::vector<uint32_t>(1, 0x9893); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9893); auto const rel = std::vector<uint32_t>(1, 0x5c35); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c35); auto const rel = std::vector<uint32_t>(1, 0x96a4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x96a4); auto const rel = std::vector<uint32_t>(1, 0x9839); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9839); auto const rel = std::vector<uint32_t>(1, 0x983a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x983a); auto const rel = std::vector<uint32_t>(1, 0x983d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x983d); auto const rel = std::vector<uint32_t>(1, 0x9b4b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b4b); auto const rel = std::vector<uint32_t>(1, 0x7a68); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a68); auto const rel = std::vector<uint32_t>(1, 0x8e6a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e6a); auto const rel = std::vector<uint32_t>(1, 0x8608); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8608); auto const rel = std::vector<uint32_t>(1, 0x3fd7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3fd7); auto const rel = std::vector<uint32_t>(1, 0x4fc0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4fc0); auto const rel = std::vector<uint32_t>(1, 0x50d3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x50d3); auto const rel = std::vector<uint32_t>(1, 0x817f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x817f); auto const rel = std::vector<uint32_t>(1, 0x8e46); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e46); auto const rel = std::vector<uint32_t>(1, 0x9abd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9abd); auto const rel = std::vector<uint32_t>(1, 0x4fbb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4fbb); auto const rel = std::vector<uint32_t>(1, 0x5a27); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a27); auto const rel = std::vector<uint32_t>(1, 0x9000); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } }
35.148854
76
0.597449
Ryan-rsm-McKenzie
7291f9692107375003ce88c72589d9623cbf9d47
725
hpp
C++
src/runner_options.hpp
dholmes215/adventofcode-cpp
2a0ce43c51ec3beccc56fb48bf91de070e6ca136
[ "BSL-1.0" ]
null
null
null
src/runner_options.hpp
dholmes215/adventofcode-cpp
2a0ce43c51ec3beccc56fb48bf91de070e6ca136
[ "BSL-1.0" ]
null
null
null
src/runner_options.hpp
dholmes215/adventofcode-cpp
2a0ce43c51ec3beccc56fb48bf91de070e6ca136
[ "BSL-1.0" ]
null
null
null
// // Copyright (c) 2020-2021 David Holmes (dholmes at dholmes dot us) // // 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) // #ifndef RUNNER_OPTIONS_HPP #define RUNNER_OPTIONS_HPP #include <filesystem> #include <optional> namespace aoc { struct date_filter { int year{}; std::optional<int> day; }; struct runner_options { std::optional<std::filesystem::path> inputfile; std::optional<std::filesystem::path> datadir; std::optional<date_filter> dates; int repeat{1}; int seconds{1}; }; runner_options process_args(int argc, char** argv); } // namespace aoc #endif // RUNNER_OPTIONS_HPP
21.969697
79
0.713103
dholmes215
729c8bd7858f55b9933cf7bb0fabdadc9a2eb4b8
3,780
cpp
C++
disk/DiskAsyncResult.cpp
zukisoft/storage
a8b6ac184377c4a6c25624260d16e7f42f082395
[ "MIT" ]
1
2016-05-28T04:19:26.000Z
2016-05-28T04:19:26.000Z
disk/DiskAsyncResult.cpp
zukisoft/storage-legacy
a8b6ac184377c4a6c25624260d16e7f42f082395
[ "MIT" ]
null
null
null
disk/DiskAsyncResult.cpp
zukisoft/storage-legacy
a8b6ac184377c4a6c25624260d16e7f42f082395
[ "MIT" ]
null
null
null
//----------------------------------------------------------------------------- // Copyright (c) 2014 Michael G. Brehm // // 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 "stdafx.h" // Include project pre-compiled headers #include "DiskAsyncResult.h" // Include DiskAsyncResult decls #pragma warning(push, 4) // Enable maximum compiler warnings BEGIN_NAMESPACE(zuki) BEGIN_NAMESPACE(storage) BEGIN_NAMESPACE(disk) //--------------------------------------------------------------------------- // DiskAsyncResult Constructor (internal) // // Arguments: // // handle - Open DiskSafeHandle instance // state - IAsyncResult state object DiskAsyncResult::DiskAsyncResult(DiskSafeHandle^ handle, Object^ state) : m_handle(handle), m_state(state), m_completed(false) { // Can't check this // if(handle == nullptr) throw gcnew ArgumentNullException("handle"); m_event = gcnew ManualResetEvent(false); m_overlapped = gcnew Overlapped(0, 0, m_event->SafeWaitHandle->DangerousGetHandle(), this); m_pNativeOverlapped = m_overlapped->Pack(nullptr, nullptr); } //--------------------------------------------------------------------------- // DiskAsyncResult Finalizer DiskAsyncResult::!DiskAsyncResult() { if(m_pNativeOverlapped) Overlapped::Free(m_pNativeOverlapped); m_pNativeOverlapped = NULL; } //--------------------------------------------------------------------------- // DiskAsyncResult::EndOperation (internal, static) // // Completes the asynchronous I/O operation // // Arguments: // // asyncResult - IAsyncResult object instance void DiskAsyncResult::EndOperation(IAsyncResult^ asyncResult) { DiskAsyncResult^ instance = safe_cast<DiskAsyncResult^>(asyncResult); instance->EndOperation(); } //--------------------------------------------------------------------------- // DiskAsyncResult::EndOperation (private) // // Completes the asynchronous I/O operation // // Arguments: // // NONE void DiskAsyncResult::EndOperation(void) { DWORD cbTransferred; // Bytes transferred m_event->WaitOne(); // Wait for the I/O operation to complete // Complete the asynchronous operation if(!GetOverlappedResult(m_handle, reinterpret_cast<LPOVERLAPPED>(m_pNativeOverlapped), &cbTransferred, FALSE)) throw gcnew Win32Exception(GetLastError()); Interlocked::Exchange(m_completed, 1); // Set the completion flag Overlapped::Free(m_pNativeOverlapped); // Release native OVERLAPPED structure m_pNativeOverlapped = NULL; // Reset pointer to NULL } //--------------------------------------------------------------------------- END_NAMESPACE(disk) END_NAMESPACE(storage) END_NAMESPACE(zuki) #pragma warning(pop)
35.660377
111
0.648413
zukisoft
729d5c6948cc979a568380c8763aaf305170982d
1,226
cpp
C++
robot/arduino/echo.cpp
kkevlar/bazelrobot
7b858a0513d6c8e4241641d9132b5d74a9a80ca5
[ "MIT" ]
1
2020-02-04T23:40:37.000Z
2020-02-04T23:40:37.000Z
robot/arduino/echo.cpp
kkevlar/bazelrobot
7b858a0513d6c8e4241641d9132b5d74a9a80ca5
[ "MIT" ]
6
2019-12-23T02:31:25.000Z
2019-12-23T02:33:03.000Z
robot/arduino/echo.cpp
kkevlar/roborodentia2020
7b858a0513d6c8e4241641d9132b5d74a9a80ca5
[ "MIT" ]
null
null
null
#include "echo.h" #include <Arduino.h> void echo_init() { pinMode(PIN_ULTRASONIC_TRIG, OUTPUT); pinMode(PIN_ULTRASONIC_ECHO_BACK, INPUT); pinMode(PIN_ULTRASONIC_ECHO_LEFT, INPUT); pinMode(PIN_ULTRASONIC_ECHO_FRONT, INPUT); pinMode(PIN_ULTRASONIC_ECHO_RIGHT, INPUT); #ifdef TEST_ECHO Serial.begin(9600); #endif } pin_t direction_to_echo_pin(direction_t dir) { if(dir == DIRECTION_ID_FRONT) return PIN_ULTRASONIC_ECHO_FRONT; else if(dir == DIRECTION_ID_BACK) return PIN_ULTRASONIC_ECHO_BACK; else if(dir == DIRECTION_ID_LEFT) return PIN_ULTRASONIC_ECHO_LEFT; else if(dir == DIRECTION_ID_RIGHT) return PIN_ULTRASONIC_ECHO_RIGHT; return 0; } float echo_test_mm(uint8_t pin) { long duration; float myout; digitalWrite(PIN_ULTRASONIC_TRIG, LOW); delayMicroseconds(5); digitalWrite(PIN_ULTRASONIC_TRIG, HIGH); delayMicroseconds(10); digitalWrite(PIN_ULTRASONIC_TRIG, LOW); pinMode(pin, INPUT); #ifdef ECHO_PULSEIN_LIMIT duration = pulseIn(pin, HIGH, ECHO_PULSEIN_LIMIT); #else duration = pulseIn(pin, HIGH); #endif myout = (duration); myout *= (0.171821f); return myout; }
21.892857
54
0.699837
kkevlar
72a040f91a1921b69242cc4bcf014f2af4dad0d4
13,346
cpp
C++
src/blackmagicsdk/blackmagicsdk_video_source.cpp
mhubii/GIFT-Grab
c9678e25edbd0403b25366d60a3e2e2e5c32320f
[ "BSD-3-Clause" ]
41
2017-06-24T21:58:17.000Z
2022-03-29T04:44:05.000Z
src/blackmagicsdk/blackmagicsdk_video_source.cpp
mhubii/GIFT-Grab
c9678e25edbd0403b25366d60a3e2e2e5c32320f
[ "BSD-3-Clause" ]
91
2017-06-14T09:57:40.000Z
2020-12-02T11:36:19.000Z
src/blackmagicsdk/blackmagicsdk_video_source.cpp
mhubii/GIFT-Grab
c9678e25edbd0403b25366d60a3e2e2e5c32320f
[ "BSD-3-Clause" ]
15
2017-05-21T14:04:50.000Z
2021-11-22T06:03:26.000Z
#include "blackmagicsdk_video_source.h" #include "deck_link_display_mode_detector.h" #include <chrono> namespace gg { VideoSourceBlackmagicSDK::VideoSourceBlackmagicSDK() : IVideoSource() , _frame_rate(0.0) , _video_buffer(nullptr) , _video_buffer_length(0) , _cols(0) , _rows(0) , _buffer_video_frame(VideoFrame(UYVY)) , _running(false) { // nop } VideoSourceBlackmagicSDK::VideoSourceBlackmagicSDK(size_t deck_link_index, ColourSpace colour) : IVideoSource(colour) , _frame_rate(0.0) , _video_buffer(nullptr) , _video_buffer_length(0) , _cols(0) , _rows(0) , _buffer_video_frame(VideoFrame(colour, false)) // TODO manage data? , _deck_link(nullptr) , _deck_link_input(nullptr) , _video_input_flags(bmdVideoInputFlagDefault | bmdVideoInputDualStream3D) , _12_bit_rgb_to_bgra_converter(nullptr) , _bgra_frame_buffers{nullptr, nullptr} , _running(false) { // Pixel format, i.e. colour space BMDPixelFormat pixel_format; switch(_colour) { case UYVY: pixel_format = bmdFormat8BitYUV; break; case BGRA: // We currently only support BGRA with DeckLink 4K Extreme 12G, // and that card supports only this YUV format: pixel_format = bmdFormat10BitYUV; break; case I420: default: bail("BlackmagicSDK video source supports only UYVY and BGRA colour spaces"); } // Get an iterator through the available DeckLink ports IDeckLinkIterator * deck_link_iterator = CreateDeckLinkIteratorInstance(); if (deck_link_iterator == nullptr) bail("DeckLink drivers do not appear to be installed"); HRESULT res; // Get the desired DeckLink index (port) int idx = deck_link_index; while ((res = deck_link_iterator->Next(&_deck_link)) == S_OK) { if (idx == 0) break; --idx; _deck_link->Release(); } if (deck_link_iterator != nullptr) deck_link_iterator->Release(); // No glory: release everything and throw exception if (res != S_OK or _deck_link == nullptr) bail( std::string("Could not get DeckLink device ").append(std::to_string(deck_link_index)) ); // Get the input interface of connected DeckLink port res = _deck_link->QueryInterface(IID_IDeckLinkInput, reinterpret_cast<void **>(&_deck_link_input)); // No glory: release everything and throw exception if (res != S_OK) bail("Could not get the Blackmagic DeckLink input interface"); // Set the input format (i.e. display mode) BMDDisplayMode display_mode; BMDFrameFlags frame_flags; std::string error_msg = ""; size_t cols = 0, rows = 0; if (not detect_input_format(pixel_format, _video_input_flags, display_mode, _frame_rate, cols, rows, frame_flags, error_msg)) { _video_input_flags ^= bmdVideoInputDualStream3D; if (not detect_input_format(pixel_format, _video_input_flags, display_mode, _frame_rate, cols, rows, frame_flags, error_msg)) bail(error_msg); } // Get a post-capture converter if necessary if (_colour == BGRA) { _12_bit_rgb_to_bgra_converter = CreateVideoConversionInstance(); if (_12_bit_rgb_to_bgra_converter == nullptr) bail("Could not create colour converter for Blackmagic source"); } // Set this object (IDeckLinkInputCallback instance) as callback res = _deck_link_input->SetCallback(this); // No glory: release everything and throw exception if (res != S_OK) bail("Could not set the callback of Blackmagic DeckLink device"); // Enable video input res = _deck_link_input->EnableVideoInput(display_mode, pixel_format, _video_input_flags); // No glory if (res != S_OK) bail("Could not enable video input of Blackmagic DeckLink device"); // Start streaming _running = true; res = _deck_link_input->StartStreams(); // No glory: release everything and throw exception if (res != S_OK) { _running = false; bail("Could not start streaming from the Blackmagic DeckLink device"); } } VideoSourceBlackmagicSDK::~VideoSourceBlackmagicSDK() { { // Artificial scope for data lock // Make sure streamer thread not trying to access buffer std::lock_guard<std::mutex> data_lock_guard(_data_lock); _running = false; } // Stop streaming and disable enabled inputs _deck_link_input->SetCallback(nullptr); _deck_link_input->StopStreams(); _deck_link_input->DisableVideoInput(); // Release DeckLink members release_deck_link(); } bool VideoSourceBlackmagicSDK::get_frame_dimensions(int & width, int & height) { // Make sure only this thread is accessing the cols and rows members now std::lock_guard<std::mutex> data_lock_guard(_data_lock); if (_cols <= 0 or _rows <= 0) return false; width = _cols; height = _rows; return true; } bool VideoSourceBlackmagicSDK::get_frame(VideoFrame & frame) { if (frame.colour() != _colour) return false; // Make sure only this thread is accessing the video frame data now std::lock_guard<std::mutex> data_lock_guard(_data_lock); if (_video_buffer_length > 0 and _cols > 0 and _rows > 0) { frame.init_from_specs(_video_buffer, _video_buffer_length, _cols, _rows); return true; } else return false; } double VideoSourceBlackmagicSDK::get_frame_rate() { return _frame_rate; } void VideoSourceBlackmagicSDK::set_sub_frame(int x, int y, int width, int height) { // issue #147 throw VideoSourceError("Blackmagic does not support cropping yet"); } void VideoSourceBlackmagicSDK::get_full_frame() { // nop: set_sub_frame currently not implemented } HRESULT STDMETHODCALLTYPE VideoSourceBlackmagicSDK::QueryInterface(REFIID iid, LPVOID * ppv) { return E_NOINTERFACE; } ULONG STDMETHODCALLTYPE VideoSourceBlackmagicSDK::AddRef(void) { __sync_add_and_fetch(&_n_ref, 1); return _n_ref; } ULONG STDMETHODCALLTYPE VideoSourceBlackmagicSDK::Release(void) { __sync_sub_and_fetch(&_n_ref, 1); return _n_ref; } HRESULT STDMETHODCALLTYPE VideoSourceBlackmagicSDK::VideoInputFormatChanged( BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode * display_mode, BMDDetectedVideoInputFormatFlags format_flags ) { // not supported yet: see issue #149 return S_OK; } HRESULT STDMETHODCALLTYPE VideoSourceBlackmagicSDK::VideoInputFrameArrived( IDeckLinkVideoInputFrame * video_frame, IDeckLinkAudioInputPacket * audio_packet ) { if (not _running) // nop if not running! return S_OK; // Not processing the audio packet, but only the video // frame for the time being if (video_frame == nullptr) // nop if no data return S_OK; { // Artificial scope for data lock // Make sure only this thread is accessing the buffer now std::lock_guard<std::mutex> data_lock_guard(_data_lock); smart_allocate_buffers( video_frame->GetWidth(), video_frame->GetHeight(), video_frame->GetFlags() ); if (_video_buffer == nullptr) // something's terribly wrong! // nop if something's terribly wrong! return S_OK; HRESULT res; if (need_conversion()) // convert to BGRA from capture format res = _12_bit_rgb_to_bgra_converter->ConvertFrame( video_frame, _bgra_frame_buffers[0] ); else // Get the new data into the buffer res = video_frame->GetBytes( reinterpret_cast<void **>(&_video_buffer) ); // If the last operation failed, return if (FAILED(res)) return res; if (is_stereo()) { IDeckLinkVideoFrame *right_eye_frame = nullptr; IDeckLinkVideoFrame3DExtensions *three_d_extensions = nullptr; if ((video_frame->QueryInterface( IID_IDeckLinkVideoFrame3DExtensions, (void **) &three_d_extensions) != S_OK) || (three_d_extensions->GetFrameForRightEye( &right_eye_frame) != S_OK)) { right_eye_frame = nullptr; } if (three_d_extensions != nullptr) three_d_extensions->Release(); if (right_eye_frame != nullptr) { if (need_conversion()) // convert to BGRA from capture format res = _12_bit_rgb_to_bgra_converter->ConvertFrame( right_eye_frame, _bgra_frame_buffers[1] ); else res = right_eye_frame->GetBytes( reinterpret_cast<void **>(&_video_buffer[_video_buffer_length / 2]) ); right_eye_frame->Release(); // If data could not be read into the buffer, return if (FAILED(res)) return res; } } // Propagate new video frame to observers _buffer_video_frame.init_from_specs( _video_buffer, _video_buffer_length, _cols, _rows, is_stereo() ? 2 : 1 ); } this->notify(_buffer_video_frame); // Everything went fine, return success return S_OK; } void VideoSourceBlackmagicSDK::release_deck_link() noexcept { if (_deck_link_input != nullptr) { _deck_link_input->Release(); _deck_link_input = nullptr; } if (_deck_link != nullptr) _deck_link->Release(); if (_12_bit_rgb_to_bgra_converter != nullptr) { _12_bit_rgb_to_bgra_converter->Release(); _12_bit_rgb_to_bgra_converter = nullptr; } for (size_t i = 0; i < 2; i++) if (_bgra_frame_buffers[i] != nullptr) { _bgra_frame_buffers[i]->Release(); delete _bgra_frame_buffers[i]; _bgra_frame_buffers[i] = nullptr; } } inline void VideoSourceBlackmagicSDK::smart_allocate_buffers( size_t cols, size_t rows, BMDFrameFlags frame_flags ) noexcept { if (cols <= 0 or rows <= 0) return; if (cols == _cols and rows == _rows) return; _cols = cols; _rows = rows; // Allocate pixel buffer _video_buffer_length = VideoFrame::required_data_length(_colour, _cols, _rows); if (is_stereo()) _video_buffer_length *= 2; _video_buffer = reinterpret_cast<uint8_t *>( realloc(_video_buffer, _video_buffer_length * sizeof(uint8_t)) ); // Colour converter for post-capture colour conversion if (need_conversion()) { for (size_t i = 0; i < (is_stereo() ? 2 : 1); i++) { if (_bgra_frame_buffers[i] != nullptr) { _bgra_frame_buffers[i]->Release(); delete _bgra_frame_buffers[i]; _bgra_frame_buffers[i] = nullptr; } _bgra_frame_buffers[i] = new DeckLinkBGRAVideoFrame( _cols, _rows, &_video_buffer[i * _video_buffer_length / 2], frame_flags ); } } } bool VideoSourceBlackmagicSDK::detect_input_format(BMDPixelFormat pixel_format, BMDVideoInputFlags & video_input_flags, BMDDisplayMode & display_mode, double & frame_rate, size_t & cols, size_t & rows, BMDFrameFlags & frame_flags, std::string & error_msg) noexcept { std::vector<BMDDisplayMode> display_modes = { bmdModeHD1080p6000, bmdModeHD1080p5994, bmdModeHD1080p50, bmdModeHD1080p30, bmdModeHD1080p2997, bmdModeHD1080p25, bmdModeHD1080p24, bmdModeHD1080p2398, bmdModeHD1080i6000, bmdModeHD1080i5994, bmdModeHD1080i50, bmdModeHD720p60, bmdModeHD720p5994, bmdModeHD720p50, bmdMode4K2160p60, bmdMode4K2160p5994, bmdMode4K2160p50, bmdMode4K2160p30, bmdMode4K2160p2997, bmdMode4K2160p25, bmdMode4K2160p24, bmdMode4K2160p2398, bmdMode2k25, bmdMode2k24, bmdMode2k2398, }; DeckLinkDisplayModeDetector detector( _deck_link_input, display_modes, pixel_format, video_input_flags ); BMDDisplayMode display_mode_ = detector.get_display_mode(); if (display_mode_ != bmdModeUnknown) { frame_rate = detector.get_frame_rate(); detector.get_frame_dimensions(cols, rows); frame_flags = detector.get_frame_flags(); display_mode = display_mode_; video_input_flags = detector.get_video_input_flags(); return true; } else { error_msg = detector.get_error_msg(); return false; } } }
30.263039
103
0.621385
mhubii
72a11eadc3dd83ebd43b738669fdc317af80e726
1,838
cpp
C++
src/viennautils/filesystem/filesystem.cpp
viennautils/viennautils-dev
38ef9a088f8df2a59215d27fd38bed8a4effd012
[ "MIT" ]
1
2015-09-13T03:50:52.000Z
2015-09-13T03:50:52.000Z
src/viennautils/filesystem/filesystem.cpp
viennautils/viennautils-dev
38ef9a088f8df2a59215d27fd38bed8a4effd012
[ "MIT" ]
null
null
null
src/viennautils/filesystem/filesystem.cpp
viennautils/viennautils-dev
38ef9a088f8df2a59215d27fd38bed8a4effd012
[ "MIT" ]
2
2017-01-12T09:02:43.000Z
2021-05-12T07:29:57.000Z
#include "viennautils/filesystem/filesystem.hpp" namespace viennautils { namespace filesystem { namespace { std::string const path_delimiters = "\\/"; std::string::size_type find_last_path_delimiter(std::string const & path) { return path.find_last_of(path_delimiters); } std::string::size_type find_extension_delimiter(std::string const & path) { //we also have to look for path delimiters so that "a.b/file" doesn't yield pos 1 but rather std::string::npos std::string::size_type pos = path.find_last_of(path_delimiters + "."); return (pos == std::string::npos || path[pos] != '.') ? std::string::npos : pos; } } std::string extract_extension(std::string const & path, bool include_delimiter) { return path.substr(find_extension_delimiter(path) + (include_delimiter ? 0 : 1)); } std::string extract_stem(std::string const & path) { std::string::size_type last_path_delim = find_last_path_delimiter(path); std::string::size_type stem_start = (last_path_delim == std::string::npos) ? 0 : last_path_delim+1; std::string::size_type ext_delim = find_extension_delimiter(path); std::string::size_type stem_len = (ext_delim == std::string::npos) ? std::string::npos : ext_delim-stem_start; return path.substr(stem_start, stem_len); } std::string extract_filename(std::string const & path) { std::string::size_type last_path_delim = find_last_path_delimiter(path); return (last_path_delim == std::string::npos) ? path : path.substr(last_path_delim+1); } std::string extract_path(std::string const & path, bool include_last_delimiter) { std::string::size_type last_path_delim = find_last_path_delimiter(path); return (last_path_delim == std::string::npos) ? "" : path.substr(0, last_path_delim + (include_last_delimiter ? 1 : 0)); } } //end of namespace filesystem } //end of namespace viennautils
32.245614
122
0.735038
viennautils
72a44e346584e77c1d9722c2a1426f459cb1a86c
1,341
cpp
C++
Week9/Fractional_Knapsack.cpp
SukalpVishnoi/DAA-PRACTICL
fee6b3f42a90d96de01ccf6af417d7ed29dc30f5
[ "MIT" ]
null
null
null
Week9/Fractional_Knapsack.cpp
SukalpVishnoi/DAA-PRACTICL
fee6b3f42a90d96de01ccf6af417d7ed29dc30f5
[ "MIT" ]
null
null
null
Week9/Fractional_Knapsack.cpp
SukalpVishnoi/DAA-PRACTICL
fee6b3f42a90d96de01ccf6af417d7ed29dc30f5
[ "MIT" ]
1
2021-09-22T18:22:08.000Z
2021-09-22T18:22:08.000Z
#include <bits/stdc++.h> using namespace std; bool compare(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) { return a.first.second * 1.0 / a.first.first > b.first.second * 1.0 / b.first.first; } int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n; cin >> n; int V[n], W[n]; for (int i = 0; i < n; ++i) cin >> W[i]; for (int i = 0; i < n; ++i) cin >> V[i]; vector<pair<pair<int, int>, int>> items; for (int i = 0; i < n; ++i) items.push_back(make_pair(make_pair(W[i], V[i]), i + 1)); int k; cin >> k; sort(items.begin(), items.end(), compare); float max_profit = 0; vector<pair<int, int>> sack; for (int i = 0; i < n && k > 0; ++i) { int w = items[i].first.first, v = items[i].first.second, ind = items[i].second; if (w <= k) { k -= w; max_profit += v; sack.push_back(make_pair(ind, w)); } else { max_profit += k * v * 1.0 / w; sack.push_back(make_pair(ind, k)); k = 0; } } cout << "Maximum Value : " << max_profit << endl; cout << "item-weight" << endl; for (auto i : sack) cout << i.first << " " << i.second << endl; }
26.294118
87
0.480239
SukalpVishnoi
72a4b92309d39bd9701a8dd076af60135ae76805
25,286
hxx
C++
ants/lib/antsJointHistogramParzenShapeAndOrientationListSampleFunction.hxx
ncullen93/ANTsPy
a4c990dcd5b7445a45ce7b366ee018c7350e7d9f
[ "Apache-2.0" ]
3
2018-06-07T19:11:47.000Z
2019-06-10T05:24:06.000Z
ants/lib/antsJointHistogramParzenShapeAndOrientationListSampleFunction.hxx
ncullen93/ANTsPy
a4c990dcd5b7445a45ce7b366ee018c7350e7d9f
[ "Apache-2.0" ]
null
null
null
ants/lib/antsJointHistogramParzenShapeAndOrientationListSampleFunction.hxx
ncullen93/ANTsPy
a4c990dcd5b7445a45ce7b366ee018c7350e7d9f
[ "Apache-2.0" ]
1
2019-04-04T06:18:44.000Z
2019-04-04T06:18:44.000Z
/*========================================================================= Program: Advanced Normalization Tools Copyright (c) ConsortiumOfANTS. All rights reserved. See accompanying COPYING.txt or https://github.com/stnava/ANTs/blob/master/ANTSCopyright.txt 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 notices for more information. =========================================================================*/ #ifndef __antsJointHistogramParzenShapeAndOrientationListSampleFunction_hxx #define __antsJointHistogramParzenShapeAndOrientationListSampleFunction_hxx #include "antsJointHistogramParzenShapeAndOrientationListSampleFunction.h" #include "itkArray.h" #include "itkContinuousIndex.h" #include "itkDecomposeTensorFunction.h" #include "itkDiscreteGaussianImageFilter.h" #include "itkDivideByConstantImageFilter.h" #include "itkStatisticsImageFilter.h" namespace itk { namespace ants { namespace Statistics { template <class TListSample, class TOutput, class TCoordRep> JointHistogramParzenShapeAndOrientationListSampleFunction<TListSample, TOutput, TCoordRep> ::JointHistogramParzenShapeAndOrientationListSampleFunction() { this->m_NumberOfShapeJointHistogramBins = 32; this->m_NumberOfOrientationJointHistogramBins = 64; this->m_ShapeSigma = 1.0; this->m_OrientationSigma = 2.0; this->m_UseNearestNeighborIncrements = true; this->m_MaximumEigenvalue1 = 0; this->m_MaximumEigenvalue2 = 0; this->m_MinimumEigenvalue1 = 1; this->m_MinimumEigenvalue2 = 1; this->m_Interpolator = InterpolatorType::New(); this->m_Interpolator->SetSplineOrder( 3 ); this->m_JointHistogramImages[0] = ITK_NULLPTR; this->m_JointHistogramImages[1] = ITK_NULLPTR; this->m_JointHistogramImages[2] = ITK_NULLPTR; } template <class TListSample, class TOutput, class TCoordRep> JointHistogramParzenShapeAndOrientationListSampleFunction<TListSample, TOutput, TCoordRep> ::~JointHistogramParzenShapeAndOrientationListSampleFunction() { } template <class TListSample, class TOutput, class TCoordRep> void JointHistogramParzenShapeAndOrientationListSampleFunction<TListSample, TOutput, TCoordRep> ::IncrementJointHistogramForShape( RealType eigenvalue1, RealType eigenvalue2 ) { RealType newWeight = 1.0; // now define two joint histograms, one for shape, one for orientation. // first, the shape histogram --- 0,0 origin and spacing of 1 if( !this->m_JointHistogramImages[0] ) { typename JointHistogramImageType::SpacingType spacing; spacing.Fill( 1 ); typename JointHistogramImageType::PointType origin; origin.Fill( 0 ); typename JointHistogramImageType::SizeType size; size.Fill( this->m_NumberOfShapeJointHistogramBins ); this->m_JointHistogramImages[0] = AllocImage<JointHistogramImageType>(size); this->m_JointHistogramImages[0]->SetOrigin( origin ); this->m_JointHistogramImages[0]->SetSpacing( spacing ); this->m_JointHistogramImages[0]->FillBuffer( 0 ); } typename JointHistogramImageType::PointType shapePoint; if( eigenvalue1 > 1.0 ) { eigenvalue1 = 1.0; } if( eigenvalue2 > 1.0 ) { eigenvalue2 = 1.0; } if( eigenvalue1 < 0.0 ) { eigenvalue1 = 0.0; } if( eigenvalue2 < 0 ) { eigenvalue2 = 0.0; } shapePoint[0] = eigenvalue1 * ( this->m_NumberOfShapeJointHistogramBins - 1 ); shapePoint[1] = eigenvalue2 * ( this->m_NumberOfShapeJointHistogramBins - 1 ); ContinuousIndex<double, 2> shapeCidx; this->m_JointHistogramImages[0]->TransformPhysicalPointToContinuousIndex( shapePoint, shapeCidx ); typedef typename JointHistogramImageType::IndexType JointHistogramImageIndexType; JointHistogramImageIndexType shapeIdx; /** Nearest neighbor increment to JH */ if( this->m_UseNearestNeighborIncrements ) { shapeIdx[0] = static_cast<typename JointHistogramImageIndexType::IndexValueType>( std::floor( shapeCidx[0] + 0.5 ) ); shapeIdx[1] = static_cast<typename JointHistogramImageIndexType::IndexValueType>( std::floor( shapeCidx[1] + 0.5 ) ); if( this->m_JointHistogramImages[0]-> GetLargestPossibleRegion().IsInside( shapeIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[0]->GetPixel( shapeIdx ); this->m_JointHistogramImages[0]->SetPixel( shapeIdx, 1 + oldWeight ); } } else { /** linear addition */ shapeIdx[0] = static_cast<IndexValueType>( std::floor( shapeCidx[0] ) ); shapeIdx[1] = static_cast<IndexValueType>( std::floor( shapeCidx[1] ) ); RealType distance1 = std::sqrt( vnl_math_sqr( shapeCidx[0] - shapeIdx[0] ) + vnl_math_sqr( shapeCidx[1] - shapeIdx[1] ) ); shapeIdx[0]++; RealType distance2 = std::sqrt( vnl_math_sqr( shapeCidx[0] - shapeIdx[0] ) + vnl_math_sqr( shapeCidx[1] - shapeIdx[1] ) ); shapeIdx[1]++; RealType distance3 = std::sqrt( vnl_math_sqr( shapeCidx[0] - shapeIdx[0] ) + vnl_math_sqr( shapeCidx[1] - shapeIdx[1] ) ); shapeIdx[0]--; RealType distance4 = std::sqrt( vnl_math_sqr( shapeCidx[0] - shapeIdx[0] ) + vnl_math_sqr( shapeCidx[1] - shapeIdx[1] ) ); RealType sumDistance = distance1 + distance2 + distance3 + distance4; distance1 /= sumDistance; distance2 /= sumDistance; distance3 /= sumDistance; distance4 /= sumDistance; unsigned int whichHistogram = 0; shapeIdx[0] = static_cast<IndexValueType>( std::floor( shapeCidx[0] ) ); shapeIdx[1] = static_cast<IndexValueType>( std::floor( shapeCidx[1] ) ); if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( shapeIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel( shapeIdx ); this->m_JointHistogramImages[whichHistogram]->SetPixel( shapeIdx, ( 1.0 - distance1 ) * newWeight + oldWeight ); } shapeIdx[0]++; if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( shapeIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel( shapeIdx ); this->m_JointHistogramImages[whichHistogram]->SetPixel( shapeIdx, ( 1.0 - distance2 ) * newWeight + oldWeight ); } shapeIdx[1]++; if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( shapeIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel( shapeIdx ); this->m_JointHistogramImages[whichHistogram]->SetPixel( shapeIdx, ( 1.0 - distance3 ) * newWeight + oldWeight ); } shapeIdx[0]--; if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( shapeIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel( shapeIdx ); this->m_JointHistogramImages[whichHistogram]->SetPixel( shapeIdx, ( 1.0 - distance4) * newWeight + oldWeight ); } } return; } template <class TListSample, class TOutput, class TCoordRep> void JointHistogramParzenShapeAndOrientationListSampleFunction<TListSample, TOutput, TCoordRep> ::IncrementJointHistogramForOrientation( RealType x, RealType y, RealType z, unsigned int whichHistogram ) { RealType newWeight = 1.0; // 2nd, the orientation histogram. origin 0,0. spacing of 1,1. // need to be careful for wrap around in the 0 to 2*pi case. if( !this->m_JointHistogramImages[whichHistogram] ) { typename JointHistogramImageType::SpacingType spacing2; spacing2.Fill(1); typename JointHistogramImageType::PointType origin2; origin2.Fill(0); typename JointHistogramImageType::SizeType size2; size2.Fill( this->m_NumberOfOrientationJointHistogramBins ); size2[0] = size2[0] + 2; this->m_JointHistogramImages[whichHistogram] = AllocImage<JointHistogramImageType>(size2); this->m_JointHistogramImages[whichHistogram]->SetOrigin( origin2 ); this->m_JointHistogramImages[whichHistogram]->SetSpacing( spacing2 ); this->m_JointHistogramImages[whichHistogram]->FillBuffer( 0 ); } typename JointHistogramImageType::PointType orientPoint; RealType tp[2]; tp[1] = 0.0; // If eigenvector has negative x, we reflect it about the origin. // We do this to avoid redundancy in representation of the eigenvectors, // because they are all redundant. if( x < 0 ) { x *= -1; y *= -1; z *= -1; } tp[0] = std::acos( z ); // phi goes from 0.0 (+x axis) and goes to -pi/2 and pi/2. // theta goes from 0.0 (+z axis) and wraps at PI // if x and y are 0.0 or very close, return phi == 0 // we do this to eliminate redundancy in the distribution of orientations. if( vnl_math_abs( x ) + vnl_math_abs( y ) < 1e-9 ) { tp[1] = 0.0; } else { if( y == 0.0 ) { if( x > 0.0 ) { tp[1] = 0.0; } else { tp[1] = vnl_math::pi; } } else if( x == 0.0 ) { // avoid div by zero if( y > 0 ) { tp[1] = vnl_math::pi_over_2; } else { tp[1] = -vnl_math::pi_over_2; } } else if( x > 0.0 && y > 0.0 ) { // first quadrant tp[1] = std::atan( y / x ); } else if( x < 0.0 && y > 0.0 ) { // second quadrant tp[1] = vnl_math::pi + std::atan( y / x ); } else if( x < 0.0 && y < 0.0 ) { // third quadrant tp[1] = vnl_math::pi + atan( y / x ); } else { // fourth quadrant tp[1] = atan( y / x ); } } RealType psi = tp[0]; RealType theta = tp[1]; // note, if a point maps to 0 or 2*pi then it should contribute to both bins -- pretty much only difference between this // function and matlab code is the next 15 or so lines, as far as we see orientPoint[0] = psi / (vnl_math::pi ) * ( this->m_NumberOfOrientationJointHistogramBins - 1) + 1; orientPoint[1] = ( theta + vnl_math::pi_over_2 ) / vnl_math::pi * ( this->m_NumberOfOrientationJointHistogramBins - 1 ); ContinuousIndex<double, 2> orientCidx; this->m_JointHistogramImages[whichHistogram]-> TransformPhysicalPointToContinuousIndex( orientPoint, orientCidx ); typedef typename JointHistogramImageType::IndexType JointHistogramImageIndexType; JointHistogramImageIndexType orientIdx; /** Nearest neighbor interpolation */ if( this->m_UseNearestNeighborIncrements ) { orientIdx[0] = static_cast<typename JointHistogramImageIndexType::IndexValueType>( std::floor( orientCidx[0] + 0.5 ) ); orientIdx[1] = static_cast<typename JointHistogramImageIndexType::IndexValueType>( std::floor( orientCidx[1] + 0.5 ) ); if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( orientIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel( orientIdx ); this->m_JointHistogramImages[whichHistogram]-> SetPixel( orientIdx, 1 + oldWeight ); } } else { orientIdx[0] = static_cast<IndexValueType>( std::floor( orientCidx[0] ) ); orientIdx[1] = static_cast<IndexValueType>( std::floor( orientCidx[1] ) ); RealType distance1 = std::sqrt( vnl_math_sqr( orientCidx[0] - orientIdx[0] ) + vnl_math_sqr( orientCidx[1] - orientIdx[1] ) ); orientIdx[0]++; RealType distance2 = std::sqrt( vnl_math_sqr( orientCidx[0] - orientIdx[0] ) + vnl_math_sqr( orientCidx[1] - orientIdx[1] ) ); orientIdx[1]++; RealType distance3 = std::sqrt( vnl_math_sqr( orientCidx[0] - orientIdx[0] ) + vnl_math_sqr( orientCidx[1] - orientIdx[1] ) ); orientIdx[0]--; RealType distance4 = std::sqrt( vnl_math_sqr( orientCidx[0] - orientIdx[0] ) + vnl_math_sqr( orientCidx[1] - orientIdx[1] ) ); RealType sumDistance = distance1 + distance2 + distance3 + distance4; distance1 /= sumDistance; distance2 /= sumDistance; distance3 /= sumDistance; distance4 /= sumDistance; orientIdx[0] = static_cast<IndexValueType>( std::floor( orientCidx[0] ) ); orientIdx[1] = static_cast<IndexValueType>( std::floor( orientCidx[1] ) ); if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( orientIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel( orientIdx ); this->m_JointHistogramImages[whichHistogram]->SetPixel( orientIdx, ( 1.0 - distance1 ) * newWeight + oldWeight ); } orientIdx[0]++; if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( orientIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel( orientIdx ); this->m_JointHistogramImages[whichHistogram]->SetPixel( orientIdx, ( 1.0 - distance2 ) * newWeight + oldWeight ); } orientIdx[1]++; if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( orientIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel( orientIdx ); this->m_JointHistogramImages[whichHistogram]->SetPixel( orientIdx, ( 1.0 - distance3 ) * newWeight + oldWeight ); } orientIdx[0]--; if( this->m_JointHistogramImages[whichHistogram]-> GetLargestPossibleRegion().IsInside( orientIdx ) ) { RealType oldWeight = this->m_JointHistogramImages[whichHistogram]->GetPixel(orientIdx ); this->m_JointHistogramImages[whichHistogram]->SetPixel( orientIdx, ( 1.0 - distance4) * newWeight + oldWeight ); } } // The last thing we do is copy the [1,] column to the [NBins+1,] column and // the [NBins,] column to the [0,] column --- circular boundary conditions. typedef itk::ImageRegionIteratorWithIndex<JointHistogramImageType> Iterator; Iterator tIter( this->m_JointHistogramImages[whichHistogram], this->m_JointHistogramImages[whichHistogram]->GetBufferedRegion() ); for( tIter.GoToBegin(); !tIter.IsAtEnd(); ++tIter ) { IndexType index = tIter.GetIndex(); IndexType index2 = tIter.GetIndex(); if( index[0] == 0 ) { index2[0] = this->m_NumberOfOrientationJointHistogramBins; index2[1] = index[1]; tIter.Set( this->m_JointHistogramImages[whichHistogram]->GetPixel( index2 ) ); } if( index[0] == static_cast<typename IndexType::IndexValueType> (this->m_NumberOfOrientationJointHistogramBins + 1) ) { index2[0] = 1; index2[1] = index[1]; tIter.Set( this->m_JointHistogramImages[whichHistogram]->GetPixel( index2 ) ); } } return; } template <class TListSample, class TOutput, class TCoordRep> void JointHistogramParzenShapeAndOrientationListSampleFunction<TListSample, TOutput, TCoordRep> ::SetInputListSample( const InputListSampleType * ptr ) { Superclass::SetInputListSample( ptr ); if( !this->GetInputListSample() ) { return; } if( this->GetInputListSample()->Size() <= 1 ) { itkWarningMacro( "The input list sample has <= 1 element." << "Function evaluations will be equal to 0." ); return; } const unsigned int Dimension = this->GetInputListSample()->GetMeasurementVectorSize(); /** * Find the min/max values to define the histogram domain */ Array<RealType> minValues( Dimension ); minValues.Fill( NumericTraits<RealType>::max() ); Array<RealType> maxValues( Dimension ); maxValues.Fill( NumericTraits<RealType>::NonpositiveMin() ); typename InputListSampleType::ConstIterator It = this->GetInputListSample()->Begin(); while( It != this->GetInputListSample()->End() ) { InputMeasurementVectorType inputMeasurement = It.GetMeasurementVector(); for( unsigned int d = 0; d < Dimension; d++ ) { if( inputMeasurement[d] < minValues[d] ) { minValues[d] = inputMeasurement[d]; } if( inputMeasurement[d] > maxValues[d] ) { maxValues[d] = inputMeasurement[d]; } } ++It; } for( unsigned int d = 0; d < 3; d++ ) { this->m_JointHistogramImages[d] = ITK_NULLPTR; } RealType L = static_cast<RealType>( this->GetInputListSample()->GetMeasurementVectorSize() ); unsigned int D = static_cast<unsigned int>( 0.5 * ( -1 + std::sqrt( 1.0 + 8.0 * L ) ) ); It = this->GetInputListSample()->Begin(); while( It != this->GetInputListSample()->End() ) { InputMeasurementVectorType inputMeasurement = It.GetMeasurementVector(); // convert to a tensor then get its shape and primary orientation vector typedef VariableSizeMatrix<RealType> TensorType; TensorType T( D, D ); T.Fill( 0.0 ); unsigned int index = 0; for( unsigned int i = 0; i < D; i++ ) { for( unsigned int j = i; j < D; j++ ) { T(i, j) = inputMeasurement( index++ ); T(j, i) = T(i, j); } } // now decompose T into shape and orientation TensorType V; TensorType W; TensorType Tc = T; typedef DecomposeTensorFunction<TensorType> DecomposerType; typename DecomposerType::Pointer decomposer = DecomposerType::New(); decomposer->EvaluateSymmetricEigenDecomposition( Tc, W, V ); // now W holds the eigenvalues ( shape ) // for each tensor sample, we add its content to the relevant histogram. RealType eigenvalue1 = W(2, 2); RealType eigenvalue2 = ( W(1, 1) ); // + W(0, 0) ) * 0.5; if( eigenvalue1 > this->m_MaximumEigenvalue1 ) { this->m_MaximumEigenvalue1 = eigenvalue1; } if( eigenvalue2 > this->m_MaximumEigenvalue2 ) { this->m_MaximumEigenvalue2 = eigenvalue2; } if( eigenvalue1 < this->m_MinimumEigenvalue1 ) { this->m_MinimumEigenvalue1 = eigenvalue1; } if( eigenvalue2 < this->m_MinimumEigenvalue2 ) { this->m_MinimumEigenvalue2 = eigenvalue2; } ++It; } It = this->GetInputListSample()->Begin(); while( It != this->GetInputListSample()->End() ) { InputMeasurementVectorType inputMeasurement = It.GetMeasurementVector(); // convert to a tensor then get its shape and primary orientation vector typedef VariableSizeMatrix<RealType> TensorType; TensorType T( D, D ); T.Fill( 0.0 ); unsigned int index = 0; for( unsigned int i = 0; i < D; i++ ) { for( unsigned int j = i; j < D; j++ ) { T(i, j) = inputMeasurement( index++ ); T(j, i) = T(i, j); } } // now decompose T into shape and orientation TensorType V; TensorType W; TensorType Tc = T; typedef DecomposeTensorFunction<TensorType> DecomposerType; typename DecomposerType::Pointer decomposer = DecomposerType::New(); decomposer->EvaluateSymmetricEigenDecomposition( Tc, W, V ); // now W holds the eigenvalues ( shape ) // for each tensor sample, we add its content to the relevant histogram. RealType eigenvalue1 = W(2, 2); RealType eigenvalue2 = W(1, 1); eigenvalue1 /= ( this->m_MaximumEigenvalue1 - this->m_MinimumEigenvalue1 ); eigenvalue2 /= ( this->m_MaximumEigenvalue2 - this->m_MinimumEigenvalue2 ); // std::cout << " ev1 " << eigenvalue1 << " oev1 " << W(2,2) << " ev2 " << eigenvalue2 << " oev2 " << // W(1,1) << // std::endl; /** joint-hist model for the eigenvalues */ this->IncrementJointHistogramForShape( eigenvalue1, eigenvalue2 ); RealType x = V(0, 2); RealType y = V(1, 2); RealType z = V(2, 2); /** joint-hist model for the principal eigenvector */ this->IncrementJointHistogramForOrientation( x, y, z, 1 ); x = V(0, 1); y = V(1, 1); z = V(2, 1); /** joint-hist model for the second eigenvector */ this->IncrementJointHistogramForOrientation( x, y, z, 2 ); ++It; } for( unsigned int d = 0; d < 3; d++ ) { typedef DiscreteGaussianImageFilter<JointHistogramImageType, JointHistogramImageType> GaussianFilterType; typename GaussianFilterType::Pointer gaussian = GaussianFilterType::New(); gaussian->SetInput( this->m_JointHistogramImages[d] ); if( d == 0 ) // Shape { gaussian->SetVariance( this->m_ShapeSigma * this->m_ShapeSigma ); } else if( d == 1 ) // Orientation of 1st eigenvector { gaussian->SetVariance(this->m_OrientationSigma * this->m_OrientationSigma ); } else if( d == 2 ) // Orientation of 2nd eigenvector { gaussian->SetVariance( this->m_ShapeSigma * this->m_OrientationSigma ); } gaussian->SetMaximumError( 0.01 ); gaussian->SetUseImageSpacing( false ); gaussian->Update(); typedef StatisticsImageFilter<JointHistogramImageType> StatsFilterType; typename StatsFilterType::Pointer stats = StatsFilterType::New(); stats->SetInput( gaussian->GetOutput() ); stats->Update(); typedef DivideByConstantImageFilter<JointHistogramImageType, RealType, JointHistogramImageType> DividerType; typename DividerType::Pointer divider = DividerType::New(); divider->SetInput( gaussian->GetOutput() ); divider->SetConstant( stats->GetSum() ); divider->Update(); this->m_JointHistogramImages[d] = divider->GetOutput(); } /* write out histograms--for debugging static int which_class=0; which_class++; std::string string; std::stringstream outstring; outstring<<which_class; string=outstring.str(); typedef ImageFileWriter< JointHistogramImageType > WriterType; typename WriterType::Pointer writer = WriterType::New(); std::string output( "output_shape"+string+".nii.gz" ); writer->SetFileName( output.c_str() ); writer->SetInput(this->m_JointHistogramImages[0] ); writer->Update(); typedef ImageFileWriter< JointHistogramImageType > WriterType2; typename WriterType2::Pointer writer2 = WriterType::New(); std::string output2( "output_orientation"+string+".nii.gz" ); writer2->SetFileName( output2.c_str() ); writer2->SetInput(this->m_JointHistogramImages[1] ); writer2->Update(); std::cout << "Writing output of histograms." << std::endl; */ } template <class TListSample, class TOutput, class TCoordRep> TOutput JointHistogramParzenShapeAndOrientationListSampleFunction<TListSample, TOutput, TCoordRep> ::Evaluate( const InputMeasurementVectorType & measurement ) const { try { RealType probability = 1.0; for( unsigned int d = 0; d < 2; d++ ) { typename JointHistogramImageType::PointType point; point[0] = measurement[d]; this->m_Interpolator->SetInputImage( this->m_JointHistogramImages[d] ); if( this->m_Interpolator->IsInsideBuffer( point ) ) { probability *= this->m_Interpolator->Evaluate( point ); } else { return 0; } } return probability; } catch( ... ) { return 0; } } /** * Standard "PrintSelf" method */ template <class TListSample, class TOutput, class TCoordRep> void JointHistogramParzenShapeAndOrientationListSampleFunction<TListSample, TOutput, TCoordRep> ::PrintSelf( std::ostream& os, Indent indent) const { os << indent << "Shape Sigma: " << this->m_ShapeSigma << std::endl; os << indent << "Number of shape histogram bins: " << this->m_NumberOfShapeJointHistogramBins << std::endl; os << indent << "Orientation Sigma: " << this->m_OrientationSigma << std::endl; os << indent << "Number of orientation histogram bins: " << this->m_NumberOfOrientationJointHistogramBins << std::endl; os << indent << "Minimum eigenvalue 1: " << this->m_MinimumEigenvalue1; os << indent << "Minimum eigenvalue 2: " << this->m_MinimumEigenvalue2; os << indent << "Maximum eigenvalue 1: " << this->m_MaximumEigenvalue1; os << indent << "Maximum eigenvalue 2: " << this->m_MaximumEigenvalue2; if( this->m_UseNearestNeighborIncrements ) { os << indent << "Use nearest neighbor increments." << std::endl; } else { os << indent << "Use linear interpolation for increments." << std::endl; } } } // end of namespace Statistics } // end of namespace ants } // end of namespace itk #endif
36.540462
121
0.642174
ncullen93
72a4db9cdce58e0e49216b312758cd8ca6afbc9d
14,532
cpp
C++
src/mrilucpp/Ifpack_MRILU.cpp
jthies/i-emic
8bc351e2e6e31ac6a4c14a16fadfa65c0e04b6a7
[ "Apache-2.0" ]
2
2020-11-30T08:37:53.000Z
2021-01-18T09:53:59.000Z
src/mrilucpp/Ifpack_MRILU.cpp
jthies/i-emic
8bc351e2e6e31ac6a4c14a16fadfa65c0e04b6a7
[ "Apache-2.0" ]
83
2019-03-04T10:07:02.000Z
2022-01-20T10:45:40.000Z
src/mrilucpp/Ifpack_MRILU.cpp
jthies/i-emic
8bc351e2e6e31ac6a4c14a16fadfa65c0e04b6a7
[ "Apache-2.0" ]
4
2019-02-18T10:17:59.000Z
2019-03-27T12:24:57.000Z
/********************************************************************** * Copyright by Jonas Thies, Univ. of Groningen 2006/7/8. * * Permission to use, copy, modify, redistribute is granted * * as long as this header remains intact. * * contact: jonas@math.rug.nl * **********************************************************************/ #include "Ifpack_MRILU.h" #include "Epetra_MultiVector.h" #include "Epetra_Vector.h" #include "Epetra_Comm.h" #include "Epetra_MpiComm.h" #include "Epetra_RowMatrix.h" #include "Epetra_CrsMatrix.h" #include <iomanip> #include "Teuchos_oblackholestream.hpp" #include "Teuchos_StandardCatchMacros.hpp" #include "GlobalDefinitions.H" // we still use one or two subroutines from the Fortran code, // this might (and should) be changed in the future extern "C" { #ifdef HAVE_IFPACK_MRILU void mrilucpp_create(int* id, int* n, int* nnz, int* beg, int* jco, double* co); void mrilucpp_destroy(int* id); void mrilucpp_set_params(const int* id, int* blocksize, int* cutmck, int* scarow, int* xactelm,int* clsonce, double* nlsfctr, double* epsw, double* elmfctr, int* gusmod, double* gusfctr,double* redfctr, double* schtol, double* denslim, double* globfrac, double* locfrac, double* sparslim, int* ilutype, double* droptol, double* compfct, double* cpivtol, double* lutol_, int* singlu, int* outlev); void mrilucpp_compute(const int* id); void mrilucpp_apply(const int* id, int* dim, const double *rhs, double *sol); #endif }//extern #ifdef DEBUGGING #define DEBUG(s) std::cerr << comm->MyPID() << ": " << s << std::endl; #else #define DEBUG(s) #endif #ifndef CHECK_ZERO # define CHECK_ZERO(funcall) {int ierr = funcall; \ if (ierr) {std::cerr<<"Trilinos Error "<<ierr<<" returned from call "<<#funcall<<std::endl;}} #endif /////////////////////////////////////////////////////////////////////////////// // CLASS IFPACK_MRILU /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////// // note: 'needs_setup' is currently irrelevant, the preconditioner is recomputed // completely every time. Ifpack_MRILU::Ifpack_MRILU(Teuchos::RCP<Epetra_CrsMatrix> A, Teuchos::RCP<Epetra_Comm> comm_) : mrilu_id(0), Matrix_(A), comm(comm_), is_initialized(false),is_computed(false) { std::string s1="MRILU("; std::string s2(A->Label()); std::string s3=")"; label = s1+s2+s3; DEBUG("Ifpack_MRILU constructor called"); default_params(); } //Constructor Ifpack_MRILU::Ifpack_MRILU(Epetra_RowMatrix* A) : mrilu_id(0), is_initialized(false),is_computed(false) { std::string s1="MRILU("; std::string s2(A->Label()); std::string s3=")"; label = s1+s2+s3; Matrix_ = Teuchos::rcp(A,false); comm=Teuchos::rcp(&(A->Comm()),false); DEBUG("Ifpack_MRILU Ifpack constructor called"); default_params(); //std::cout << "PID " << comm->MyPID()<<", MRILU local matrix size = "<<A->NumMyRows()<<std::endl; } //Constructor /////////////////////////////////////////////////////////////////////////////// // destructor /////////////////////////////////////////////////////////////////////////////// Ifpack_MRILU::~Ifpack_MRILU() { DEBUG("Ifpack_MRILU destructor called"); if (mrilu_id>0) { DEBUG("Destroy MRILU preconditioner...\n"); #ifdef HAVE_IFPACK_MRILU mrilucpp_destroy(&mrilu_id); #endif } is_initialized=false; is_computed=false; } ////////////// const Epetra_Comm& Ifpack_MRILU::Comm() const {return *comm;} const Epetra_Map& Ifpack_MRILU::OperatorDomainMap() const {return Matrix_->OperatorDomainMap();} const Epetra_Map& Ifpack_MRILU::OperatorRangeMap() const {return Matrix_->OperatorRangeMap();} int Ifpack_MRILU::SetParameters(Teuchos::ParameterList& ifpParams) { Teuchos::ParameterList& lsParams = ifpParams.sublist("MRILU"); DEBUG("Parameters supplied by User: "); DEBUG(lsParams); blocksize = lsParams.get("blocksize",blocksize); cutmck = lsParams.get("cutmck",cutmck); scarow = lsParams.get("scarow",scarow); xactelm = lsParams.get("xactelm",xactelm); clsonce = lsParams.get("clsonce",clsonce); nlsfctr = lsParams.get("nlsfctr",nlsfctr); epsw = lsParams.get("epsw",epsw); elmfctr = lsParams.get("elmfctr",elmfctr); gusmod = lsParams.get("gusmod",gusmod); gusfctr = lsParams.get("gusfctr",gusfctr); redfctr = lsParams.get("redfctr",redfctr); schtol = lsParams.get("schtol",schtol); denslim = lsParams.get("denslim", denslim); globfrac = lsParams.get("globfrac", globfrac); locfrac = lsParams.get("locfrac", locfrac); sparslim = lsParams.get("sparslim", sparslim); ilutype = lsParams.get("ilutype", ilutype); droptol = lsParams.get("droptol", droptol); compfct = lsParams.get("compfct", compfct); cpivtol = lsParams.get("cpivtol", cpivtol); lutol = lsParams.get("lutol", lutol); singlu = lsParams.get("singlu", singlu); outlev = lsParams.get("Output Level",outlev); DEBUG("Parameters used: "); DEBUG(lsParams); return 0; } // build preconditioner. This function is called by NOX/LOCA, // I am not sure what the arguments mean but we do not use them // anyway bool Ifpack_MRILU::computePreconditioner(const Epetra_Vector& x, Epetra_Operator& Prec, Teuchos::ParameterList* p) { DEBUG("+++ Enter Ifpack_MRILU::computePreconditioner"); if (p!=NULL) this->SetParameters(*p); if (!IsInitialized()) { this->Initialize(); } this->Compute(); DEBUG("--- Leave Ifpack_MRILU::computePreconditioner"); return true; } /////////////////////////////////////////////////////////////////////////////// // apply inverse preconditioner step /////////////////////////////////////////////////////////////////////////////// int Ifpack_MRILU:: ApplyInverse(const Epetra_MultiVector& input, Epetra_MultiVector& result) const { if (!IsComputed()) { Error("Ifpack_MRILU not yet computed!",__FILE__,__LINE__); } if (&input == &result) Error("aliased call to Ifpack_MRILU::ApplyInverse",__FILE__,__LINE__); DEBUG("+++ Enter Ifpack_MRILU::ApplyInverse"); if (input.NumVectors()!=1) { this->Error("Multiple Rhs not supported by Ifpack_MRILU!",__FILE__,__LINE__); } #ifdef HAVE_IFPACK_MRILU int n = input.MyLength(); double *sol_array; //= new double[n]; const double *rhs_array; //= new double[n]; //CHECK_ZERO(input.ExtractCopy(rhs_array,n)); rhs_array = input[0]; sol_array = result[0]; DEBUG("Apply MRILU preconditioner..."); /* if (outlev>3) { std::cout << "Apply " << label << std::endl; } */ if (is_identity) result = input; else { mrilucpp_apply(&mrilu_id, &n, rhs_array,sol_array); } //for (int i=0;i<n;i++) result[0][i]=sol_array[i]; //delete [] sol_array; //delete [] rhs_array; #else std::cout << "WARNING: MRILU is not available, using identity preconditioner."<<std::endl; result=input; #endif DEBUG("done!"); DEBUG("+++ Leave Ifpack_MRILU::ApplyInverse"); return 0; } /////////////////////////////////////////////////////////////////////////////// // Apply preconditioner matrix (not available) /////////////////////////////////////////////////////////////////////////////// int Ifpack_MRILU:: Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const { this->Error("Ifpack_MRILU::Apply() - method is NOT implemented!! ",__FILE__,__LINE__); return false; } /////////////////////////////////////////////////////////////////////////////// // inf-norm (n/a) /////////////////////////////////////////////////////////////////////////////// double Ifpack_MRILU::NormInf() const { this->Error("Ifpack_MRILU::NormInf() - method is NOT implemented!! ",__FILE__,__LINE__); return -1.0; } ////////////////////////////////////////////////////////////////////////////// // remaining IFPACK interface // ////////////////////////////////////////////////////////////////////////////// //! Computes all it is necessary to initialize the preconditioner. int Ifpack_MRILU::Initialize() { DEBUG("+++ Enter Ifpack_MRILU::Initialize"); // extract CRS array of the local Jacobian. int nnz = Matrix_->NumMyNonzeros(); int nrows = Matrix_->NumMyRows(); // although we might get CRS arrays directly from Epetra, // this method is preferred because it is implementation independent int* beg = new int[nrows+1]; int* jco = new int[nnz]; double* co = new double[nnz]; int len; beg[0] = 0; int idx = 0; is_identity = true; for (int i = 0; i < nrows; i++) { CHECK_ZERO(Matrix_->ExtractMyRowCopy(i, nnz-beg[i], len, co+beg[i], jco+beg[i])); beg[i+1] = beg[i] + len; // Check whether this matrix is the identity if (is_identity) { for (int j = beg[i]; j != beg[i+1]; ++j) { if ( ((jco[idx] == i) && (std::abs(co[idx] - 1.0) > 1e-7)) || ((jco[idx] != i) && (std::abs(co[idx]) > 1e-7)) ) { is_identity = false; break; } idx++; } } } DEBUG("Create preconditioner..."); #ifdef HAVE_IFPACK_MRILU // the loca 'Reuse Policy' doesn't work for user // defined preconditioners, it seems. They just // call this function whenever they want a new precond. mrilucpp_destroy(&mrilu_id); // note that the conversion to 1-based indexing is done in fortran: mrilucpp_create(&mrilu_id, &nrows, &nnz, beg, jco, co); #endif delete [] beg; delete [] co; delete [] jco; is_initialized = true; DEBUG("+++ Leave Ifpack_MRILU::Initialize"); return 0; } //! Returns true if the preconditioner has been successfully initialized, false otherwise. bool Ifpack_MRILU::IsInitialized() const { return is_initialized; } //! Computes all it is necessary to apply the preconditioner. int Ifpack_MRILU::Compute() { DEBUG("Enter Ifpack_MRILU::Compute"); #ifdef HAVE_IFPACK_MRILU //note: needs_setup is ignored up to now if (comm->NumProc()>1) { // this class should be run through an Ifpack_LocalFilter or the like: this->Error("The MRILU preconditioner is not intended for parallel use!",__FILE__,__LINE__); } if (!this->IsInitialized()) this->Initialize(); DEBUG("set parameters..."); mrilucpp_set_params( &mrilu_id, &blocksize, &cutmck , &scarow , &xactelm , &clsonce, &nlsfctr, &epsw , &elmfctr, &gusmod , &gusfctr, &redfctr, &schtol , &denslim, &globfrac, &locfrac, &sparslim, &ilutype, &droptol, &compfct , &cpivtol, &lutol, &singlu , &outlev); DEBUG("Compute factorization..."); if (outlev>3) { std::cout << "Compute " << label << std::endl; } mrilucpp_compute(&mrilu_id); DEBUG("done!"); // after building the preconditioner, the internal csr matrix is destroyed is_computed=true; is_initialized=false; // always have to re-initialize before calling Compute again! #else std::cout << "WARNING: MRILU is not available, using identity!"<<std::endl; #endif DEBUG("Leave Ifpack_MRILU::Compute"); return 0; } //! Returns true if the preconditioner has been successfully computed, false otherwise. bool Ifpack_MRILU::IsComputed() const { return is_computed; } //! Computes the condition number estimate, returns its value. double Ifpack_MRILU::Condest(const Ifpack_CondestType CT, const int MaxIters, const double Tol, Epetra_RowMatrix* Matrix) { // this is not yet implemented, although it should be trivial to get // some estimate from the ILU factorization condest=-1.0; return condest; } //! Returns the computed condition number estimate, or -1.0 if not computed. double Ifpack_MRILU::Condest() const { return condest; } //! Returns a pointer to the matrix to be preconditioned. const Epetra_RowMatrix& Ifpack_MRILU::Matrix() const { if (Matrix_==Teuchos::null) { Error("Matrix handle not available!",__FILE__,__LINE__); } return *Matrix_; } // TODO: none of the performance measuring routines below are implemented, yet //! Returns the number of calls to Initialize(). int Ifpack_MRILU::NumInitialize() const { return 0; } //! Returns the number of calls to Compute(). int Ifpack_MRILU::NumCompute() const { return 0; } //! Returns the number of calls to ApplyInverse(). int Ifpack_MRILU::NumApplyInverse() const { return 0; } //! Returns the time spent in Initialize(). double Ifpack_MRILU::InitializeTime() const { return -1.0; } //! Returns the time spent in Compute(). double Ifpack_MRILU::ComputeTime() const { return -1.0; } //! Returns the time spent in ApplyInverse(). double Ifpack_MRILU::ApplyInverseTime() const { return -1.0; } //! Returns the number of flops in the initialization phase. double Ifpack_MRILU::InitializeFlops() const { return 0.0; } //! Returns the number of flops in the computation phase. double Ifpack_MRILU::ComputeFlops() const { return 0.0; } //! Returns the number of flops in the application of the preconditioner. double Ifpack_MRILU::ApplyInverseFlops() const { return 0.0; } //! Prints basic information on iostream. This function is used by operator<<. std::ostream& Ifpack_MRILU::Print(std::ostream& os) const { // TODO: print something interesting for the user to read and enjoy os << this->Label(); return os; } void Ifpack_MRILU::default_params() { blocksize=1; cutmck=false; scarow = true; xactelm = false; clsonce = false; nlsfctr = 0.1; epsw = 1e-2; elmfctr = 0.1; gusmod = false; gusfctr = 1.0; redfctr = 0.8; schtol = 0.0; denslim = 0.01; globfrac = 0.1; locfrac = 1.0; sparslim = 0.9; ilutype = 9; droptol = 1e-4; compfct = 1.0; cpivtol = 0.5; lutol = 1e-10; singlu = false; outlev = 2; } void Ifpack_MRILU::Error(std::string msg, std::string file, int line) const { std::cerr << "ERROR: "<<msg<<std::endl; std::cerr << "("<<file<<", line "<<line<<")\n"; #ifdef HAVE_MPI MPI_Abort(MPI_COMM_WORLD,-1); #endif exit(-1); }
28.217476
99
0.595789
jthies
72a7799234f20ef47ac4bbce25b728ce18f55df6
19,959
cpp
C++
Base/PLRenderer/src/Texture/TextureAniLoaderPL.cpp
ktotheoz/pixellight
43a661e762034054b47766d7e38d94baf22d2038
[ "MIT" ]
83
2015-01-08T15:06:14.000Z
2021-07-20T17:07:00.000Z
Base/PLRenderer/src/Texture/TextureAniLoaderPL.cpp
PixelLightFoundation/pixellight
43a661e762034054b47766d7e38d94baf22d2038
[ "MIT" ]
19
2018-08-24T08:10:13.000Z
2018-11-29T06:39:08.000Z
Base/PLRenderer/src/Texture/TextureAniLoaderPL.cpp
ktotheoz/pixellight
43a661e762034054b47766d7e38d94baf22d2038
[ "MIT" ]
40
2015-02-25T18:24:34.000Z
2021-03-06T09:01:48.000Z
/*********************************************************\ * File: TextureAniLoaderPL.cpp * * * Copyright (C) 2002-2013 The PixelLight Team (http://www.pixellight.org/) * * This file is part of PixelLight. * * 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. \*********************************************************/ //[-------------------------------------------------------] //[ Includes ] //[-------------------------------------------------------] #include <PLCore/Xml/Xml.h> #include <PLCore/Log/Log.h> #include "PLRenderer/Texture/AniInfo.h" #include "PLRenderer/Texture/TextureAni.h" #include "PLRenderer/Texture/TextureManager.h" #include "PLRenderer/Texture/TextureAniLoaderPL.h" //[-------------------------------------------------------] //[ Namespace ] //[-------------------------------------------------------] using namespace PLCore; using namespace PLMath; namespace PLRenderer { //[-------------------------------------------------------] //[ RTTI interface ] //[-------------------------------------------------------] pl_implement_class(TextureAniLoaderPL) //[-------------------------------------------------------] //[ Public RTTI methods ] //[-------------------------------------------------------] bool TextureAniLoaderPL::Load(TextureAni &cTextureAni, File &cFile) { // Load XML document XmlDocument cDocument; if (cDocument.Load(cFile)) { // Get texture animation element const XmlElement *pTextureAniElement = cDocument.GetFirstChildElement("TextureAnimation"); if (pTextureAniElement) { // Get the format version const int nVersion = pTextureAniElement->GetAttribute("Version").GetInt(); // Unknown if (nVersion > 1) { PL_LOG(Error, cDocument.GetValue() + ": " + UnknownFormatVersion) // 1 (current) } else if (nVersion == 1) { return LoadV1(cTextureAni, *pTextureAniElement); // ""/0 (same format as 1) } else if (nVersion == 0) { // [DEPRECATED] PL_LOG(Warning, cDocument.GetValue() + ": " + DeprecatedFormatVersion) return LoadV1(cTextureAni, *pTextureAniElement); // No longer supported format version } else if (nVersion >= 0) { PL_LOG(Warning, cDocument.GetValue() + ": " + NoLongerSupportedFormatVersion) // Invalid format version (negative!) } else { PL_LOG(Error, cDocument.GetValue() + ": " + InvalidFormatVersion) } } else { PL_LOG(Error, "Can't find 'TextureAnimation' element") } } else { PL_LOG(Error, cDocument.GetValue() + ": " + cDocument.GetErrorDesc()) } // Error! return false; } bool TextureAniLoaderPL::Save(const TextureAni &cTextureAni, File &cFile) { // Create XML document XmlDocument cDocument; // Add declaration XmlDeclaration *pDeclaration = new XmlDeclaration("1.0", "", ""); cDocument.LinkEndChild(*pDeclaration); // Add texture animation XmlElement *pTextureAniElement = new XmlElement("TextureAnimation"); pTextureAniElement->SetAttribute("Version", "1"); // Add texture frames if (cTextureAni.GetTextureFrames().GetNumOfElements()) { XmlElement *pTextureFramesElement = new XmlElement("TextureFrames"); // Loop through all frames for (uint32 i=0; i<cTextureAni.GetTextureFrames().GetNumOfElements(); i++) { // Get the frame information const TextureAni::TextureFrame *pTextureFrame = cTextureAni.GetTextureFrames()[i]; if (pTextureFrame) { XmlElement *pFrameElement = new XmlElement("Frame"); if (pTextureFrame->pTextureHandler && pTextureFrame->pTextureHandler->GetResource()) { // Add value XmlText *pValue = new XmlText(pTextureFrame->pTextureHandler->GetResource()->GetName()); pFrameElement->LinkEndChild(*pValue); } // Link frame element pTextureFramesElement->LinkEndChild(*pFrameElement); } } // Link texture frames element pTextureAniElement->LinkEndChild(*pTextureFramesElement); } // Add matrix frames if (cTextureAni.GetMatrixFrames().GetNumOfElements()) { XmlElement *pMatrixFramesElement = new XmlElement("MatrixFrames"); // Loop through all frames for (uint32 i=0; i<cTextureAni.GetMatrixFrames().GetNumOfElements(); i++) { // Get the frame information const TextureAni::MatrixFrame *pMatrixFrame = cTextureAni.GetMatrixFrames()[i]; if (pMatrixFrame) { XmlElement *pFrameElement = new XmlElement("Frame"); // Add position if (pMatrixFrame->vTranslation != Vector3::Zero) pFrameElement->SetAttribute("Position", pMatrixFrame->vTranslation.ToString()); // Add rotation if (pMatrixFrame->vRotation != Vector3::Zero) pFrameElement->SetAttribute("Rotation", pMatrixFrame->vRotation.ToString()); // Add scale if (pMatrixFrame->vScale != Vector3::One) pFrameElement->SetAttribute("Scale", pMatrixFrame->vScale.ToString()); // Link frame element pMatrixFramesElement->LinkEndChild(*pFrameElement); } } // Link matrix frames element pTextureAniElement->LinkEndChild(*pMatrixFramesElement); } // Add color frames if (cTextureAni.GetColorFrames().GetNumOfElements()) { XmlElement *pColorFramesElement = new XmlElement("ColorFrames"); // Loop through all frames for (uint32 i=0; i<cTextureAni.GetColorFrames().GetNumOfElements(); i++) { // Get the frame information const TextureAni::ColorFrame *pColorFrame = cTextureAni.GetColorFrames()[i]; if (pColorFrame) { XmlElement *pFrameElement = new XmlElement("Frame"); // Add value XmlText *pValue = new XmlText(pColorFrame->vColor.ToString()); pFrameElement->LinkEndChild(*pValue); // Link frame element pColorFramesElement->LinkEndChild(*pFrameElement); } } // Link color frames element pTextureAniElement->LinkEndChild(*pColorFramesElement); } // Add texture animation information AddAniInfoManager(*pTextureAniElement, cTextureAni.GetTextureAnimationManager(), "Texture"); // Add matrix animation information AddAniInfoManager(*pTextureAniElement, cTextureAni.GetMatrixAnimationManager(), "Matrix"); // Add color animation information AddAniInfoManager(*pTextureAniElement, cTextureAni.GetColorAnimationManager(), "Color"); // Link texture animation element cDocument.LinkEndChild(*pTextureAniElement); // Save settings cDocument.Save(cFile); // Done return true; } //[-------------------------------------------------------] //[ Public functions ] //[-------------------------------------------------------] /** * @brief * Default constructor */ TextureAniLoaderPL::TextureAniLoaderPL() { } /** * @brief * Destructor */ TextureAniLoaderPL::~TextureAniLoaderPL() { } //[-------------------------------------------------------] //[ Private functions ] //[-------------------------------------------------------] /** * @brief * Loader implementation for format version 1 */ bool TextureAniLoaderPL::LoadV1(TextureAni &cTextureAni, const XmlElement &cTextureAniElement) const { // Iterate through all texture frames const XmlNode *pTextureFramesNode = cTextureAniElement.GetFirstChild("TextureFrames"); while (pTextureFramesNode) { // Iterate through all texture frames const XmlNode *pTextureFrameNode = pTextureFramesNode->GetFirstChild("Frame"); while (pTextureFrameNode) { // Get value const XmlNode *pNode = pTextureFrameNode->GetFirstChild(); if (pNode && pNode->GetType() == XmlNode::Text) { String sValue = pNode->GetValue(); if (sValue.GetLength()) { // Create texture frame TextureAni::TextureFrame *pTextureFrame = new TextureAni::TextureFrame; pTextureFrame->pTextureHandler = new TextureHandler(); pTextureFrame->pTextureHandler->Load(cTextureAni.GetTextureManager(), sValue); // Add texture frame cTextureAni.GetTextureFrames().Add(pTextureFrame); } } // Next node, please pTextureFrameNode = pTextureFramesNode->IterateChildren("Frame", pTextureFrameNode); } // Next node, please pTextureFramesNode = cTextureAniElement.IterateChildren("TextureFrames", pTextureFramesNode); } // Iterate through all matrix frames const XmlNode *pMatrixFramesNode = cTextureAniElement.GetFirstChild("MatrixFrames"); while (pMatrixFramesNode) { // Iterate through all matrix frames const XmlElement *pMatrixFrameElement = pMatrixFramesNode->GetFirstChildElement("Frame"); while (pMatrixFrameElement) { // Create and add matrix frame TextureAni::MatrixFrame *pMatrixFrame = new TextureAni::MatrixFrame; cTextureAni.GetMatrixFrames().Add(pMatrixFrame); pMatrixFrame->vScale = Vector3::One; // Position String sValue = pMatrixFrameElement->GetAttribute("Position"); if (sValue.GetLength()) pMatrixFrame->vTranslation.FromString(sValue); // Rotation sValue = pMatrixFrameElement->GetAttribute("Rotation"); if (sValue.GetLength()) pMatrixFrame->vRotation.FromString(sValue); // Scale sValue = pMatrixFrameElement->GetAttribute("Scale"); if (sValue.GetLength()) pMatrixFrame->vScale.FromString(sValue); // Next element, please pMatrixFrameElement = pMatrixFrameElement->GetNextSiblingElement("Frame"); } // Next node, please pMatrixFramesNode = cTextureAniElement.IterateChildren("MatrixFrames", pMatrixFramesNode); } // Iterate through all color frames const XmlNode *pColorFramesNode = cTextureAniElement.GetFirstChild("ColorFrames"); while (pColorFramesNode) { // Iterate through all color frames const XmlNode *pColorFrameNode = pColorFramesNode->GetFirstChild("Frame"); while (pColorFrameNode) { // Get value const XmlNode *pNode = pColorFrameNode->GetFirstChild(); if (pNode && pNode->GetType() == XmlNode::Text) { const String sValue = pNode->GetValue(); if (sValue.GetLength()) { // Create and add color frame TextureAni::ColorFrame *pColorFrame = new TextureAni::ColorFrame; cTextureAni.GetColorFrames().Add(pColorFrame); pColorFrame->vColor.FromString(sValue); } } // Next node, please pColorFrameNode = pColorFramesNode->IterateChildren("Frame", pColorFrameNode); } // Next element, please pColorFramesNode = cTextureAniElement.IterateChildren("ColorFrames", pColorFramesNode); } // Iterate through all animations int nValue; float fValue; const XmlElement *pAnimationElement = cTextureAniElement.GetFirstChildElement("Animation"); while (pAnimationElement) { AniInfo *pAnimation = nullptr; uint32 nFrames = 0; // Type String sValue = pAnimationElement->GetAttribute("Type"); if (sValue.GetLength()) { // Texture if (sValue == "Texture") { cTextureAni.CreateStandardTextureAnimation(); pAnimation = cTextureAni.GetTextureAnimationManager().Create(); pAnimation->SetType(0); // Matrix } else if (sValue == "Matrix") { cTextureAni.CreateStandardMatrixAnimation(); pAnimation = cTextureAni.GetMatrixAnimationManager().Create(); pAnimation->SetType(1); // Color } else if (sValue == "Color") { cTextureAni.CreateStandardColorAnimation(); pAnimation = cTextureAni.GetColorAnimationManager().Create(); pAnimation->SetType(2); } if (pAnimation) { switch (pAnimation->GetType()) { case 0: nFrames = cTextureAni.GetTextureFrames().GetNumOfElements(); break; case 1: nFrames = cTextureAni.GetMatrixFrames().GetNumOfElements(); break; case 2: nFrames = cTextureAni.GetColorFrames().GetNumOfElements(); break; } } } if (pAnimation) { // Name sValue = pAnimationElement->GetAttribute("Name"); if (sValue.GetLength()) pAnimation->SetName(sValue); // Start if (pAnimationElement->QueryIntAttribute("Start", &nValue) == XmlBase::Success) { if (nValue >= static_cast<int>(nFrames)) pAnimation->SetStartFrame(nFrames-1); else { if (nValue < 0) nValue = 0; pAnimation->SetStartFrame(nValue); } } // End if (pAnimationElement->QueryIntAttribute("End", &nValue) == XmlBase::Success) { if (nValue >= static_cast<int>(nFrames)) pAnimation->SetEndFrame(nFrames-1); else { if (nValue < 0) nValue = 0; pAnimation->SetEndFrame(nValue); } } // Speed if (pAnimationElement->QueryFloatAttribute("Speed", &fValue) == XmlBase::Success) pAnimation->SetSpeed(fValue); // Loop sValue = pAnimationElement->GetAttribute("Loop"); if (sValue.GetLength()) { if (sValue.GetBool()) pAnimation->SetFlags(pAnimation->GetFlags() | AnimationInfo::Loop); else pAnimation->SetFlags(pAnimation->GetFlags() & ~AnimationInfo::Loop); } // PingPong sValue = pAnimationElement->GetAttribute("PingPong"); if (sValue.GetLength()) { if (sValue.GetBool()) pAnimation->SetFlags(pAnimation->GetFlags() | AnimationInfo::PingPong); else pAnimation->SetFlags(pAnimation->GetFlags() & ~AnimationInfo::PingPong); } // Iterate through all frames const XmlNode *pFrameNode = pAnimationElement->GetFirstChild("Frame"); while (pFrameNode) { // Is this an XML element? if (pFrameNode->GetType() == XmlNode::Element) { const XmlElement *pFrameElement = static_cast<const XmlElement*>(pFrameNode); // ID nValue = -1; if (pFrameElement->QueryIntAttribute("ID", &nValue) == XmlBase::Success && nValue >= 0 && nValue < static_cast<int>(nFrames)) { // Speed float fSpeed = 1.0f; sValue = pFrameElement->GetAttribute("Speed"); if (sValue.GetLength()) fSpeed = sValue.GetFloat(); // Set pAnimation->GetFrameInfo(nValue)->SetSpeed(fSpeed); } } // Next node, please pFrameNode = pAnimationElement->IterateChildren("Frame", pFrameNode); } // Iterate through all events const XmlNode *pEventNode = pAnimationElement->GetFirstChild("Event"); while (pEventNode) { // Is this an XML element? if (pEventNode->GetType() == XmlNode::Element) { const XmlElement *pEventElement = static_cast<const XmlElement*>(pEventNode); // FrameID int nFrameID = -1; if (pEventElement->QueryIntAttribute("FrameID", &nFrameID) == XmlBase::Success && nFrameID >= 0 && nFrameID < static_cast<int>(nFrames)) { // ID int nID = 0; if (pEventElement->QueryIntAttribute("ID", &nID) == XmlBase::Success) { // Create the event, added automatically to the event manager new AnimationEvent(nID, nFrameID, &pAnimation->GetEventManager()); } } } // Next node, please pEventNode = pAnimationElement->IterateChildren("Event", pEventNode); } } // Next element, please pAnimationElement = pAnimationElement->GetNextSiblingElement("Animation"); } // Check if there is at least one frame per animation type if (!cTextureAni.GetTextureFrames().GetNumOfElements()) { // No texture frames found // Create and add standard texture frame TextureAni::TextureFrame *pTextureFrame = new TextureAni::TextureFrame; pTextureFrame->pTextureHandler = new TextureHandler(); pTextureFrame->pTextureHandler->Load(cTextureAni.GetTextureManager(), TextureManager::Default); cTextureAni.GetTextureFrames().Add(pTextureFrame); } if (!cTextureAni.GetMatrixFrames().GetNumOfElements()) { // No matrix frames found // Create and add standard matrix frame TextureAni::MatrixFrame *pMatrixFrame = new TextureAni::MatrixFrame; pMatrixFrame->vScale = Vector3::One; cTextureAni.GetMatrixFrames().Add(pMatrixFrame); } if (!cTextureAni.GetColorFrames().GetNumOfElements()) { // No color frames found // Create and add standard color frame TextureAni::ColorFrame *pColorFrame = new TextureAni::ColorFrame; pColorFrame->vColor = 1.0f; cTextureAni.GetColorFrames().Add(pColorFrame); } // Create standard animations (if there aren't created until now) cTextureAni.CreateStandardTextureAnimation(); cTextureAni.CreateStandardMatrixAnimation(); cTextureAni.CreateStandardColorAnimation(); // Done return true; } /** * @brief * Adds an animation information manager to the given XML element */ void TextureAniLoaderPL::AddAniInfoManager(XmlElement &cElement, const AniInfoManager &cAniInfoManager, const String &sType) const { // Loop through all animation information for (uint32 i=0; i<cAniInfoManager.GetNumOfElements(); i++) { // Get animation information const AniInfo *pAnimation = cAniInfoManager.GetByIndex(i); if (pAnimation) { XmlElement *pAnimationElement = new XmlElement("Animation"); // Type pAnimationElement->SetAttribute("Type", sType); // Name if (pAnimation->GetName().GetLength()) pAnimationElement->SetAttribute("Name", pAnimation->GetName()); // Start if (pAnimation->GetStartFrame() != 0) pAnimationElement->SetAttribute("Start", pAnimation->GetStartFrame()); // End if (pAnimation->GetEndFrame() != 0) pAnimationElement->SetAttribute("End", pAnimation->GetEndFrame()); // Speed if (pAnimation->GetSpeed() != 24.0f) pAnimationElement->SetAttribute("Speed", String(pAnimation->GetSpeed())); // Loop if (pAnimation->GetFlags() & AnimationInfo::Loop) pAnimationElement->SetAttribute("Loop", "1"); // PingPong if (pAnimation->GetFlags() & AnimationInfo::PingPong) pAnimationElement->SetAttribute("PingPong", "1"); // Add frame information uint32 nNumOfFrames = pAnimation->GetNumOfFrames(); for (uint32 nFrameID=0; nFrameID<nNumOfFrames; nFrameID++) { // Get frame information const AnimationFrameInfo *pFrameInfo = pAnimation->GetFrameInfo(nFrameID); // Add? if (pFrameInfo && pFrameInfo->GetSpeed() != 1.0f) { XmlElement *pFrameInfoElement = new XmlElement("Frame"); // ID pAnimationElement->SetAttribute("ID", nFrameID); // Speed pAnimationElement->SetAttribute("Speed", String(pFrameInfo->GetSpeed())); // Link frame information element pAnimationElement->LinkEndChild(*pFrameInfoElement); } } // Add events const AnimationEventManager &cEventManager = pAnimation->GetEventManager(); for (uint32 nEvent=0; nEvent<cEventManager.GetNumOfElements(); nEvent++) { // Get the event const AnimationEvent *pEvent = cEventManager.GetByIndex(nEvent); if (pEvent) { XmlElement *pEventElement = new XmlElement("Event"); // FrameID pEventElement->SetAttribute("FrameID", pEvent->GetFrame()); // ID pEventElement->SetAttribute("ID", pEvent->GetID()); // Link event element pAnimationElement->LinkEndChild(*pEventElement); } } // Link animation element cElement.LinkEndChild(*pAnimationElement); } } } //[-------------------------------------------------------] //[ Namespace ] //[-------------------------------------------------------] } // PLRenderer
33.488255
130
0.66346
ktotheoz
72a77e4b706945954b782607100be05740d3aa8e
553
cpp
C++
src/world/particles/systems/blueorbparticlesystem.cpp
Eae02/tank-game
0c526b177ccc15dd49e3228489163f13335040db
[ "Zlib" ]
null
null
null
src/world/particles/systems/blueorbparticlesystem.cpp
Eae02/tank-game
0c526b177ccc15dd49e3228489163f13335040db
[ "Zlib" ]
null
null
null
src/world/particles/systems/blueorbparticlesystem.cpp
Eae02/tank-game
0c526b177ccc15dd49e3228489163f13335040db
[ "Zlib" ]
null
null
null
#include "blueorbparticlesystem.h" namespace TankGame { BlueOrbParticleSystem::BlueOrbParticleSystem(ParticlesManager& particlesManager) : m_blueOrbEmitter(particlesManager) { } ParticleEmitter* BlueOrbParticleSystem::GetEmitter(size_t n) { return &m_blueOrbEmitter; } size_t BlueOrbParticleSystem::GetEmitterCount() const { return 1; } void BlueOrbParticleSystem::SetTransformationProvider(const ITransformationProvider* transformationProvider) { m_blueOrbEmitter.SetTransformationProvider(transformationProvider); } }
21.269231
109
0.802893
Eae02
72a80d75b454af16c09b505bb52363c2106d8d5f
7,635
cc
C++
source/graphics/rasterize.cc
dolfly/plotfx
6381339d6ea89cf54f47948889ce9d86e178d851
[ "BSD-3-Clause" ]
null
null
null
source/graphics/rasterize.cc
dolfly/plotfx
6381339d6ea89cf54f47948889ce9d86e178d851
[ "BSD-3-Clause" ]
null
null
null
source/graphics/rasterize.cc
dolfly/plotfx
6381339d6ea89cf54f47948889ce9d86e178d851
[ "BSD-3-Clause" ]
null
null
null
/** * This file is part of the "plotfx" project * Copyright (c) 2018 Paul Asmuth * * 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 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. */ #include <iostream> #include <graphics/rasterize.h> #include <graphics/image.h> #include <graphics/text_layout.h> namespace plotfx { Rasterizer::Rasterizer( uint32_t width_, uint32_t height_, double dpi_, std::shared_ptr<text::TextShaper> text_shaper_) : width(width_), height(height_), dpi(dpi_), text_shaper(text_shaper_), ft_ready(false) { if (!FT_Init_FreeType(&ft)) { ft_ready = true; } cr_surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height); cr_ctx = cairo_create(cr_surface); } Rasterizer::~Rasterizer() { if (ft_ready) { FT_Done_FreeType(ft); } cairo_destroy(cr_ctx); cairo_surface_destroy(cr_surface); } Status Rasterizer::fillPath(const layer_ops::BrushFillOp& op) { const auto& clip = op.clip; const auto& path = op.path; const auto& style = op.style; if (path.size() < 2) { return ERROR; } cairo_set_source_rgba( cr_ctx, style.color.red(), style.color.green(), style.color.blue(), style.color.alpha()); cairo_rectangle(cr_ctx, clip.x, clip.y, clip.w, clip.h); cairo_clip(cr_ctx); cairo_new_path(cr_ctx); for (const auto& cmd : path) { switch (cmd.command) { case PathCommand::MOVE_TO: cairo_move_to(cr_ctx, cmd[0], cmd[1]); break; case PathCommand::LINE_TO: cairo_line_to(cr_ctx, cmd[0], cmd[1]); break; case PathCommand::ARC_TO: cairo_arc(cr_ctx, cmd[0], cmd[1], cmd[2], cmd[3], cmd[4]); break; default: break; // not yet implemented } } cairo_fill(cr_ctx); return OK; } Status Rasterizer::strokePath(const layer_ops::BrushStrokeOp& op) { const auto& clip = op.clip; const auto& path = op.path; const auto& style = op.style; if (path.size() < 2) { return ERROR; } cairo_set_source_rgba( cr_ctx, style.color.red(), style.color.green(), style.color.blue(), style.color.alpha()); cairo_set_line_width(cr_ctx, style.line_width); cairo_rectangle(cr_ctx, clip.x, clip.y, clip.w, clip.h); cairo_clip(cr_ctx); cairo_new_path(cr_ctx); for (const auto& cmd : path) { switch (cmd.command) { case PathCommand::MOVE_TO: cairo_move_to(cr_ctx, cmd[0], cmd[1]); break; case PathCommand::LINE_TO: cairo_line_to(cr_ctx, cmd[0], cmd[1]); break; case PathCommand::ARC_TO: cairo_arc(cr_ctx, cmd[0], cmd[1], cmd[2], cmd[3], cmd[4]); break; default: break; // not yet implemented } } cairo_stroke(cr_ctx); return OK; } Status Rasterizer::drawText(const layer_ops::TextSpanOp& op) { std::vector<text::GlyphPlacement> glyphs; auto rc = text::layoutText( op.text, op.position.x, op.position.y, op.style.font, op.style.font_size, 96, // FIXME op.style.direction, text_shaper.get(), [&glyphs] (const text::GlyphPlacement& g) { glyphs.emplace_back(g); }); if (rc != OK) { return rc; } return drawTextGlyphs( glyphs.data(), glyphs.size(), op.style); } Status Rasterizer::drawTextGlyphs( const text::GlyphPlacement* glyphs, size_t glyph_count, const TextStyle& style) { if (!ft_ready) { return ERROR; } // FIXME cache FT_Face ft_font; if (FT_New_Face(ft, style.font.font_file.c_str(), 0, &ft_font)) { return ERROR; } auto font_size_ft = style.font_size * (72.0 / dpi) * 64; if (FT_Set_Char_Size(ft_font, 0, font_size_ft, dpi, dpi)) { FT_Done_Face(ft_font); return ERROR; } cairo_set_source_rgba( cr_ctx, style.color.red(), style.color.green(), style.color.blue(), style.color.alpha()); auto cairo_face = cairo_ft_font_face_create_for_ft_face(ft_font, 0); cairo_set_font_face(cr_ctx, cairo_face); cairo_set_font_size(cr_ctx, style.font_size); auto cairo_glyphs = cairo_glyph_allocate(glyph_count); for (int i = 0; i < glyph_count; ++i) { const auto& g = glyphs[i]; //FT_Load_Glyph(ft_font, g.codepoint, FT_LOAD_DEFAULT); cairo_glyphs[i].index = g.codepoint; cairo_glyphs[i].x = g.x; cairo_glyphs[i].y = g.y; //// render with freetype // FT_Render_Glyph(ft_font->glyph, FT_RENDER_MODE_NORMAL); // const auto& ft_bitmap = ft_font->glyph->bitmap; // for (uint32_t y = 0; y < ft_bitmap.rows; ++y) { // for (uint32_t x = 0; x < ft_bitmap.width; ++x) { // auto v = 1.0 - (ft_bitmap.buffer[y * ft_bitmap.width + x] / 255.0); // auto ox = x + g.x + ft_font->glyph->bitmap_left; // auto oy = y + g.y - ft_font->glyph->bitmap_top; // if (ox >= pixmap->getWidth() || oy >= pixmap->getHeight()) { // continue; // } // pixmap->setPixel(ox, oy, Color::fromRGBA(v, v, v, 1)); // } // } } cairo_show_glyphs(cr_ctx, cairo_glyphs, glyph_count); cairo_glyph_free(cairo_glyphs); cairo_font_face_destroy(cairo_face); FT_Done_Face(ft_font); return OK; } void Rasterizer::clear(const Color& c) { cairo_set_source_rgba( cr_ctx, c.red(), c.green(), c.blue(), c.alpha()); cairo_paint(cr_ctx); } const unsigned char* Rasterizer::data() const { return cairo_image_surface_get_data(cr_surface); } size_t Rasterizer::size() const { return width * height * 4; } cairo_status_t cr_copy( void* closure, const unsigned char* data, unsigned int length) { *static_cast<std::string*>(closure) += std::string((const char*) data, length); return CAIRO_STATUS_SUCCESS; } std::string Rasterizer::to_png() const { std::string buf; cairo_surface_write_to_png_stream(cr_surface, cr_copy, &buf); return buf; } Status Rasterizer::writeToFile(const std::string& path) { if (StringUtil::endsWith(path, ".png")) { auto rc = cairo_surface_write_to_png(cr_surface, path.c_str()); if (rc == CAIRO_STATUS_SUCCESS) { return OK; } else { return ERROR; } } return ERROR; } } // namespace plotfx
26.695804
81
0.658546
dolfly
72a9ebb06e37ccf9dca67a53cab90886c7b724f0
34,270
cpp
C++
src/rrgenerator.cpp
sischkg/nxnsattack
c20896e40187bbcacb5c0255ff8f3cc7d0592126
[ "MIT" ]
5
2020-05-22T10:01:51.000Z
2022-01-01T04:45:14.000Z
src/rrgenerator.cpp
sischkg/dns-fuzz-server
6f45079014e745537c2f564fdad069974e727da1
[ "MIT" ]
1
2020-06-07T14:09:44.000Z
2020-06-07T14:09:44.000Z
src/rrgenerator.cpp
sischkg/dns-fuzz-server
6f45079014e745537c2f564fdad069974e727da1
[ "MIT" ]
2
2020-03-10T03:06:20.000Z
2021-07-25T15:07:45.000Z
#include "rrgenerator.hpp" #include <boost/noncopyable.hpp> #include <sys/types.h> #include <unistd.h> #include <cstdlib> #include <sstream> namespace dns { /********************************************************** * RandomGenarator **********************************************************/ RandomGenerator *RandomGenerator::mInstance = nullptr; RandomGenerator::RandomGenerator() : mGenerator( static_cast<unsigned long>(time(nullptr)) ) { std::srand( getpid() * time( nullptr ) ); } uint32_t RandomGenerator::rand( uint32_t base ) { if ( base == 0 ) return 0; boost::mutex::scoped_lock lock( mMutex ); boost::uniform_smallint<> dst( 0, base); uint32_t v = dst( mGenerator ); return v; } PacketData RandomGenerator::randStream( unsigned int size ) { PacketData stream; stream.reserve( size ); for ( unsigned int i = 0 ; i < size ; i++ ) stream.push_back( this->rand( 0xff ) ); return stream; } PacketData RandomGenerator::randSizeStream( unsigned int max_size ) { unsigned int size = rand( max_size ); PacketData stream; stream.reserve( size ); for ( unsigned int i = 0 ; i < size ; i++ ) stream.push_back( this->rand( 0xff ) ); return stream; } RandomGenerator *RandomGenerator::getInstance() { if ( mInstance == nullptr ) mInstance = new RandomGenerator(); return mInstance; } /********************************************************** * DomainnameGenarator **********************************************************/ std::string DomainnameGenerator::generateLabel() { std::string label; if ( getRandom( 37 ) == 0 ) return "*"; unsigned int label_size = 1 + getRandom( 62 ); label.reserve( label_size ); for ( unsigned int i = 0 ; i < label_size ; i++ ) label.push_back( getRandom( 0xff ) ); return label; } Domainname DomainnameGenerator::generate() { unsigned int label_count = 1 + getRandom( 100 ); unsigned int domainname_size = 0; std::deque<std::string> labels; for ( unsigned int i = 0 ; i < label_count ; i++ ) { auto label = generateLabel(); if ( domainname_size + label.size() + 1 >= 255 ) break; labels.push_back( label ); domainname_size += ( label.size() + 1 ); } return Domainname( labels ); } Domainname DomainnameGenerator::generate( const Domainname &hint1, const Domainname &hint2 ) { Domainname hint = hint1; Domainname result = hint1; if ( hint2 != "" && getRandom( 2 ) == 0 ) { hint = hint2; result = hint2; } switch ( getRandom( 3 ) ) { case 0: return result; case 1: // erase labels; { unsigned int erased_label_count = getRandom( hint.getLabels().size() ); for ( unsigned int i = 0 ; i < erased_label_count ; i++ ) { result.popSubdomain(); } return result; } case 2: // append labels as subdomain; { unsigned int label_count = hint.getLabels().size(); unsigned int append_label_count = getRandom( 255 - hint.getLabels().size() ); unsigned int domainname_size = hint.size(); for ( unsigned int i = 0 ; i < append_label_count ; i++ ) { std::string new_label = generateLabel(); if ( label_count + 1 >= 128 || domainname_size + new_label.size() + 1 >= 255 ) break; result.addSubdomain( new_label ); domainname_size += ( new_label.size() + 1 ); label_count++; } return result; } case 3: // replace labels; { unsigned int erased_label_count = getRandom( hint.getLabels().size() ); for ( unsigned int i = 0 ; i < erased_label_count ; i++ ) { result.popSubdomain(); } unsigned int label_count = result.getLabels().size(); unsigned int append_label_count = getRandom( 255 - result.getLabels().size() ); unsigned int domainname_size = result.size(); for ( unsigned int i = 0 ; i < append_label_count ; i++ ) { std::string new_label = generateLabel(); if ( label_count + 1 >= 128 || domainname_size + new_label.size() + 1 >= 255 ) break; result.addSubdomain( new_label ); domainname_size += ( new_label.size() + 1 ); label_count++; } return result; } default: throw std::logic_error( "generate domainname error" ); } } static Domainname generateDomainname( const Domainname &hint1, const Domainname &hint2 = Domainname() ) { DomainnameGenerator g; return g.generate( hint1, hint2 ); } Domainname generateDomainname() { DomainnameGenerator g; return g.generate(); } Domainname getDomainname( const MessageInfo &hint ) { std::vector<Domainname> names; for ( auto rr : hint.getQuestionSection() ) { names.push_back( rr.mDomainname ); } for ( auto rr : hint.getAnswerSection() ) { names.push_back( rr.mDomainname ); } for ( auto rr : hint.getAuthoritySection() ) { names.push_back( rr.mDomainname ); } for ( auto rr : hint.getAdditionalSection() ) { names.push_back( rr.mDomainname ); } unsigned int index = getRandom( names.size() - 1 ); return names.at( index ); } Domainname generateAlgorithmName() { if ( withChance( 0.7 ) ) { const char *algorithms[] = { "gss-tsig", "HMAC-MD5.SIG-ALG.REG.INT", "hmac-sha1", "hmac-sha224", "hmac-sha256", "hmac-sha384", "hmac-sha512", }; return (Domainname)algorithms[ getRandom( sizeof(algorithms)/sizeof(char *) - 1 ) ]; } else { return generateDomainname(); } } /********************************************************** * XNAMEGenarator **********************************************************/ template<class T> std::shared_ptr<RDATA> XNameGenerator<T>::generate( const MessageInfo &hint, const Domainname &hint2 ) { Domainname hint_name; uint32_t qdcount = hint.getQuestionSection().size(); uint32_t ancount = hint.getAnswerSection().size(); uint32_t nscount = hint.getAuthoritySection().size(); uint32_t adcount = hint.getAdditionalSection().size(); uint32_t index = getRandom( qdcount + ancount + nscount + adcount - 1 ); if ( index < qdcount ) { hint_name = hint.getQuestionSection().at( index ).mDomainname; } else if ( index < qdcount + ancount ) { hint_name = hint.getAnswerSection().at( index - qdcount ).mDomainname; } else if ( index < qdcount + ancount + nscount ) { hint_name = hint.getAuthoritySection().at( index - qdcount - ancount ).mDomainname; } else if ( index < qdcount + ancount + nscount + adcount ) { hint_name = hint.getAdditionalSection().at( index - qdcount - ancount - nscount ).mDomainname; } else { throw std::logic_error( "invalid index of XNameGenerator::generate( hint )" ); } return std::shared_ptr<RDATA>( new T( DomainnameGenerator().generate( hint_name, hint2 ) ) ); } template<class T> std::shared_ptr<RDATA> XNameGenerator<T>::generate() { return std::shared_ptr<RDATA>( new T( DomainnameGenerator().generate() ) ); } /********************************************************** * RAWGenarator **********************************************************/ std::shared_ptr<RDATA> RawGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { return generate(); } std::shared_ptr<RDATA> RawGenerator::generate() { return std::shared_ptr<RDATA>( new RecordRaw( getRandom( 0x3ff ), getRandomSizeStream( 0xff ) ) ); } /********************************************************** * AGenarator **********************************************************/ std::shared_ptr<RDATA> AGenerator::generate( const MessageInfo &hint, const Domainname &hint2 ) { std::vector<std::shared_ptr<RDATA> > record_a_list; for ( auto rr : hint.getAnswerSection() ) { if ( rr.mType == TYPE_A ) { record_a_list.push_back( rr.mRData ); } } for ( auto rr : hint.getAuthoritySection() ) { if ( rr.mType == TYPE_A ) { record_a_list.push_back( rr.mRData ); } } for ( auto rr : hint.getAdditionalSection() ) { if ( rr.mType == TYPE_A ) { record_a_list.push_back( rr.mRData ); } } if ( record_a_list.size() == 0 ) return generate(); unsigned int index = getRandom( record_a_list.size() - 1 ); return std::shared_ptr<RDATA>( record_a_list.at( index )->clone() ); } std::shared_ptr<RDATA> AGenerator::generate() { return std::shared_ptr<RDATA>( new RecordA( getRandom() ) ); } /********************************************************** * WKSGenarator **********************************************************/ std::shared_ptr<RDATA> WKSGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { return generate(); } std::shared_ptr<RDATA> WKSGenerator::generate() { std::vector<Type> bitmap; if ( getRandom( 32 ) == 0 ) bitmap.resize( 0 ); else if ( getRandom( 32 ) == 0 ) { bitmap.resize( 256 * 256 ); for ( unsigned int i = 0 ; i < bitmap.size() ; i++ ) bitmap[i] = i; } else { bitmap.resize( getRandom( 0xffff ) ); for ( unsigned int i = 0 ; i < bitmap.size() ; i++ ) bitmap[i] = getRandom( 0xffff); } return std::shared_ptr<RDATA>( new RecordWKS( getRandom(), getRandom( 255 ), bitmap ) ); } /********************************************************** * AAAAGenarator **********************************************************/ std::shared_ptr<RDATA> AAAAGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { std::vector<std::shared_ptr<RDATA> > record_a_list; for ( auto rr : hint1.getAnswerSection() ) { if ( rr.mType == TYPE_AAAA ) { record_a_list.push_back( rr.mRData ); } } for ( auto rr : hint1.getAuthoritySection() ) { if ( rr.mType == TYPE_AAAA ) { record_a_list.push_back( rr.mRData ); } } for ( auto rr : hint1.getAdditionalSection() ) { if ( rr.mType == TYPE_AAAA ) { record_a_list.push_back( rr.mRData ); } } if ( record_a_list.size() == 0 ) return generate(); unsigned int index = getRandom( record_a_list.size() - 1 ); return std::shared_ptr<RDATA>( record_a_list.at( index )->clone() ); } std::shared_ptr<RDATA> AAAAGenerator::generate() { PacketData sin_addr = getRandomStream( 16 ); return std::shared_ptr<RDATA>( new RecordAAAA( &sin_addr[0] ) ); } /********************************************************** * SOAGenarator **********************************************************/ std::shared_ptr<RDATA> SOAGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { return std::shared_ptr<RDATA>( new RecordSOA( getDomainname( hint1 ), getDomainname( hint1 ), getRandom(), getRandom(), getRandom(), getRandom(), getRandom() ) ); } std::shared_ptr<RDATA> SOAGenerator::generate() { return std::shared_ptr<RDATA>( new RecordSOA( generateDomainname(), generateDomainname(), getRandom(), getRandom(), getRandom(), getRandom(), getRandom() )); } /********************************************************** * SRVGenarator **********************************************************/ std::shared_ptr<RDATA> SRVGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { return std::shared_ptr<RDATA>( new RecordSRV( getRandom( 0xffff ), getRandom( 0xffff ), getRandom( 0xffff ), getDomainname( hint1 ) ) ); } std::shared_ptr<RDATA> SRVGenerator::generate() { return std::shared_ptr<RDATA>( new RecordSRV( getRandom( 0xffff ), getRandom( 0xffff ), getRandom( 0xffff ), generateDomainname() ) ); } /********************************************************** * RRSIGGenarator **********************************************************/ std::shared_ptr<RDATA> RRSIGGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { PacketData signature = getRandomSizeStream( 0xff ); std::shared_ptr<RDATA> p( new RecordRRSIG( getRandom( 0xffff ), // type covered getRandom( 0xff ), // algorithm getRandom( 0xff ), // label getRandom(), // original ttl getRandom(), // expiration getRandom(), // inception getRandom( 0xffff ), // key tag generateDomainname( getDomainname( hint1 ), hint2 ), signature ) ); return p; } std::shared_ptr<RDATA> RRSIGGenerator::generate() { PacketData signature = getRandomSizeStream( 0xff ); return std::shared_ptr<RDATA>( new RecordRRSIG( getRandom( 0xffff ), // type covered getRandom( 0xff ), // algorithm getRandom( 0xff ), // label getRandom(), // original ttl getRandom(), // expiration getRandom(), // inception getRandom( 0xffff ), // key tag generateDomainname(), signature ) ); } /********************************************************** * DNSKEYGenarator **********************************************************/ std::shared_ptr<RDATA> DNSKEYGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { PacketData public_key = getRandomStream( 132 ); return std::shared_ptr<RDATA>( new RecordDNSKEY( getRandom() % 2 ? RecordDNSKEY::KSK : RecordDNSKEY::ZSK, RecordDNSKEY::RSASHA1, public_key ) ); } std::shared_ptr<RDATA> DNSKEYGenerator::generate() { PacketData public_key = getRandomStream( 132 ); return std::shared_ptr<RDATA>( new RecordDNSKEY( getRandom() % 2 ? RecordDNSKEY::KSK : RecordDNSKEY::ZSK, RecordDNSKEY::RSASHA1, public_key ) ); } /********************************************************** * DSGenarator **********************************************************/ std::shared_ptr<RDATA> DSGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { if ( getRandom( 2 ) ) { PacketData hash = getRandomStream( 20 ); return std::shared_ptr<RDATA>( new RecordDS( getRandom( 0xffff ), 5, 1, hash ) ); } else { PacketData hash = getRandomStream( 32 ); return std::shared_ptr<RDATA>( new RecordDS( getRandom( 0xffff ), 5, 2, hash ) ); } } std::shared_ptr<RDATA> DSGenerator::generate() { if ( getRandom( 2 ) ) { PacketData hash = getRandomStream( 40 ); return std::shared_ptr<RDATA>( new RecordDS( getRandom( 0xffff ), 5, 1, hash ) ); } else { PacketData hash = getRandomStream( 64 ); return std::shared_ptr<RDATA>( new RecordDS( getRandom( 0xffff ), 5, 2, hash ) ); } } /********************************************************** * NSECGenarator **********************************************************/ std::shared_ptr<RDATA> NSECGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { std::vector<Type> types; unsigned int type_count = getRandom( 4 ); types.reserve( type_count ); for ( unsigned int i = 0 ; i < type_count ; i++ ) { types.push_back( getRandom( 0xffff ) ); } return std::shared_ptr<RDATA>( new RecordNSEC( generateDomainname( getDomainname( hint1 ), hint2 ), types ) ); } std::shared_ptr<RDATA> NSECGenerator::generate() { std::vector<Type> types; unsigned int type_count = getRandom( 0xffff ); types.reserve( type_count ); for ( unsigned int i = 0 ; i < type_count ; i++ ) { types.push_back( getRandom( 0xffff ) ); } return std::shared_ptr<RDATA>( new RecordNSEC( generateDomainname(), types ) ); } /********************************************************** * NSEC3Genarator **********************************************************/ std::shared_ptr<RDATA> NSEC3Generator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { return generate(); } std::shared_ptr<RDATA> NSEC3Generator::generate() { uint8_t optout = 0x07; if ( getRandom( 8 ) ) { optout = 0; } std::vector<Type> types; unsigned int type_count = getRandom( 4 ); for ( unsigned int i = 0 ; i < type_count ; i++ ) { types.push_back( getRandom( 0xffff ) ); } return std::shared_ptr<RDATA>( new RecordNSEC3( 0x01, optout, getRandom( 0x00ff ), getRandomSizeStream( 0xff ), getRandomStream( 20 ), types ) ); } /********************************************************** * NSEC3PARAMGenarator **********************************************************/ std::shared_ptr<RDATA> NSEC3PARAMGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { return generate(); } std::shared_ptr<RDATA> NSEC3PARAMGenerator::generate() { uint8_t optout = 0x07; if ( getRandom( 8 ) ) { optout = 0; } return std::shared_ptr<RDATA>( new RecordNSEC3PARAM( 0x01, optout, getRandom( 0x00ff ), getRandomSizeStream( 0xff ) ) ); } /********************************************************** * TLSAGenarator **********************************************************/ std::shared_ptr<RDATA> TLSAGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { return generate(); } std::shared_ptr<RDATA> TLSAGenerator::generate() { return std::shared_ptr<RDATA>( new RecordTLSA( getRandom( 0xff ), getRandom( 0xff ), getRandom( 0xff ), getRandomSizeStream( 0x01ff ) ) ); } /********************************************************** * SIGGenarator **********************************************************/ std::shared_ptr<RDATA> SIGGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { PacketData signature = getRandomStream( 256 ); std::shared_ptr<RDATA> p( new RecordSIG( getRandom( 0xffff ), // type covered getRandom( 0xff ), // algorithm getRandom( 0xff ), // label getRandom(), // original ttl getRandom(), // expiration getRandom(), // inception getRandom( 0xffff ), // key tag generateDomainname( getDomainname( hint1 ), hint2 ), signature ) ); return p; } std::shared_ptr<RDATA> SIGGenerator::generate() { PacketData signature = getRandomSizeStream( 256 ); return std::shared_ptr<RDATA>( new RecordSIG( getRandom( 0xffff ), // type covered getRandom( 0xff ), // algorithm getRandom( 0xff ), // label getRandom(), // original ttl getRandom(), // expiration getRandom(), // inception getRandom( 0xffff ), // key tag generateDomainname(), signature ) ); } /********************************************************** * KEYGenarator **********************************************************/ std::shared_ptr<RDATA> KEYGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { PacketData public_key = getRandomStream( 132 ); return std::shared_ptr<RDATA>( new RecordKEY( 0xffff, RecordDNSKEY::RSASHA1, public_key ) ); } std::shared_ptr<RDATA> KEYGenerator::generate() { PacketData public_key = getRandomStream( 132 ); return std::shared_ptr<RDATA>( new RecordKEY( getRandom( 0xffff ), RecordDNSKEY::RSASHA1, public_key ) ); } /********************************************************** * NXTGenarator **********************************************************/ std::shared_ptr<RDATA> NXTGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { std::vector<Type> types; unsigned int type_count = getRandom( 0xffff ); types.reserve( type_count ); for ( unsigned int i = 0 ; i < type_count ; i++ ) { types.push_back( getRandom( 0xffff ) ); } return std::shared_ptr<RDATA>( new RecordNXT( generateDomainname( getDomainname( hint1 ), hint2 ), types ) ); } std::shared_ptr<RDATA> NXTGenerator::generate() { std::vector<Type> types; unsigned int type_count = getRandom( 0xffff ); types.reserve( type_count ); for ( unsigned int i = 0 ; i < type_count ; i++ ) { types.push_back( getRandom( 0xffff ) ); } return std::shared_ptr<RDATA>( new RecordNXT( generateDomainname(), types ) ); } /********************************************************** * TKEYGenarator **********************************************************/ std::shared_ptr<RDATA> TKEYGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { PacketData signature = getRandomSizeStream( 0xff ); PacketData other = getRandomSizeStream( 0xff ); std::shared_ptr<RDATA> p( new RecordTKEY( generateDomainname( getDomainname( hint1 ), hint2 ), // domain generateAlgorithmName(), // algorithm getRandom(), // inception getRandom(), // expiration getRandom( 0xff ), getRandom( 0xff ), signature, other) ); return p; } std::shared_ptr<RDATA> TKEYGenerator::generate() { PacketData signature = getRandomSizeStream( 0xff ); PacketData other = getRandomSizeStream( 0xff ); std::shared_ptr<RDATA> p( new RecordTKEY( generateDomainname(), // domain generateAlgorithmName(), // algorithm getRandom(), // inception getRandom(), // expiration getRandom(), getRandom(), signature ) ); return p; } /********************************************************** * TSIGGenarator **********************************************************/ std::shared_ptr<RDATA> TSIGGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { PacketData signature = getRandomStream( 16 ); uint64_t signed_time = (uint64_t)getRandom() + (((uint64_t)getRandom() ) << 32 ); PacketData other = getRandomSizeStream( 0xff ); return std::shared_ptr<RDATA>( new RecordTSIGData( generateDomainname( getDomainname( hint1 ), hint2 ), // domain generateAlgorithmName(), // algorithm signed_time, // signed time getRandom( 0xffff ), // fudge signature, // mac getRandom( 0xffff ), // original id getRandom( 0xffff ), // error other ) ); } std::shared_ptr<RDATA> TSIGGenerator::generate() { PacketData signature = getRandomStream( 16 ); uint64_t signed_time = (uint64_t)getRandom() + (((uint64_t)getRandom() ) << 32 ); PacketData other = getRandomSizeStream( 0xff ); return std::shared_ptr<RDATA>( new RecordTSIGData( generateDomainname(), // domain generateAlgorithmName(), // algorithm signed_time, // signed time getRandom( 0xffff ), // fudge signature, // mac getRandom( 0xffff ), // original id getRandom( 0xffff ), // error other ) ); } /********************************************************** * ResourceRecordGenarator **********************************************************/ ResourceRecordGenerator::ResourceRecordGenerator() { mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new RawGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new NSGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new CNAMEGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new DNAMEGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new AGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new AAAAGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new WKSGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new SOAGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new SRVGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new RRSIGGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new DNSKEYGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new DSGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new NSECGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new NSEC3Generator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new NSEC3PARAMGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new TLSAGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new SIGGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new KEYGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new NXTGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new TKEYGenerator ) ); mGenerators.push_back( std::shared_ptr<RDATAGeneratable>( new TSIGGenerator ) ); } RRSet ResourceRecordGenerator::generate( const MessageInfo &hint1, const Domainname &hint2 ) { Class class_table[] = { CLASS_IN, CLASS_CH, CLASS_HS, CLASS_NONE, CLASS_ANY }; std::shared_ptr<RDATA> resource_data = mGenerators.at( getRandom( mGenerators.size() - 1 ) )->generate( hint1, hint2 ); Domainname owner; if ( resource_data->type() == TYPE_NSEC3 ) { std::string hash; encodeToBase32Hex( getRandomStream( 20 ), hash ); owner = getDomainname( hint1 ); owner.addSubdomain( hash ); } else { owner = generateDomainname( getDomainname( hint1 ), hint2 ); } unsigned int index = getRandom( sizeof(class_table)/sizeof(Class) - 1 ); if ( index >= sizeof(class_table)/sizeof(Class) ) { throw std::logic_error( "invalid class index" ); } RRSet rrset( owner, class_table[index], resource_data->type(), getRandom( 0xffffffff ) ); rrset.add( resource_data ); return rrset; } std::shared_ptr<OptPseudoRROption> RawOptionGenerator::generate( const MessageInfo &hint ) { return generate(); } std::shared_ptr<OptPseudoRROption> RawOptionGenerator::generate() { return std::shared_ptr<OptPseudoRROption>( new RAWOption( getRandom( 0x0f ), getRandomSizeStream( 0xff ) ) ); } std::shared_ptr<OptPseudoRROption> NSIDGenerator::generate( const MessageInfo &hint ) { return generate(); } std::shared_ptr<OptPseudoRROption> NSIDGenerator::generate() { ssize_t length = getRandom( 0xff ); std::string data; data.reserve( length ); for ( ssize_t i = 0 ; i < length ; i++ ) data.push_back( getRandom( 0xff ) ); return std::shared_ptr<OptPseudoRROption>( new NSIDOption( data ) ); } std::shared_ptr<OptPseudoRROption> ClientSubnetGenerator::generate( const MessageInfo &hint ) { return generate(); } std::shared_ptr<OptPseudoRROption> ClientSubnetGenerator::generate() { if ( getRandom( 2 ) ) { std::ostringstream os; os << getRandom( 0xff ) << "." << getRandom( 0xff ) << "." << getRandom( 0xff ) << getRandom( 0xff ); return std::shared_ptr<OptPseudoRROption>( new ClientSubnetOption( ClientSubnetOption::IPv4, getRandom( 32 ), getRandom( 32 ), os.str() ) ); } else { std::ostringstream os; os << std::hex << getRandom( 0xff ); for ( int i = 0 ; i < 15 ; i++ ) os << ":" << getRandom( 0xff ); return std::shared_ptr<OptPseudoRROption>( new ClientSubnetOption( ClientSubnetOption::IPv6, getRandom( 128 ), getRandom( 128 ), os.str() ) ); } } std::shared_ptr<OptPseudoRROption> CookieGenerator::generate( const MessageInfo &hint ) { return generate(); } std::shared_ptr<OptPseudoRROption> CookieGenerator::generate() { PacketData client, server; unsigned int client_length = getRandom( 64 ); unsigned int server_length = getRandom( 64 ); client.reserve( client_length ); server.reserve( server_length ); for ( unsigned int i = 0 ; i < client_length ; i++ ) client.push_back( getRandom( 0xff ) ); for ( unsigned int i = 0 ; i < server_length ; i++ ) server.push_back( getRandom( 0xff ) ); return std::shared_ptr<OptPseudoRROption>( new CookieOption( client, server ) ); } std::shared_ptr<OptPseudoRROption> TCPKeepaliveGenerator::generate( const MessageInfo &hint ) { return generate(); } std::shared_ptr<OptPseudoRROption> TCPKeepaliveGenerator::generate() { uint16_t timeout = 0; if ( getRandom( 4 ) ) { timeout = getRandom( 0xffff ); } return std::shared_ptr<OptPseudoRROption>( new TCPKeepaliveOption( timeout ) ); } std::shared_ptr<OptPseudoRROption> KeyTagGenerator::generate( const MessageInfo &hint ) { return generate(); } std::shared_ptr<OptPseudoRROption> KeyTagGenerator::generate() { uint16_t count = getRandom( 0x0fff ); std::vector<uint16_t> tags; tags.reserve( count ); for ( uint16_t i = 0 ; i < count ; i++ ) tags.push_back( getRandom( 0xffff ) ); return std::shared_ptr<OptPseudoRROption>( new KeyTagOption( tags ) ); } /********************************************************** * OptionGenarator **********************************************************/ OptionGenerator::OptionGenerator() { mGenerators.push_back( std::shared_ptr<OptGeneratable>( new RawOptionGenerator ) ); mGenerators.push_back( std::shared_ptr<OptGeneratable>( new NSIDGenerator ) ); mGenerators.push_back( std::shared_ptr<OptGeneratable>( new ClientSubnetGenerator ) ); mGenerators.push_back( std::shared_ptr<OptGeneratable>( new CookieGenerator ) ); mGenerators.push_back( std::shared_ptr<OptGeneratable>( new TCPKeepaliveGenerator ) ); mGenerators.push_back( std::shared_ptr<OptGeneratable>( new KeyTagGenerator ) ); } void OptionGenerator::generate( MessageInfo &packet ) { if ( ! packet.isEDNS0() ) return; std::shared_ptr<OptPseudoRROption> option = mGenerators.at( getRandom( mGenerators.size() - 1 ) )->generate( packet ); packet.addOption( option ); } }
37.008639
127
0.512372
sischkg
72ac70593f700c0cf38306c73c6e47e13ac1470c
11,061
cpp
C++
src/filter.cpp
acejarvis/realtime-sdr
2eaa8fdcbf66b2f8057e382847f8be4050cb740a
[ "MIT" ]
null
null
null
src/filter.cpp
acejarvis/realtime-sdr
2eaa8fdcbf66b2f8057e382847f8be4050cb740a
[ "MIT" ]
null
null
null
src/filter.cpp
acejarvis/realtime-sdr
2eaa8fdcbf66b2f8057e382847f8be4050cb740a
[ "MIT" ]
null
null
null
/* Comp Eng 3DY4 (Computer Systems Integration Project) Department of Electrical and Computer Engineering McMaster University Ontario, Canada */ #include "dy4.h" #include "filter.h" #include <iostream> #include <fstream> #include <vector> #include <iomanip> #include <complex> #include <cmath> #include <chrono> // function to compute the impulse response "h" for a Low-pass filter void impulseResponseLPF(float Fs, float Fc, unsigned short int num_taps, std::vector<float> &h) { // bring your own functionality // allocate memory for the impulse response h.resize(num_taps, 0.0); float norm_cutoff = Fc / Fs * 2; for (auto i = 0; i < num_taps; i++) { if (i == (num_taps - 1) / 2) { h[i] = norm_cutoff; } else { h[i] = norm_cutoff * std::sin(PI * norm_cutoff * (i - (num_taps - 1) / 2)) / (PI * norm_cutoff * (i - (num_taps - 1) / 2)); } h[i] *= pow(std::sin(i * PI / num_taps), 2.0); } } // function to compute the impulse response "h" for a Band-pass filter void impulseResponseBPF(float Fs, float Fe, float Fb, unsigned short int num_taps, std::vector<float> &h) { // bring your own functionality // allocate memory for the impulse response h.resize(num_taps, 0.0); float norm_center = ((Fe + Fb) / 2) / (Fs / 2); float norm_pass = (Fe - Fb) / (Fs / 2); for (auto i = 0; i < num_taps; i++) { if (i == (num_taps - 1) / 2) { h[i] = norm_pass; } else { h[i] = norm_pass * std::sin(PI * (norm_pass / 2) * (i - (num_taps - 1) / 2)) / (PI * (norm_pass / 2) * (i - (num_taps - 1) / 2)); } h[i] *= std::cos(i * PI * norm_center); h[i] *= pow(std::sin(i * PI / num_taps), 2.0); } } // function to compute the impulse response "h" for a Root-raised Cosine filter void impulseResponseRRC(float Fs, unsigned short int num_taps, std::vector<float> &h) { float T_symbol = 1 / 2375.0; float beta = 0.90; h.resize(num_taps, 0.0); for (auto i = 0; i < num_taps; i++) { float t = (i - num_taps / 2) / Fs; if (t == 0.0) { h[i] = 1.0 + beta * (4 / PI - 1); } else if (t == -T_symbol / (4 * beta) || t == T_symbol / (4 * beta)) { h[i] = (beta / sqrt(2)) * (((1 + 2 / PI) * (std::sin(PI / (4 * beta)))) + ((1 - 2 / PI) * (std::cos(PI / (4 * beta))))); } else { h[i] = (std::sin(PI * t * (1 - beta) / T_symbol) + 4 * beta * (t / T_symbol) * std::cos(PI * t * (1 + beta) / T_symbol)) / (PI * t * (1 - (4 * beta * t / T_symbol) * (4 * beta * t / T_symbol)) / T_symbol); } } } // function to process FM Demodulation without arctan function (computational friendly) void fmDemodNoArctan(const std::vector<float> &I, const std::vector<float> &Q, std::vector<float> &prev_IQ, std::vector<float> &fm_demod) { fm_demod.resize(I.size(), 0.0); std::vector<float> sI, sQ; sI.resize(I.size(), 0.0); sQ.resize(I.size(), 0.0); for (auto i = 0; i < sI.size(); i++) { sI[i] = I[i] * I[i]; sQ[i] = Q[i] * Q[i]; } std::vector<float> Inew, Qnew; Inew.resize(I.size() + 1, 0.0); Qnew.resize(Q.size() + 1, 0.0); for (auto j = 0; j < Inew.size(); j++) { if (j == 0) { Inew[j] = prev_IQ[0]; Qnew[j] = prev_IQ[1]; } else { Inew[j] = I[j - 1]; Qnew[j] = Q[j - 1]; } } float current_phase; for (auto k = 0; k < Inew.size() - 1; k++) { if (sI[k] + sQ[k] == 0) { current_phase = 0; } else { current_phase = (Inew[k + 1] * (Qnew[k + 1] - Qnew[k]) - Qnew[k + 1] * (Inew[k + 1] - Inew[k])) / (sI[k] + sQ[k]); } fm_demod[k] = current_phase; //store previous I,Q for block processing prev_IQ[0] = Inew[k + 1]; prev_IQ[1] = Qnew[k + 1]; } } // function to filter signal with upsampling and downsampling void upDownConvolveFIR(std::vector<float> &y, const std::vector<float> &x, const std::vector<float> &h, std::vector<float> &temp, int up_decim, int down_decim) { // bring your own functionality // allocate memory for the output (filtered) data y.resize(x.size() / down_decim, 0.0); int N_taps = h.size(); std::vector<int> phase; if (up_decim == 24) phase = {23, 18, 13, 8, 3, 22, 17, 12, 7, 2, 21, 16, 11, 6, 1, 20, 15, 10, 5, 0, 19, 14, 9, 4}; else phase = {18, 14, 10, 6, 2, 17, 13, 9, 5, 1, 16, 12, 8, 4, 0, 15, 11, 7, 3}; while (true) { //k is used to write elements into the array int k = 0; //to locate the beginning of the array for each data int l_base = 0; int m = 0; int count = 0; // phase array for the first j to be calculated for (auto i = 0; i < x.size(); i += down_decim) { int l = (up_decim == 24) ? 6 : 12; // temp offset for (auto j = phase[(i / down_decim) % up_decim]; j < N_taps; j += 24) { if (l_base + l < N_taps - 1) { y[i / down_decim] = y[i / down_decim] + temp[l_base + l] * h[N_taps - j - 1]; l += 24; } else { if ((i + j - N_taps + 1) % up_decim == 0 && (i + j - N_taps + 1) != 0) { y[i / down_decim] = y[i / down_decim] + x[i + j + 1 - N_taps] * h[N_taps - j - 1]; } } } y[i / down_decim] *= up_decim; //the beginning of the array needs to increase after finish a y data l_base = l_base + down_decim; if (x.size() - count < N_taps) { temp[k] = x[count]; k++; } m = i; count++; } if (m == x.size() - down_decim) { break; } } } // function to filter signal with downsampling only void downConvolveFIR(std::vector<float> &y, const std::vector<float> &x, const std::vector<float> &h, std::vector<float> &temp, int decim) { // bring your own functionality // allocate memory for the output (filtered) data y.resize(x.size() / decim, 0.0); int N_taps = h.size(); while (true) { //k is used to write elements into the array int k = 0; //to locate the beginning of the array for each data int l_base = 0; int m = 0; int count = 0; for (auto i = 0; i < x.size(); i += decim) { int l = 0; for (auto j = 0; j < N_taps; j++) { if (l_base + l < N_taps - 1) { y[i / decim] = y[i / decim] + temp[l_base + l] * h[N_taps - j - 1]; l++; } else { y[i / decim] = y[i / decim] + x[i + j + 1 - N_taps] * h[N_taps - j - 1]; } } //the beginning of the array needs to increase after finish a y data l_base = l_base + decim; if ((x.size() - count) < N_taps) { temp[k] = x[count]; k++; } m = i; count++; } if (m == x.size() - decim) { break; } } } // function for phase-locked loop with mixed output void fmPLL(std::vector<float> &pllIn, std::vector<float> &ncoOut, float freq, float Fs, float &integrator, float &phaseEst, float &feedbackI, float &feedbackQ, float &nco_buf, int &trigOffset, float ncoScale = 1.0, float phaseAdjust = 0.0, float normBandwidth = 0.01) { //scale factors for proportional/integrator terms //these scale factors were derived assuming the following: //damping factor of 0.707 (1 over square root of 2) //there is no oscillator gain and no phase detector gain float Cp = 2.666; float Ci = 3.555; //gain for the proportional term float Kp = (normBandwidth)*Cp; //gain for the integrator term float Ki = (normBandwidth * normBandwidth) * Ci; ncoOut.resize(pllIn.size() + 1, 0.0); ncoOut[0] = nco_buf; float errorI, errorQ, errorD, triArg; for (auto i = 0; i < pllIn.size(); i++) { //phase detector errorI = pllIn[i] * feedbackI; // complex conjugate of the errorQ = pllIn[i] * (-1) * feedbackQ; //feedback complex exponential errorD = std::atan2(errorQ, errorI); //loop filter integrator += Ki * errorD; //update phase estimate phaseEst += (Kp * errorD) + integrator; //internal oscillator triArg = 2 * PI * (freq / Fs) * (trigOffset + i + 1) + phaseEst; feedbackI = std::cos(triArg); feedbackQ = std::sin(triArg); ncoOut[i + 1] = std::cos(triArg * ncoScale + phaseAdjust); } trigOffset += pllIn.size(); nco_buf = ncoOut[-1]; ncoOut.pop_back(); } // function for phase-locked loop with I/Q output void fmPLL(std::vector<float> &pllIn, std::vector<float> &ncoOut_i, std::vector<float> &ncoOut_q, float freq, float Fs, float &integrator, float &phaseEst, float &feedbackI, float &feedbackQ, float &nco_buf_i, float &nco_buf_q, int &trigOffset, float ncoScale = 1.0, float phaseAdjust = 0.0, float normBandwidth = 0.01) { float Cp = 2.666; float Ci = 3.555; //gain for the proportional term float Kp = (normBandwidth)*Cp; //gain for the integrator term float Ki = (normBandwidth * normBandwidth) * Ci; ncoOut_i.resize(pllIn.size() + 1, 0.0); ncoOut_q.resize(pllIn.size() + 1, 0.0); ncoOut_i[0] = nco_buf_i; ncoOut_q[0] = nco_buf_q; float errorI, errorQ, errorD, triArg; for (auto i = 0; i < pllIn.size(); i++) { //phase detector errorI = pllIn[i] * feedbackI; // complex conjugate of the errorQ = pllIn[i] * (-1) * feedbackQ; //feedback complex exponential errorD = std::atan2(errorQ, errorI); //std::cerr << errorD << std::endl; //loop filter integrator += Ki * errorD; //update phase estimate phaseEst += (Kp * errorD) + integrator; //internal oscillator triArg = 2 * PI * (freq / Fs) * (trigOffset + i + 1) + phaseEst; feedbackI = std::cos(triArg); feedbackQ = std::sin(triArg); ncoOut_i[i + 1] = std::cos(triArg * ncoScale + phaseAdjust); ncoOut_q[i + 1] = std::sin(triArg * ncoScale + phaseAdjust); } trigOffset += pllIn.size(); nco_buf_i = ncoOut_i[ncoOut_i.size() - 1]; nco_buf_q = ncoOut_q[ncoOut_q.size() - 1]; ncoOut_i.pop_back(); ncoOut_q.pop_back(); }
32.247813
319
0.508815
acejarvis
72b444be5e0f1bdea1eced5d9ccfc01fc5e3ae00
6,786
cpp
C++
src/layers/MsnhUpSampleLayer.cpp
Janus1984/Msnhnet
4e09f2501ba8db789f0a20441a357de3ba468f10
[ "MIT" ]
546
2020-07-05T13:09:44.000Z
2022-03-31T01:55:22.000Z
src/layers/MsnhUpSampleLayer.cpp
hengC-137/Msnhnet
b7ae88b41c1c1d715990afe50727c46c09237a5a
[ "MIT" ]
23
2020-07-09T01:26:10.000Z
2021-12-08T01:18:46.000Z
src/layers/MsnhUpSampleLayer.cpp
hengC-137/Msnhnet
b7ae88b41c1c1d715990afe50727c46c09237a5a
[ "MIT" ]
114
2020-07-06T06:04:40.000Z
2022-03-30T14:47:50.000Z
#include "Msnhnet/layers/MsnhUpSampleLayer.h" namespace Msnhnet { UpSampleLayer::UpSampleLayer(const int &batch, const int &width, const int &height, const int &channel, const int &strideX, const int &strideY, const float &scaleX, const float &scaleY, UpSampleParams::UpsampleType upsampleType, const int &alignCorners) { this->_type = LayerType::UPSAMPLE; this->_layerName = "UpSample "; this->_batch = batch; this->_width = width; this->_height = height; this->_channel = channel; this->_upsampleType = upsampleType; if(upsampleType == UpSampleParams::NEAREST) { this->_outWidth = width*strideX; this->_outHeight = height*strideY; } else if(upsampleType == UpSampleParams::BILINEAR) { this->_outWidth = static_cast<int>(width*scaleX); this->_outHeight = static_cast<int>(height*scaleY); } this->_outChannel = channel; this->_scaleX = scaleX; this->_scaleY = scaleY; this->_strideX = strideX; this->_strideY = strideY; this->_outputNum = this->_outWidth * this->_outHeight * this->_outChannel; this->_inputNum = this->_width * this->_height * this->_channel; this->_alignCorners = alignCorners; this->_maxOutputNum = this->_batch*this->_outputNum; char msg[100]; if(upsampleType == UpSampleParams::NEAREST) { #ifdef WIN32 sprintf_s(msg, "Upsample nearest %2dx%2d %4d x%4d x%4d -> %4d x%4d x%4d\n", this->_strideX, this->_strideY, this->_width, this->_height, this->_channel, this->_outHeight, this->_outHeight, this->_outChannel); #else sprintf(msg, "upsample %2dx%2d %4d x%4d x%4d -> %4d x%4d x%4d\n", this->_strideX, this->_strideY, this->_width, this->_height, this->_channel, this->_outHeight, this->_outHeight, this->_outChannel); #endif } else if(upsampleType == UpSampleParams::BILINEAR) { #ifdef WIN32 sprintf_s(msg, "Upsample bili %4fx%4f %4d x%4d x%4d -> %4d x%4d x%4d\n", this->_scaleX, this->_scaleY, this->_width, this->_height, this->_channel, this->_outHeight, this->_outHeight, this->_outChannel); #else sprintf(msg, "upsample bili %4fx%4f %4d x%4d x%4d -> %4d x%4d x%4d\n", this->_scaleX, this->_scaleY, this->_width, this->_height, this->_channel, this->_outHeight, this->_outHeight, this->_outChannel); #endif } this->_layerDetail = msg; } void UpSampleLayer::forward(NetworkState &netState) { auto st = TimeUtil::startRecord(); float* layerInput = netState.getInput(); float* layerOutput = nullptr; if(this->_layerIndex == 0) { layerInput = netState.input; } else { if(netState.net->layers[this->_layerIndex - 1]->getMemReUse() == 0) { layerInput = netState.input; } } if(this->_memReUse==1) { layerOutput = netState.getOutput(); netState.shuffleInOut(); } else { layerOutput = this->_output; } if(this->_upsampleType == UpSampleParams::NEAREST) { Blas::cpuUpSample(layerInput, this->_width, this->_height, this->_channel, this->_batch, this->_strideX, this->_strideY, this->_scaleX, layerOutput); } else { Blas::cpuBilinearResize(layerInput, this->_width, this->_height, this->_channel, this->_batch, this->_outWidth, this->_outHeight, this->_alignCorners, layerOutput); } this->_forwardTime = TimeUtil::getElapsedTime(st); } void UpSampleLayer::mallocMemory() { if(!this->_memoryMalloced) { if(!BaseLayer::isPreviewMode) { if(!BaseLayer::onlyUseGpu) { this->_output = MemoryManager::effcientNew<float>(static_cast<size_t>(this->_outputNum * this->_batch)); } #ifdef USE_GPU if(!BaseLayer::onlyUseCpu) { this->_gpuOutput = Cuda::mallocCudaArray(this->_outputNum * this->_batch); } #endif this->_memoryMalloced = true; } } this->_memReUse = 0; } #ifdef USE_GPU void UpSampleLayer::forwardGPU(NetworkState &netState) { float* layerGpuInput = netState.getGpuInput(); float* layerGpuOutput = nullptr; if(this->_layerIndex == 0) { layerGpuInput = netState.input; } else { if(netState.net->layers[this->_layerIndex - 1]->getMemReUse() == 0) { layerGpuInput = netState.input; } } if(this->_memReUse==1) { layerGpuOutput = netState.getGpuOutput(); netState.shuffleGpuInOut(); } else { layerGpuOutput = this->_gpuOutput; } this->recordCudaStart(); BlasGPU::gpuFill(this->_outputNum*this->_batch, 0, layerGpuOutput, 1); if(this->_upsampleType == UpSampleParams::NEAREST) { BlasGPU::gpuUpSample(layerGpuInput, this->_width, this->_height, this->_channel, this->_batch, this->_strideX, this->_strideY, this->_scaleX, layerGpuOutput); } else { BlasGPU::gpuBilinearResize(layerGpuInput, this->_width, this->_height, this->_channel, this->_batch, this->_outWidth, this->_outHeight, this->_alignCorners, layerGpuOutput); } this->recordCudaStop(); } #endif void UpSampleLayer::resize(const int &width, const int &height) { this->_width = width; this->_height = height; this->_outWidth = width*this->_strideX; this->_outHeight = height*this->_strideY; this->_outputNum = this->_outWidth * this->_outHeight * this->_outChannel; if(this->_output == nullptr) { throw Exception(1,"output can't be null", __FILE__, __LINE__, __FUNCTION__); } this->_output = static_cast<float *>(realloc(this->_output, static_cast<size_t>(this->_outputNum * this->_batch) *sizeof(float))); } int UpSampleLayer::getStrideX() const { return _strideX; } int UpSampleLayer::getStrideY() const { return _strideY; } float UpSampleLayer::getScaleX() const { return _scaleX; } float UpSampleLayer::getScaleY() const { return _scaleY; } int UpSampleLayer::getAlignCorners() const { return _alignCorners; } UpSampleParams::UpsampleType UpSampleLayer::getUpsampleType() const { return _upsampleType; } }
28.157676
182
0.587533
Janus1984
72b454affbf7d906621c52ca284b57f6ca0da826
36,002
cpp
C++
src/gausskernel/storage/mot/core/src/memory/mm_session_api.cpp
wotchin/openGauss-server
ebd92e92b0cfd76b121d98e4c57a22d334573159
[ "MulanPSL-1.0" ]
1
2020-06-30T15:00:50.000Z
2020-06-30T15:00:50.000Z
src/gausskernel/storage/mot/core/src/memory/mm_session_api.cpp
wotchin/openGauss-server
ebd92e92b0cfd76b121d98e4c57a22d334573159
[ "MulanPSL-1.0" ]
null
null
null
src/gausskernel/storage/mot/core/src/memory/mm_session_api.cpp
wotchin/openGauss-server
ebd92e92b0cfd76b121d98e4c57a22d334573159
[ "MulanPSL-1.0" ]
null
null
null
/* * Copyright (c) 2020 Huawei Technologies Co.,Ltd. * * openGauss is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. * ------------------------------------------------------------------------- * * mm_session_api.cpp * Session-local memory API, which provides session-local objects that can be used only in session context. * * IDENTIFICATION * src/gausskernel/storage/mot/core/src/memory/mm_session_api.cpp * * ------------------------------------------------------------------------- */ #include <string.h> #include "mm_session_api.h" #include "mm_cfg.h" #include "mm_numa.h" #include "mm_def.h" #include "mot_error.h" #include "mm_raw_chunk_store.h" #include "thread_id.h" #include "mm_buffer_class.h" #include "mot_engine.h" #include "mm_api.h" #include "mm_session_large_buffer_store.h" #include "mm_session_allocator.h" namespace MOT { DECLARE_LOGGER(SessionApi, Memory) /** @var The actual maximum object size in bytes that can be allocated by a huge allocation. */ uint64_t memSessionHugeBufferMaxObjectSizeBytes = 0; // comment to disable huge buffer usage #define USING_LARGE_HUGE_SESSION_BUFFERS struct MemSessionAttrSet { int m_node; MOTThreadId m_threadId; SessionId m_sessionId; ConnectionId m_connectionId; }; static MemSessionAllocator** g_sessionAllocators = nullptr; static void* g_sessionAllocatorBuf[MEM_MAX_NUMA_NODES]; static pthread_mutex_t g_sessionLock; // required for safe statistics reporting extern int MemSessionApiInit() { int result = 0; MOT_LOG_TRACE("Initializing session API"); memSessionHugeBufferMaxObjectSizeBytes = ((uint64_t)g_memGlobalCfg.m_sessionMaxHugeObjectSizeMb) * MEGA_BYTE; int rc = pthread_mutex_init(&g_sessionLock, nullptr); if (rc != 0) { MOT_REPORT_SYSTEM_PANIC_CODE( rc, pthread_mutex_init, "Session API Initialization", "Failed to initialize session lock"); } else { // 1. Allocate memory for global array: g_sessionAllocators, and nullify it. g_sessionAllocators = (MemSessionAllocator**)malloc(sizeof(MemSessionAllocator*) * g_memGlobalCfg.m_maxConnectionCount); if (g_sessionAllocators == nullptr) { MOT_REPORT_PANIC(MOT_ERROR_OOM, "Session API Initialization", "Failed to allocate memory for global array of g_sessionAllocators."); result = MOT_ERROR_OOM; } else { // make sure all session allocators are NULL errno_t erc = memset_s(g_sessionAllocators, sizeof(MemSessionAllocator*) * g_memGlobalCfg.m_maxConnectionCount, 0, sizeof(MemSessionAllocator*) * g_memGlobalCfg.m_maxConnectionCount); securec_check(erc, "\0", "\0"); // 2. Allocate memory for sessionAllocator for all threads, and nullify it. size_t size = L1_ALIGNED_SIZEOF(MemSessionAllocator) * g_memGlobalCfg.m_maxConnectionCount; for (uint32_t node = 0; node < g_memGlobalCfg.m_nodeCount; ++node) { g_sessionAllocatorBuf[node] = MemNumaAllocLocal(size, node); if (g_sessionAllocatorBuf[node] == nullptr) { MOT_REPORT_PANIC(MOT_ERROR_OOM, "Session API Initialization", "Failed to allocate %u bytes for session allocators on NUMA node: %d", size, node); // Exception: free all memory allocated successfully before to avoid memory leak; for (uint32_t i = 0; i < node; i++) { MemNumaFreeLocal(g_sessionAllocatorBuf[i], size, i); g_sessionAllocatorBuf[i] = nullptr; } free(g_sessionAllocators); g_sessionAllocators = nullptr; pthread_mutex_destroy(&g_sessionLock); result = GetLastError(); break; } erc = memset_s(g_sessionAllocatorBuf[node], size, 0, size); securec_check(erc, "\0", "\0"); } } } if (result == 0) { MOT_LOG_TRACE("Session API initialized successfully"); } return result; } extern void MemSessionApiDestroy() { MOT_LOG_TRACE("Destroying Session API"); size_t size = L1_ALIGNED_SIZEOF(MemSessionAllocator) * g_memGlobalCfg.m_maxConnectionCount; // 1. Check if the session_allocators are still in use or not. for (uint32_t i = 0; i < g_memGlobalCfg.m_maxConnectionCount; ++i) { if (g_sessionAllocators[i] != nullptr) { MOT_LOG_WARN("Session allocator for thread %u is still in use", i); } } // 2. Free all g_sessionAllocatorBuf. for (uint32_t node = 0; node < g_memGlobalCfg.m_nodeCount; ++node) { MemNumaFreeLocal((void*)g_sessionAllocatorBuf[node], size, node); g_sessionAllocatorBuf[node] = nullptr; } // 3. Free g_sessionAllocators global array. free(g_sessionAllocators); g_sessionAllocators = nullptr; pthread_mutex_destroy(&g_sessionLock); MOT_LOG_TRACE("Session API destroyed"); } static int MemSessionGetAttrSet(const char* phase, const char* operation, MemSessionAttrSet& attrSet) { int result = 0; attrSet.m_node = MOTCurrentNumaNodeId; attrSet.m_threadId = MOTCurrThreadId; attrSet.m_sessionId = MOT_GET_CURRENT_SESSION_ID(); attrSet.m_connectionId = MOT_GET_CURRENT_CONNECTION_ID(); if ((attrSet.m_node == MEM_INVALID_NODE) || (attrSet.m_threadId == INVALID_THREAD_ID) || (attrSet.m_sessionId == INVALID_SESSION_ID) || (attrSet.m_connectionId == INVALID_CONNECTION_ID)) { // invalid current session attributes, report and return error, MOT_ASSERT on debug mode MOT_REPORT_ERROR(MOT_ERROR_INTERNAL, phase, "Invalid attempt to %s without proper thread/connection/session/node identifier for the current thread " "(thread id: %u, connection id: %u, session id: %u, node id: %d)", operation, (unsigned)attrSet.m_threadId, attrSet.m_connectionId, attrSet.m_sessionId, attrSet.m_node); MOT_ASSERT(false); result = MOT_ERROR_INTERNAL; } else { #ifdef MOT_DEBUG // validate session attributes (debug mode only) SessionContext* sessionContext = MOT_GET_CURRENT_SESSION_CONTEXT(); if (sessionContext != nullptr) { MOT_ASSERT(attrSet.m_sessionId == sessionContext->GetSessionId()); MOT_ASSERT(attrSet.m_connectionId == sessionContext->GetConnectionId()); } MemSessionAllocator* sessionAllocator = g_sessionAllocators[attrSet.m_connectionId]; if (sessionAllocator != nullptr) { MOT_ASSERT(sessionAllocator->m_sessionId == attrSet.m_sessionId); MOT_ASSERT(sessionAllocator->m_connectionId == attrSet.m_connectionId); } #endif } return result; } extern int MemSessionReserve(uint32_t sizeBytes) { MemSessionAttrSet attrSet = {0}; int result = MemSessionGetAttrSet("Session Initialization", "reserve session memory and create session allocator", attrSet); if (result == 0) { int node = attrSet.m_node; ConnectionId connectionId = attrSet.m_connectionId; if (g_sessionAllocators[attrSet.m_connectionId] != nullptr) { // Check for double reservation for a sessionAllocator. MOT_LOG_WARN("Double reservation ignored for g_sessionAllocators[%u] on NUMA node %d.", attrSet.m_connectionId, node); } else { MOT_LOG_TRACE("Initializing g_sessionAllocators[%u]", attrSet.m_connectionId, node); // 1. get the right start address of g_sessionAllocatorBuf. MemSessionAllocator* sessionAllocator = (MemSessionAllocator*)(((char*)g_sessionAllocatorBuf[node]) + L1_ALIGNED_SIZEOF(MemSessionAllocator) * connectionId); // 2. Allocate raw chunks from the NUMA node local chunk pool according to the requested size. uint32_t chunkCount = (sizeBytes + MEM_CHUNK_SIZE_MB * MEGA_BYTE - 1) / (MEM_CHUNK_SIZE_MB * MEGA_BYTE); MemSessionChunkHeader* chunkList = nullptr; for (uint32_t i = 0; i < chunkCount; ++i) { MemSessionChunkHeader* chunk = (MemSessionChunkHeader*)MemRawChunkStoreAllocLocal(node); if (chunk == nullptr) { result = GetLastError(); MOT_REPORT_ERROR(MOT_ERROR_OOM, "Session Initialization", "Failed to allocate chunk for session allocator (during new session memory reservation)"); MOT_LOG_DEBUG("Exception: free all chunks successfully allocated before to avoid memory leak."); // Exception: free all chunks allocated successfully before to avoid memory leak; while (chunkList != nullptr) { MemSessionChunkHeader* temp = chunkList; chunkList = chunkList->m_next; MemRawChunkStoreFreeLocal((void*)temp, node); } break; } MemSessionChunkInit(chunk, MEM_CHUNK_TYPE_SESSION, node, MEM_ALLOC_LOCAL); chunk->m_next = chunkList; chunkList = chunk; } // 3. Initialize the sessionAllocator. if (result == 0) { MemSessionAllocatorInit( sessionAllocator, attrSet.m_sessionId, connectionId, chunkList, chunkCount, MEM_ALLOC_LOCAL); // save the new allocator in the allocator array (minimize time lock is held) pthread_mutex_lock(&g_sessionLock); g_sessionAllocators[connectionId] = sessionAllocator; pthread_mutex_unlock(&g_sessionLock); MOT_LOG_DEBUG("Session allocator initialized for thread id %u, connection id %u, session id: %u", (unsigned)attrSet.m_threadId, connectionId, attrSet.m_sessionId); } else { g_sessionAllocators[attrSet.m_connectionId] = nullptr; } } } return result; } extern void MemSessionUnreserve() { MemSessionAttrSet attrSet = {0}; int result = MemSessionGetAttrSet("Session Termination", "unreserve session memory and destroy session allocator", attrSet); if (result != 0) { return; } MOT_LOG_TRACE("Destroying g_sessionAllocators[%u]", attrSet.m_connectionId); ConnectionId connectionId = attrSet.m_connectionId; MemSessionAllocator* sessionAllocator = g_sessionAllocators[connectionId]; // Guard against double free. if (sessionAllocator == nullptr) { MOT_LOG_WARN("Ignoring double attempt to destroy session allocator[%u]", connectionId); } else { MemSessionAllocatorPrint("Pre-Terminate report", LogLevel::LL_TRACE, sessionAllocator); // minimize time lock is held (set NULL quickly before destroying later) pthread_mutex_lock(&g_sessionLock); g_sessionAllocators[connectionId] = nullptr; pthread_mutex_unlock(&g_sessionLock); MemSessionAllocatorDestroy(sessionAllocator); } } extern void* MemSessionAlloc(uint64_t sizeBytes) { void* result = nullptr; #ifndef MEM_SESSION_ACTIVE result = malloc(sizeBytes); #else MemSessionAttrSet attrSet = {0}; int res = MemSessionGetAttrSet("Session Memory Allocation", "allocate session-local memory", attrSet); if (res != 0) { return nullptr; } ConnectionId connectionId = attrSet.m_connectionId; SessionId sessionId = attrSet.m_sessionId; #ifndef USING_LARGE_HUGE_SESSION_BUFFERS MOT_LOG_DEBUG("Allocating %" PRIu64 " bytes by session %u from session allocator %u", sizeBytes, sessionId, (unsigned)connectionId); result = MemSessionAllocatorAlloc(g_sessionAllocators[connectionId], sizeBytes); #else if (sizeBytes <= MEM_SESSION_MAX_ALLOC_SIZE) { MOT_LOG_DEBUG( "Allocating %" PRIu64 " bytes by session %u from session allocator %u", sizeBytes, sessionId, connectionId); result = MemSessionAllocatorAlloc(g_sessionAllocators[connectionId], sizeBytes); } else { // try to allocate from large buffer store if (sizeBytes <= g_memSessionLargeBufferMaxObjectSizeBytes) { MOT_LOG_DEBUG("Trying to allocate %" PRIu64 " bytes by session %u connection %u from session large buffer store", sizeBytes, sessionId, connectionId); result = MemSessionLargeBufferAlloc(sizeBytes, &(g_sessionAllocators[connectionId]->m_largeBufferList)); } // NOTE: large/huge buffers not counted in statistics // try to allocate from kernel (also when large allocation fails) if (result == nullptr) { if (sizeBytes <= memSessionHugeBufferMaxObjectSizeBytes) { // NOTE: check with g_instance.attr.attr_memory.max_process_memory is not done before we proceed MOT_LOG_DEBUG("Trying to allocate %" PRIu64 " bytes by session %u connection %u as huge memory", sizeBytes, sessionId, connectionId); result = MemHugeAlloc( sizeBytes, attrSet.m_node, MEM_ALLOC_LOCAL, &(g_sessionAllocators[connectionId]->m_hugeChunkList)); } else { MOT_REPORT_ERROR(MOT_ERROR_INVALID_MEMORY_SIZE, "N/A", "Request for invalid allocation size %" PRIu64 " bytes for session %u, thread %u, connection %u denied: Size exceeds configured limit of %" PRIu64 " bytes", sizeBytes, sessionId, (unsigned)attrSet.m_threadId, connectionId, memSessionHugeBufferMaxObjectSizeBytes); } } } #endif #endif return result; } extern void* MemSessionAllocAligned(uint64_t sizeBytes, uint32_t alignment) { void* result = nullptr; #ifndef MEM_SESSION_ACTIVE result = malloc(ALIGN_N(sizeBytes, alignment)); #else MemSessionAttrSet attrSet = {0}; int res = MemSessionGetAttrSet("Session Memory Allocation", "allocate aligned session-local memory", attrSet); if (res != 0) { return nullptr; } ConnectionId connectionId = attrSet.m_connectionId; SessionId sessionId = attrSet.m_sessionId; #ifndef USING_LARGE_HUGE_SESSION_BUFFERS MOT_LOG_DEBUG("Allocating %" PRIu64 " bytes aligned to %u bytes by session %u from session allocator %u", sizeBytes, alignment, sessionId, (unsigned)connectionId); result = MemSessionAllocatorAllocAligned(g_sessionAllocators[connectionId], sizeBytes, alignment); #else if ((sizeBytes + alignment) <= MEM_SESSION_MAX_ALLOC_SIZE) { MOT_LOG_DEBUG("Allocating %" PRIu64 " bytes aligned to %u bytes by session %u from session allocator %u", sizeBytes, alignment, sessionId, connectionId); result = MemSessionAllocatorAllocAligned(g_sessionAllocators[connectionId], sizeBytes, alignment); } else if ((alignment % PAGE_SIZE_BYTES) == 0) { // allocate as a regular allocation, since we have native 4 KB alignment result = MemSessionAlloc(sizeBytes); } else { MOT_REPORT_ERROR(MOT_ERROR_INVALID_MEMORY_SIZE, "Session Memory Allocation", "Unsupported size %" PRIu64 " for aligned allocations", sizeBytes); } #endif #endif return result; } static void* MemSessionReallocSmall( void* object, uint64_t newSizeBytes, MemReallocFlags flags, ConnectionId connectionId, SessionId sessionId) { void* newObject = nullptr; errno_t erc; if (newSizeBytes <= MEM_SESSION_MAX_ALLOC_SIZE) { MOT_LOG_DEBUG("Reallocating %" PRIu64 " bytes by session %u from session allocator %u", newSizeBytes, sessionId, connectionId); newObject = MemSessionAllocatorRealloc(g_sessionAllocators[connectionId], object, newSizeBytes, flags); } else { MOT_LOG_TRACE("Reallocating %" PRIu64 " bytes by session %u from session allocator %u to large/huge buffer", newSizeBytes, sessionId, connectionId); newObject = MemSessionAlloc(newSizeBytes); if (newObject != nullptr) { MemSessionObjectHeader* objectHeader = (MemSessionObjectHeader*)((char*)object - MEM_SESSION_OBJECT_HEADER_LEN); uint64_t objectSizeBytes = (uint64_t)objectHeader->m_objectSize.m_realSize; if (flags == MEM_REALLOC_COPY) { // attention: new size may be smaller erc = memcpy_s(newObject, newSizeBytes, object, std::min(newSizeBytes, objectSizeBytes)); securec_check(erc, "\0", "\0"); } else if (flags == MEM_REALLOC_ZERO) { erc = memset_s(newObject, newSizeBytes, 0, newSizeBytes); securec_check(erc, "\0", "\0"); } else if (flags == MEM_REALLOC_COPY_ZERO) { // attention: new size may be smaller erc = memcpy_s(newObject, newSizeBytes, object, std::min(newSizeBytes, objectSizeBytes)); securec_check(erc, "\0", "\0"); if (newSizeBytes > objectSizeBytes) { erc = memset_s(((char*)newObject) + objectSizeBytes, newSizeBytes - objectSizeBytes, 0, newSizeBytes - objectSizeBytes); securec_check(erc, "\0", "\0"); } } MemSessionAllocatorFree(g_sessionAllocators[connectionId], object); } } return newObject; } static void* MemSessionReallocLarge( void* object, uint64_t newSizeBytes, MemReallocFlags flags, ConnectionId connectionId, SessionId sessionId) { void* newObject = nullptr; errno_t erc; if ((newSizeBytes > MEM_SESSION_MAX_ALLOC_SIZE) && (newSizeBytes <= g_memSessionLargeBufferMaxObjectSizeBytes)) { newObject = MemSessionLargeBufferRealloc( object, newSizeBytes, flags, &(g_sessionAllocators[connectionId]->m_largeBufferList)); } else { MOT_LOG_TRACE("Reallocating %" PRIu64 " bytes by session %u, connection %u from large to small/huge session buffer", newSizeBytes, sessionId, connectionId); newObject = MemSessionAlloc(newSizeBytes); if (newObject != nullptr) { uint64_t objectSizeBytes = MemSessionLargeBufferGetObjectSize(object); if (flags == MEM_REALLOC_COPY) { // attention: new size may be smaller erc = memcpy_s(newObject, newSizeBytes, object, min(newSizeBytes, objectSizeBytes)); securec_check(erc, "\0", "\0"); } else if (flags == MEM_REALLOC_ZERO) { erc = memset_s(newObject, newSizeBytes, 0, newSizeBytes); securec_check(erc, "\0", "\0"); } else if (flags == MEM_REALLOC_COPY_ZERO) { // attention: new size may be smaller erc = memcpy_s(newObject, newSizeBytes, object, min(newSizeBytes, objectSizeBytes)); securec_check(erc, "\0", "\0"); if (newSizeBytes > objectSizeBytes) { erc = memset_s(((char*)newObject) + objectSizeBytes, newSizeBytes - objectSizeBytes, 0, newSizeBytes - objectSizeBytes); securec_check(erc, "\0", "\0"); } } MemSessionLargeBufferFree(object, &(g_sessionAllocators[connectionId]->m_largeBufferList)); } } return newObject; } static void* MemSessionReallocHuge(void* object, uint64_t newSizeBytes, MemReallocFlags flags, MemRawChunkHeader* rawChunk, ConnectionId connectionId, SessionId sessionId) { void* newObject = nullptr; errno_t erc; if ((newSizeBytes > g_memSessionLargeBufferMaxObjectSizeBytes) && (newSizeBytes <= memSessionHugeBufferMaxObjectSizeBytes)) { newObject = MemHugeRealloc((MemVirtualHugeChunkHeader*)rawChunk, object, newSizeBytes, flags, &(g_sessionAllocators[connectionId]->m_hugeChunkList)); } else { MOT_LOG_TRACE("Reallocating %" PRIu64 " bytes by session %u, connection %u from huge to small/large session buffer", newSizeBytes, sessionId, connectionId); newObject = MemSessionAlloc(newSizeBytes); if (newObject != nullptr) { uint64_t objectSizeBytes = ((MemVirtualHugeChunkHeader*)rawChunk)->m_objectSizeBytes; if (flags == MEM_REALLOC_COPY) { // attention: new size may be smaller erc = memcpy_s(newObject, newSizeBytes, object, min(newSizeBytes, objectSizeBytes)); securec_check(erc, "\0", "\0"); } else if (flags == MEM_REALLOC_ZERO) { erc = memset_s(newObject, newSizeBytes, 0, newSizeBytes); securec_check(erc, "\0", "\0"); } else if (flags == MEM_REALLOC_COPY_ZERO) { // attention: new size may be smaller erc = memcpy_s(newObject, newSizeBytes, object, min(newSizeBytes, objectSizeBytes)); securec_check(erc, "\0", "\0"); if (newSizeBytes > objectSizeBytes) { erc = memset_s(((char*)newObject) + objectSizeBytes, newSizeBytes - objectSizeBytes, 0, newSizeBytes - objectSizeBytes); securec_check(erc, "\0", "\0"); } } MemHugeFree( (MemVirtualHugeChunkHeader*)rawChunk, object, &(g_sessionAllocators[connectionId]->m_hugeChunkList)); } } return newObject; } extern void* MemSessionRealloc(void* object, uint64_t newSizeBytes, MemReallocFlags flags) { void* newObject = nullptr; MemSessionAttrSet attrSet = {0}; int res = MemSessionGetAttrSet("Session Memory Allocation", "allocate aligned session-local memory", attrSet); if (res != 0) { return nullptr; } ConnectionId connectionId = attrSet.m_connectionId; SessionId sessionId = attrSet.m_sessionId; if (object == nullptr) { newObject = MemSessionAlloc(newSizeBytes); } else { #ifndef USING_LARGE_HUGE_SESSION_BUFFERS MOT_LOG_DEBUG("Reallocating %" PRIu64 " bytes by session %u from session allocator %u", newSizeBytes, sessionId, connectionId); newObject = MemSessionAllocatorRealloc(g_sessionAllocators[connectionId], object, newSizeBytes, flags); #else // find out source of object (session allocator/session large buffer store/huge chunk) // pay attention, this code is a bit tricky: the object could come from one source, but the new size fits to // another source MemRawChunkHeader* rawChunk = (MemRawChunkHeader*)MemRawChunkDirLookup(object); if (rawChunk->m_chunkType == MEM_CHUNK_TYPE_SESSION) { // re-allocate a session-local small object newObject = MemSessionReallocSmall(object, newSizeBytes, flags, connectionId, sessionId); } else if (rawChunk->m_chunkType == MEM_CHUNK_TYPE_SESSION_LARGE_BUFFER_POOL) { // re-allocate a session-local large object newObject = MemSessionReallocLarge(object, newSizeBytes, flags, connectionId, sessionId); } else if (rawChunk->m_chunkType == MEM_CHUNK_TYPE_HUGE_OBJECT) { // re-allocate a session-local huge object newObject = MemSessionReallocHuge(object, newSizeBytes, flags, rawChunk, connectionId, sessionId); } else { MOT_LOG_PANIC("Invalid object %p provided to MemSessionRealloc(): Unknown source chunk type %u (%s)", object, rawChunk->m_chunkType, MemChunkTypeToString(rawChunk->m_chunkType)); MOTAbort(object); } #endif } return newObject; } extern void MemSessionFree(void* object) { #ifndef MEM_SESSION_ACTIVE free(object); #else MemSessionAttrSet attrSet = {0}; int res = MemSessionGetAttrSet("Session Memory De-Allocation", "free session-local memory", attrSet); if (res != 0) { return; } ConnectionId connectionId = attrSet.m_connectionId; if (object != nullptr) { // find out source of object (session allocator/session large buffer store/huge chunk) #ifdef USING_LARGE_HUGE_SESSION_BUFFERS MemRawChunkHeader* rawChunk = (MemRawChunkHeader*)MemRawChunkDirLookup(object); if (rawChunk->m_chunkType == MEM_CHUNK_TYPE_SESSION) { #endif MemSessionAllocator* sessionAllocator = g_sessionAllocators[connectionId]; if (sessionAllocator == nullptr) { MOT_REPORT_ERROR(MOT_ERROR_INTERNAL, "Session Memory De-Allocation", "Cannot free session memory: session allocator of connection %u is NULL.", connectionId); } else { MemSessionAllocatorFree(sessionAllocator, object); } #ifdef USING_LARGE_HUGE_SESSION_BUFFERS } else if (rawChunk->m_chunkType == MEM_CHUNK_TYPE_SESSION_LARGE_BUFFER_POOL) { MemSessionLargeBufferFree(object, &(g_sessionAllocators[connectionId]->m_largeBufferList)); } else if (rawChunk->m_chunkType == MEM_CHUNK_TYPE_HUGE_OBJECT) { MemHugeFree( (MemVirtualHugeChunkHeader*)rawChunk, object, &(g_sessionAllocators[connectionId]->m_hugeChunkList)); } else { MOT_LOG_PANIC("Invalid object %p provided to MemSessionFree(): Unknown source chunk type %u (%s)", object, rawChunk->m_chunkType, MemChunkTypeToString(rawChunk->m_chunkType)); MOTAbort(object); } #endif } #endif } extern void MemSessionCleanup() { MemSessionAttrSet attrSet = {0}; int res = MemSessionGetAttrSet("Session Destruction", "cleanup session-local memory", attrSet); if (res != 0) { return; } ConnectionId connectionId = attrSet.m_connectionId; MemSessionAllocator* sessionAllocator = g_sessionAllocators[connectionId]; if (sessionAllocator == nullptr) { MOT_LOG_TRACE("g_sessionAllocators[%u] was already NULL. No need to cleanup.", connectionId); } else { MemSessionAllocatorCleanup(sessionAllocator); } } extern void MemSessionApiPrint(const char* name, LogLevel logLevel, MemReportMode reportMode /* = MEM_REPORT_SUMMARY */) { if (MOT_CHECK_LOG_LEVEL(logLevel)) { StringBufferApply([name, logLevel, reportMode](StringBuffer* stringBuffer) { MemSessionApiToString(0, name, stringBuffer, reportMode); MOT_LOG(logLevel, "%s", stringBuffer->m_buffer); }); } } extern void MemSessionApiToString( int indent, const char* name, StringBuffer* stringBuffer, MemReportMode reportMode /* = MEM_REPORT_SUMMARY */) { StringBufferAppend(stringBuffer, "%*sSession Memory %s Report:\n", indent, "", name); MemSessionAllocatorStats* sessionStatsArray = (MemSessionAllocatorStats*)calloc(g_memGlobalCfg.m_maxConnectionCount, sizeof(MemSessionAllocatorStats)); if (sessionStatsArray != nullptr) { uint32_t sessionCount = MemSessionGetAllStats(sessionStatsArray, g_memGlobalCfg.m_maxConnectionCount); if (reportMode == MEM_REPORT_SUMMARY) { MemSessionAllocatorStats aggStats; errno_t erc = memset_s(&aggStats, sizeof(MemSessionAllocatorStats), 0, sizeof(MemSessionAllocatorStats)); securec_check(erc, "\0", "\0"); for (uint32_t i = 0; i < sessionCount; ++i) { MemSessionAllocatorStats* stats = &sessionStatsArray[i]; aggStats.m_reservedSize += stats->m_reservedSize; aggStats.m_usedSize += stats->m_usedSize; aggStats.m_realUsedSize += stats->m_realUsedSize; aggStats.m_maxUsedSize += stats->m_maxUsedSize; aggStats.m_maxRealUsedSize += stats->m_maxRealUsedSize; } MemSessionAllocatorFormatStats(indent + PRINT_REPORT_INDENT, name, stringBuffer, &aggStats, reportMode); } else { for (uint32_t i = 0; i < sessionCount; ++i) { MemSessionAllocatorStats* stats = &sessionStatsArray[i]; MemSessionAllocatorFormatStats(indent + PRINT_REPORT_INDENT, name, stringBuffer, stats, reportMode); } } free(sessionStatsArray); } } extern int MemSessionGetStats(ConnectionId connectionId, MemSessionAllocatorStats* stats) { // get the session allocator for the session id int result = 0; pthread_mutex_lock(&g_sessionLock); if (connectionId != INVALID_CONNECTION_ID) { MemSessionAllocator* sessionAllocator = g_sessionAllocators[connectionId]; if (sessionAllocator == nullptr) { MOT_LOG_WARN( "Cannot retrieve session allocation statistics for connection %u: connection id invalid", connectionId); } else { MemSessionAllocatorGetStats(sessionAllocator, stats); result = 1; } } pthread_mutex_unlock(&g_sessionLock); return result; } extern void MemSessionPrintStats(ConnectionId connectionId, const char* name, LogLevel logLevel) { MemSessionAllocatorStats stats; if (MemSessionGetStats(connectionId, &stats)) { MemSessionAllocatorPrintStats(name, logLevel, &stats); } } extern int MemSessionGetCurrentStats(MemSessionAllocatorStats* stats) { return MemSessionGetStats(MOT_GET_CURRENT_CONNECTION_ID(), stats); } extern void MemSessionPrintCurrentStats(const char* name, LogLevel logLevel) { MemSessionPrintStats(MOT_GET_CURRENT_CONNECTION_ID(), name, logLevel); } extern uint32_t MemSessionGetAllStats(MemSessionAllocatorStats* sessionStatsArray, uint32_t sessionCount) { uint32_t entriesReported = 0; pthread_mutex_lock(&g_sessionLock); for (uint32_t connectionId = 0; connectionId < g_memGlobalCfg.m_maxConnectionCount; ++connectionId) { MemSessionAllocator* sessionAllocator = g_sessionAllocators[connectionId]; if (sessionAllocator != nullptr) { MemSessionAllocatorStats* stats = &sessionStatsArray[entriesReported]; MemSessionAllocatorGetStats(sessionAllocator, stats); if (++entriesReported == sessionCount) { break; } } } pthread_mutex_unlock(&g_sessionLock); return entriesReported; } extern void MemSessionPrintAllStats(const char* name, LogLevel logLevel) { if (MOT_CHECK_LOG_LEVEL(logLevel)) { MemSessionAllocatorStats* sessionStatsArray = (MemSessionAllocatorStats*)calloc(g_memGlobalCfg.m_maxConnectionCount, sizeof(MemSessionAllocatorStats)); if (sessionStatsArray != nullptr) { uint32_t sessionCount = MemSessionGetAllStats(sessionStatsArray, g_memGlobalCfg.m_maxConnectionCount); MOT_LOG(logLevel, "%s Session Allocator Report:", name); for (uint32_t i = 0; i < sessionCount; ++i) { MemSessionAllocatorStats* stats = &sessionStatsArray[i]; MemSessionAllocatorPrintStats(name, logLevel, stats); } free(sessionStatsArray); } } } extern void MemSessionPrintSummary(const char* name, LogLevel logLevel, bool fullReport /* = false */) { if (MOT_CHECK_LOG_LEVEL(logLevel)) { MemSessionAllocatorStats* sessionStatsArray = (MemSessionAllocatorStats*)calloc(g_memGlobalCfg.m_maxConnectionCount, sizeof(MemSessionAllocatorStats)); if (sessionStatsArray != nullptr) { MemSessionAllocatorStats aggStats; errno_t erc = memset_s(&aggStats, sizeof(MemSessionAllocatorStats), 0, sizeof(MemSessionAllocatorStats)); securec_check(erc, "\0", "\0"); uint32_t sessionCount = MemSessionGetAllStats(sessionStatsArray, g_memGlobalCfg.m_maxConnectionCount); for (uint32_t i = 0; i < sessionCount; ++i) { MemSessionAllocatorStats* stats = &sessionStatsArray[i]; aggStats.m_reservedSize += stats->m_reservedSize; aggStats.m_usedSize += stats->m_usedSize; aggStats.m_realUsedSize += stats->m_realUsedSize; aggStats.m_maxUsedSize += stats->m_maxUsedSize; aggStats.m_maxRealUsedSize += stats->m_maxRealUsedSize; } free(sessionStatsArray); MOT_LOG(logLevel, "Session %s [Current]: Reserved = %" PRIu64 " MB, Requested = %" PRIu64 " MB, Allocated = %" PRIu64 " MB", name, aggStats.m_reservedSize / MEGA_BYTE, aggStats.m_usedSize / MEGA_BYTE, aggStats.m_realUsedSize / MEGA_BYTE); if (fullReport) { double memUtilInternal = ((double)aggStats.m_usedSize) / ((double)aggStats.m_realUsedSize) * 100.0; double memUtilExternal = ((double)aggStats.m_usedSize) / aggStats.m_reservedSize * 100.0; uint32_t minRequiredChunks = (aggStats.m_usedSize + MEM_CHUNK_SIZE_MB * MEGA_BYTE - 1) / (MEM_CHUNK_SIZE_MB * MEGA_BYTE); double maxUtilExternal = ((double)aggStats.m_usedSize) / (minRequiredChunks * MEM_CHUNK_SIZE_MB * MEGA_BYTE) * 100.0; MOT_LOG(logLevel, "Session %s [Peak]: Reserved = %" PRIu64 " MB, Requested = %" PRIu64 " MB, Allocated = %" PRIu64 " MB", name, aggStats.m_maxReservedSize / MEGA_BYTE, aggStats.m_maxUsedSize / MEGA_BYTE, aggStats.m_maxRealUsedSize / MEGA_BYTE); MOT_LOG(logLevel, "Session %s [Util]: Int. %0.2f%%, Ext. %0.2f%%, Max Ext. %0.2f%%", name, memUtilInternal, memUtilExternal, maxUtilExternal); } } } } } // namespace MOT extern "C" void MemSessionApiDump() { MOT::StringBufferApply([](MOT::StringBuffer* stringBuffer) { MOT::MemSessionApiToString(0, "Debug Dump", stringBuffer, MOT::MEM_REPORT_DETAILED); fprintf(stderr, "%s", stringBuffer->m_buffer); fflush(stderr); }); } extern "C" int MemSessionApiAnalyze(void* buffer) { for (uint32_t i = 0; i < MOT::g_memGlobalCfg.m_maxConnectionCount; ++i) { fprintf(stderr, "Searching buffer %p in session allocator %u...\n", buffer, i); if (MOT::g_sessionAllocators[i]) { if (MemSessionAllocatorAnalyze(MOT::g_sessionAllocators[i], buffer)) { return 1; } } } return 0; }
42.910608
120
0.634187
wotchin
72b4ba9b6c2f3d52b44c645fc8761d3545940fa2
9,688
cpp
C++
src/nfagraph/ng_utf8.cpp
a16bitsysop/hyperscan
2819dc3d1b796e28d23140cb135077a709b7d28a
[ "BSD-2-Clause", "BSD-3-Clause" ]
146
2021-02-15T14:13:57.000Z
2022-03-30T19:06:13.000Z
src/nfagraph/ng_utf8.cpp
a16bitsysop/hyperscan
2819dc3d1b796e28d23140cb135077a709b7d28a
[ "BSD-2-Clause", "BSD-3-Clause" ]
35
2021-01-26T10:21:21.000Z
2022-03-23T09:50:20.000Z
src/nfagraph/ng_utf8.cpp
a16bitsysop/hyperscan
2819dc3d1b796e28d23140cb135077a709b7d28a
[ "BSD-2-Clause", "BSD-3-Clause" ]
12
2021-03-26T15:02:20.000Z
2022-03-10T13:14:32.000Z
/* * Copyright (c) 2015-2017, Intel Corporation * * 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 Intel Corporation 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. */ /** \file * \brief UTF-8 transforms and operations. */ #include "ng_utf8.h" #include "ng.h" #include "ng_prune.h" #include "ng_util.h" #include "compiler/compiler.h" #include "util/graph_range.h" #include "util/unicode_def.h" #include <set> #include <vector> using namespace std; namespace ue2 { static void allowIllegal(NGHolder &g, NFAVertex v, u8 pred_char) { if (in_degree(v, g) != 1) { DEBUG_PRINTF("unexpected pred\n"); assert(0); /* should be true due to the early stage of this analysis */ return; } CharReach &cr = g[v].char_reach; if (pred_char == 0xe0) { assert(cr.isSubsetOf(CharReach(0xa0, 0xbf))); if (cr == CharReach(0xa0, 0xbf)) { cr |= CharReach(0x80, 0x9f); } } else if (pred_char == 0xf0) { assert(cr.isSubsetOf(CharReach(0x90, 0xbf))); if (cr == CharReach(0x90, 0xbf)) { cr |= CharReach(0x80, 0x8f); } } else if (pred_char == 0xf4) { assert(cr.isSubsetOf(CharReach(0x80, 0x8f))); if (cr == CharReach(0x80, 0x8f)) { cr |= CharReach(0x90, 0xbf); } } else { assert(0); /* unexpected pred */ } } /** \brief Relax forbidden UTF-8 sequences. * * Some byte sequences can not appear in valid UTF-8 as they encode code points * above \\x{10ffff} or they represent overlong encodings. As we require valid * UTF-8 input, we have no defined behaviour in these cases, as a result we can * accept them if it simplifies the graph. */ void relaxForbiddenUtf8(NGHolder &g, const ExpressionInfo &expr) { if (!expr.utf8) { return; } const CharReach e0(0xe0); const CharReach f0(0xf0); const CharReach f4(0xf4); for (auto v : vertices_range(g)) { const CharReach &cr = g[v].char_reach; if (cr == e0 || cr == f0 || cr == f4) { u8 pred_char = cr.find_first(); for (auto t : adjacent_vertices_range(v, g)) { allowIllegal(g, t, pred_char); } } } } static bool hasPredInSet(const NGHolder &g, NFAVertex v, const set<NFAVertex> &s) { for (auto u : inv_adjacent_vertices_range(v, g)) { if (contains(s, u)) { return true; } } return false; } static bool hasSuccInSet(const NGHolder &g, NFAVertex v, const set<NFAVertex> &s) { for (auto w : adjacent_vertices_range(v, g)) { if (contains(s, w)) { return true; } } return false; } static void findSeeds(const NGHolder &h, const bool som, vector<NFAVertex> *seeds) { set<NFAVertex> bad; /* from zero-width asserts near accepts, etc */ for (auto v : inv_adjacent_vertices_range(h.accept, h)) { const CharReach &cr = h[v].char_reach; if (!isutf8ascii(cr) && !isutf8start(cr)) { bad.insert(v); } } for (auto v : inv_adjacent_vertices_range(h.acceptEod, h)) { const CharReach &cr = h[v].char_reach; if (!isutf8ascii(cr) && !isutf8start(cr)) { bad.insert(v); } } // we want to be careful with asserts connected to starts // as well as they may not finish a code point for (auto v : vertices_range(h)) { if (is_virtual_start(v, h)) { bad.insert(v); insert(&bad, adjacent_vertices(v, h)); } } /* we cannot handle vertices connected to accept as would report matches in * the middle of codepoints. acceptEod is not a problem as the input must * end at a codepoint boundary */ bad.insert(h.accept); // If we're in SOM mode, we don't want to mess with vertices that have a // direct edge from startDs. if (som) { insert(&bad, adjacent_vertices(h.startDs, h)); } set<NFAVertex> already_seeds; /* already marked as seeds */ for (auto v : vertices_range(h)) { const CharReach &cr = h[v].char_reach; if (!isutf8ascii(cr) || !hasSelfLoop(v, h)) { continue; } if (hasSuccInSet(h, v, bad)) { continue; } // Skip vertices that are directly connected to other vertices already // in the seeds list: we can't collapse two of these directly next to // each other. if (hasPredInSet(h, v, already_seeds) || hasSuccInSet(h, v, already_seeds)) { continue; } DEBUG_PRINTF("%zu is a seed\n", h[v].index); seeds->emplace_back(v); already_seeds.insert(v); } } static bool expandCyclic(NGHolder &h, NFAVertex v) { DEBUG_PRINTF("inspecting %zu\n", h[v].index); bool changes = false; auto v_preds = preds(v, h); auto v_succs = succs(v, h); set<NFAVertex> start_siblings; set<NFAVertex> end_siblings; CharReach &v_cr = h[v].char_reach; /* We need to find start vertices which have all of our preds. * As we have a self loop, it must be one of our succs. */ for (auto a : adjacent_vertices_range(v, h)) { auto a_preds = preds(a, h); if (a_preds == v_preds && isutf8start(h[a].char_reach)) { DEBUG_PRINTF("%zu is a start v\n", h[a].index); start_siblings.insert(a); } } /* We also need to find full cont vertices which have all our own succs; * As we have a self loop, it must be one of our preds. */ for (auto a : inv_adjacent_vertices_range(v, h)) { auto a_succs = succs(a, h); if (a_succs == v_succs && h[a].char_reach == UTF_CONT_CR) { DEBUG_PRINTF("%zu is a full tail cont\n", h[a].index); end_siblings.insert(a); } } for (auto s : start_siblings) { if (out_degree(s, h) != 1) { continue; } const CharReach &cr = h[s].char_reach; if (cr.isSubsetOf(UTF_TWO_START_CR)) { if (end_siblings.find(*adjacent_vertices(s, h).first) == end_siblings.end()) { DEBUG_PRINTF("%zu is odd\n", h[s].index); continue; } } else if (cr.isSubsetOf(UTF_THREE_START_CR)) { NFAVertex m = *adjacent_vertices(s, h).first; if (h[m].char_reach != UTF_CONT_CR || out_degree(m, h) != 1) { continue; } if (end_siblings.find(*adjacent_vertices(m, h).first) == end_siblings.end()) { DEBUG_PRINTF("%zu is odd\n", h[s].index); continue; } } else if (cr.isSubsetOf(UTF_FOUR_START_CR)) { NFAVertex m1 = *adjacent_vertices(s, h).first; if (h[m1].char_reach != UTF_CONT_CR || out_degree(m1, h) != 1) { continue; } NFAVertex m2 = *adjacent_vertices(m1, h).first; if (h[m2].char_reach != UTF_CONT_CR || out_degree(m2, h) != 1) { continue; } if (end_siblings.find(*adjacent_vertices(m2, h).first) == end_siblings.end()) { DEBUG_PRINTF("%zu is odd\n", h[s].index); continue; } } else { DEBUG_PRINTF("%zu is bad\n", h[s].index); continue; } v_cr |= cr; clear_vertex(s, h); changes = true; } if (changes) { v_cr |= UTF_CONT_CR; /* we need to add in cont reach */ v_cr.set(0xc0); /* we can also add in the forbidden bytes as we require * valid unicode data */ v_cr.set(0xc1); v_cr |= CharReach(0xf5, 0xff); } return changes; } /** \brief Contract cycles of UTF-8 code points down to a single cyclic vertex * where possible, based on the assumption that we will always be matching * against well-formed input. */ void utf8DotRestoration(NGHolder &h, bool som) { vector<NFAVertex> seeds; /* cyclic ascii vertices */ findSeeds(h, som, &seeds); bool changes = false; for (auto v : seeds) { changes |= expandCyclic(h, v); } if (changes) { pruneUseless(h); } } } // namespace ue2
31.868421
79
0.59486
a16bitsysop
72b58cadd71b2de20d04c1c89d78434cc0c4fbb3
14,605
hpp
C++
toolkits/test_getdepneighbor_gpu.hpp
Sanzo00/NeutronStarLite
57d92d1f7f6cd55c55a83ca086096a710185d531
[ "Apache-2.0" ]
1
2022-03-10T07:41:55.000Z
2022-03-10T07:41:55.000Z
toolkits/test_getdepneighbor_gpu.hpp
Sanzo00/NeutronStarLite
57d92d1f7f6cd55c55a83ca086096a710185d531
[ "Apache-2.0" ]
null
null
null
toolkits/test_getdepneighbor_gpu.hpp
Sanzo00/NeutronStarLite
57d92d1f7f6cd55c55a83ca086096a710185d531
[ "Apache-2.0" ]
null
null
null
#include "core/neutronstar.hpp" class test_get_neighbor_gpu { public: int iterations; ValueType learn_rate; ValueType weight_decay; ValueType drop_rate; ValueType alpha; ValueType beta1; ValueType beta2; ValueType epsilon; ValueType decay_rate; ValueType decay_epoch; // graph VertexSubset *active; // graph with no edge data Graph<Empty> *graph; //std::vector<CSC_segment_pinned *> subgraphs; // NN GNNDatum *gnndatum; NtsVar L_GT_C; NtsVar L_GT_G; NtsVar MASK; //GraphOperation *gt; PartitionedGraph *partitioned_graph; // Variables std::vector<Parameter *> P; std::vector<NtsVar> X; nts::ctx::NtsContext* ctx; NtsVar F; NtsVar loss; NtsVar tt; torch::nn::Dropout drpmodel; double exec_time = 0; double all_sync_time = 0; double sync_time = 0; double all_graph_sync_time = 0; double graph_sync_time = 0; double all_compute_time = 0; double compute_time = 0; double all_copy_time = 0; double copy_time = 0; double graph_time = 0; double all_graph_time = 0; test_get_neighbor_gpu(Graph<Empty> *graph_, int iterations_, bool process_local = false, bool process_overlap = false) { graph = graph_; iterations = iterations_; active = graph->alloc_vertex_subset(); active->fill(); graph->init_gnnctx(graph->config->layer_string); // rtminfo initialize graph->init_rtminfo(); graph->rtminfo->process_local = graph->config->process_local; graph->rtminfo->reduce_comm = graph->config->process_local; graph->rtminfo->copy_data = false; graph->rtminfo->process_overlap = graph->config->overlap; graph->rtminfo->with_weight = true; graph->rtminfo->with_cuda = false; graph->rtminfo->lock_free = graph->config->lock_free; } void init_graph() { partitioned_graph=new PartitionedGraph(graph, active); partitioned_graph->GenerateAll([&](VertexId src, VertexId dst) { return nts::op::nts_norm_degree(graph,src, dst); },CPU_T,true); graph->init_communicatior(); //cp = new nts::autodiff::ComputionPath(gt, subgraphs); ctx=new nts::ctx::NtsContext(); } void init_nn() { learn_rate = graph->config->learn_rate; weight_decay = graph->config->weight_decay; drop_rate = graph->config->drop_rate; alpha = graph->config->learn_rate; decay_rate = graph->config->decay_rate; decay_epoch = graph->config->decay_epoch; beta1 = 0.9; beta2 = 0.999; epsilon = 1e-9; GNNDatum *gnndatum = new GNNDatum(graph->gnnctx, graph); // gnndatum->random_generate(); if (0 == graph->config->feature_file.compare("random")) { gnndatum->random_generate(); } else { gnndatum->readFeature_Label_Mask(graph->config->feature_file, graph->config->label_file, graph->config->mask_file); } // creating tensor to save Label and Mask gnndatum->registLabel(L_GT_C); gnndatum->registMask(MASK); // initializeing parameter. Creating tensor with shape [layer_size[i], // layer_size[i + 1]] for (int i = 0; i < graph->gnnctx->layer_size.size() - 1; i++) { P.push_back(new Parameter(graph->gnnctx->layer_size[i], graph->gnnctx->layer_size[i + 1], alpha, beta1, beta2, epsilon, weight_decay)); } // synchronize parameter with other processes // because we need to guarantee all of workers are using the same model for (int i = 0; i < P.size(); i++) { P[i]->init_parameter(); P[i]->set_decay(decay_rate, decay_epoch); } drpmodel = torch::nn::Dropout( torch::nn::DropoutOptions().p(drop_rate).inplace(true)); F = graph->Nts->NewLeafTensor( gnndatum->local_feature, {graph->gnnctx->l_v_num, graph->gnnctx->layer_size[0]}, torch::DeviceType::CPU); // X[i] is vertex representation at layer i for (int i = 0; i < graph->gnnctx->layer_size.size(); i++) { NtsVar d; X.push_back(d); } // X[0] is the initial vertex representation. We created it from // local_feature X[0] = F; } void Test(long s) { // 0 train, //1 eval //2 test NtsVar mask_train = MASK.eq(s); NtsVar all_train = X[graph->gnnctx->layer_size.size() - 1] .argmax(1) .to(torch::kLong) .eq(L_GT_C) .to(torch::kLong) .masked_select(mask_train.view({mask_train.size(0)})); NtsVar all = all_train.sum(0); long *p_correct = all.data_ptr<long>(); long g_correct = 0; long p_train = all_train.size(0); long g_train = 0; MPI_Datatype dt = get_mpi_data_type<long>(); MPI_Allreduce(p_correct, &g_correct, 1, dt, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(&p_train, &g_train, 1, dt, MPI_SUM, MPI_COMM_WORLD); float acc_train = 0.0; if (g_train > 0) acc_train = float(g_correct) / g_train; if (graph->partition_id == 0) { if (s == 0) { LOG_INFO("Train Acc: %f %d %d", acc_train, g_train, g_correct); } else if (s == 1) { LOG_INFO("Eval Acc: %f %d %d", acc_train, g_train, g_correct); } else if (s == 2) { LOG_INFO("Test Acc: %f %d %d", acc_train, g_train, g_correct); } } } void Loss() { // return torch::nll_loss(a,L_GT_C); torch::Tensor a = X[graph->gnnctx->layer_size.size() - 1]; torch::Tensor mask_train = MASK.eq(0); loss = torch::nll_loss( a.masked_select(mask_train.expand({mask_train.size(0), a.size(1)})) .view({-1, a.size(1)}), L_GT_C.masked_select(mask_train.view({mask_train.size(0)}))); ctx->appendNNOp(a, loss); } void Update() { for (int i = 0; i < P.size(); i++) { // accumulate the gradient using all_reduce P[i]->all_reduce_to_gradient(P[i]->W.grad().cpu()); // update parameters with Adam optimizer P[i]->learnC2C_with_decay_Adam(); P[i]->next(); } } void test_mirror() { graph->rtminfo->forward = true; for (int i = 0; i < graph->gnnctx->layer_size.size() - 1; i++) { graph->rtminfo->curr_layer = i; if(i==0){ // int testid=2707; for(VertexId val=graph->partition_offset[graph->partition_id];val<graph->partition_offset[graph->partition_id+1];val++) X[i][val-graph->partition_offset[graph->partition_id]][10]=(float)(val); // LOG_INFO("X_i[0][10](%f, %f)",X[i][testid][0]); //test mirror NtsVar mirror= ctx->runGraphOp<nts::op::DistGetDepNbrOp>(partitioned_graph,active,X[i]); NtsVar x_trans=X[i].cuda(); NtsVar mirror_gpu= ctx->runGraphOp<nts::op::DistGPUGetDepNbrOp>(partitioned_graph,active,x_trans); //NtsVar test_mirror_forward=torch::cat({mirror.slice(1,10,11,1),mirror_gpu.cpu().slice(1,10,11,1)},1); // NtsVar mirror.slice(1,10,11,1).eq(mirror_gpu.cpu().slice(1,10,11,1)).sum(0); partitioned_graph->SyncAndLog("sync test DistGPUGetDepNbrOp forward: 1 is passed"); std::cout<<mirror.slice(1,10,11,1).eq(mirror_gpu.cpu().slice(1,10,11,1)).sum(0).eq(mirror.size(0))<<std::endl; NtsVar x_back_cuda=ctx->ntsOp.top().op->backward(mirror_gpu); ctx->pop_one_op(); NtsVar x_back=ctx->ntsOp.top().op->backward(mirror); partitioned_graph->SyncAndLog("sync test DistGPUGetDepNbrOp backward: 1 is passed"); std::cout<<x_back.slice(1,10,11,1).eq(x_back_cuda.cpu().slice(1,10,11,1)).sum(0).eq(x_back.size(0))<<std::endl; } } } void test_scatter_src() { graph->rtminfo->forward = true; for (int i = 0; i < graph->gnnctx->layer_size.size() - 1; i++) { graph->rtminfo->curr_layer = i; if(i==0){ // int testid=2707; for(VertexId val=graph->partition_offset[graph->partition_id];val<graph->partition_offset[graph->partition_id+1];val++) X[i][val-graph->partition_offset[graph->partition_id]][10]=(float)(val); NtsVar mirror= ctx->runGraphOp<nts::op::DistGetDepNbrOp>(partitioned_graph,active,X[i]); //test DistScatterSrc NtsVar mirror_gpu=mirror.cuda(); NtsVar edge_src=ctx->runGraphOp<nts::op::DistScatterSrc>(partitioned_graph,active,mirror); NtsVar edge_src_gpu= ctx->runGraphOp<nts::op::DistGPUScatterSrc>(partitioned_graph,active,mirror_gpu); partitioned_graph->SyncAndLog("sync test DistGPUScatterSrc forward: 1 is passed"); std::cout<<edge_src.slice(1,10,11,1).eq(edge_src_gpu.cpu().slice(1,10,11,1)).sum(0).eq(edge_src.size(0))<<std::endl; NtsVar x_back_cuda=ctx->ntsOp.top().op->backward(edge_src_gpu); ctx->pop_one_op(); NtsVar x_back=ctx->ntsOp.top().op->backward(edge_src); partitioned_graph->SyncAndLog("sync test DistGPUScatterSrc backward: 1 is passed"); std::cout<<x_back.slice(1,10,11,1).eq(x_back_cuda.cpu().slice(1,10,11,1)).sum(0).eq(x_back.size(0))<<std::endl; } } } void test_scatter_dst() { graph->rtminfo->forward = true; for (int i = 0; i < graph->gnnctx->layer_size.size() - 1; i++) { graph->rtminfo->curr_layer = i; if(i==0){ // int testid=2707; for(VertexId val=graph->partition_offset[graph->partition_id];val<graph->partition_offset[graph->partition_id+1];val++) for(VertexId j=0;j<X[i].size(1);j++) X[i][val-graph->partition_offset[graph->partition_id]][j]=(float)(val); partitioned_graph->SyncAndLog("sync"); //test DistScatterDst NtsVar X_i_gpu=X[i].cuda(); NtsVar edge_dst= ctx->runGraphOp<nts::op::DistScatterDst>(partitioned_graph,active,X[i]); NtsVar edge_dst_gpu= ctx->runGraphOp<nts::op::DistGPUScatterDst>(partitioned_graph,active,X_i_gpu); partitioned_graph->SyncAndLog("sync test DistGPUScatterDst forward: 1 is passed"); std::cout<<edge_dst.eq(edge_dst_gpu.cpu()).sum(0).sum(0).eq(edge_dst.size(0)*edge_dst.size(1))<<std::endl; NtsVar x_back_cuda=ctx->ntsOp.top().op->backward(edge_dst_gpu); ctx->pop_one_op(); NtsVar x_back=ctx->ntsOp.top().op->backward(edge_dst); partitioned_graph->SyncAndLog("sync test DistGPUScatterDst backward: 1 is passed"); std::cout<<x_back.eq(x_back_cuda.cpu()).sum(0).sum(0).eq(x_back.size(0)*x_back.size(1))<<std::endl; } } } void test_gather_dst() { graph->rtminfo->forward = true; for (int i = 0; i < graph->gnnctx->layer_size.size() - 1; i++) { graph->rtminfo->curr_layer = i; if(i==0){ // int testid=2707; for(VertexId val=graph->partition_offset[graph->partition_id];val<graph->partition_offset[graph->partition_id+1];val++) for(VertexId j=0;j<X[i].size(1);j++) X[i][val-graph->partition_offset[graph->partition_id]][j]=(float)(val); //test DistScatterDst NtsVar X_i_gpu=X[i].cuda(); NtsVar edge_dst= ctx->runGraphOp<nts::op::DistScatterDst>(partitioned_graph,active,X[i]); NtsVar edge_dst_gpu= ctx->runGraphOp<nts::op::DistGPUScatterDst>(partitioned_graph,active,X_i_gpu); NtsVar dst_y= ctx->runGraphOp<nts::op::DistAggregateDst>(partitioned_graph,active,edge_dst); NtsVar dst_y_gpu= ctx->runGraphOp<nts::op::DistGPUAggregateDst>(partitioned_graph,active,edge_dst_gpu); partitioned_graph->SyncAndLog("sync test DistGPUAggregateDst forward: 1 is passed"); std::cout<<dst_y.eq(dst_y_gpu.cpu()).sum(0).sum(0).eq(dst_y.size(0)*dst_y.size(1))<<std::endl; NtsVar x_back_cuda=ctx->ntsOp.top().op->backward(dst_y_gpu); ctx->pop_one_op(); NtsVar x_back=ctx->ntsOp.top().op->backward(dst_y); partitioned_graph->SyncAndLog("sync test DistGPUAggregateDst backward: 1 is passed"); std::cout<<x_back.eq(x_back_cuda.cpu()).sum(0).sum(0).eq(x_back.size(0)*x_back.size(1))<<std::endl; } } } void test_softmax() { graph->rtminfo->forward = true; for (int i = 0; i < graph->gnnctx->layer_size.size() - 1; i++) { graph->rtminfo->curr_layer = i; if(i==0){ // int testid=2707; for(VertexId val=graph->partition_offset[graph->partition_id];val<graph->partition_offset[graph->partition_id+1];val++) X[i][val-graph->partition_offset[graph->partition_id]][10]=(float)(val); //test DistScatterDst NtsVar X_i_gpu=X[i].cuda(); NtsVar edge_dst= ctx->runGraphOp<nts::op::DistScatterDst>(partitioned_graph,active,X[i]); NtsVar m=torch::ones({edge_dst.size(0),1}); for(VertexId val=0;val< m.size(0);val++) m[val][0]=(float)(1); NtsVar m_gpu=m.cuda(); NtsVar a=ctx->runGraphOp<nts::op::DistEdgeSoftMax>(partitioned_graph,active,m); NtsVar a_gpu=ctx->runGraphOp<nts::op::DistGPUEdgeSoftMax>(partitioned_graph,active,m_gpu); NtsVar test_mirror_forward=torch::cat({a,a_gpu.cpu()},1); // std::cout<<test_mirror_forward.slice(0,1119,2200,1)<<std::endl; partitioned_graph->SyncAndLog("sync test DistGPUEdgeSoftMax forward: 1 is passed"); std::cout<<torch::abs(a-a_gpu.cpu()).le(0.0000001).sum(0).eq(a.size(0))<<std::endl; //std::cout<<a.size(0)<<" "<<a.eq(a_gpu.cpu()).sum(0)<<std::endl; NtsVar x_back_cuda=ctx->ntsOp.top().op->backward(m_gpu); ctx->pop_one_op(); NtsVar x_back=ctx->ntsOp.top().op->backward(m); partitioned_graph->SyncAndLog("sync test DistGPUEdgeSoftMax backward: 1 is passed"); // std::cout<<(x_back-x_back_cuda.cpu()).slice(0,0,6,1)<<std::endl; std::cout<<torch::abs(x_back-x_back_cuda.cpu()).le(0.0000001).sum(0).eq(x_back.size(0))<<std::endl; } } } void run() { if (graph->partition_id == 0) { LOG_INFO("GNNmini::[Dist.GPU.GCNimpl] running [%d] Epoches\n", iterations); } exec_time -= get_time(); for (int i_i = 0; i_i < 1; i_i++) { graph->rtminfo->epoch = i_i; //test_mirror(); //test_scatter_src(); //test_scatter_dst(); test_gather_dst(); //test_softmax(); if (graph->partition_id == 0) std::cout << "Nts::Running.Epoch[" << i_i << "]:loss\t" << loss << std::endl; } // NtsVar s=torch::ones({3,3}); // NtsVar d=torch::zeros({3,3}); // NtsVar l= test(d); // printf("%ld %ld\n", &l, &d); delete active; } };
40.796089
127
0.618624
Sanzo00
72b753174f178dea0751c9c0a76a2c4e7cd18284
3,502
cpp
C++
src/nfchandler.cpp
YuzukiTsuru/AmiiboTap
ceb8dd57fd87d30078e9927c87cbc80da4239376
[ "BSD-3-Clause" ]
null
null
null
src/nfchandler.cpp
YuzukiTsuru/AmiiboTap
ceb8dd57fd87d30078e9927c87cbc80da4239376
[ "BSD-3-Clause" ]
1
2021-10-21T12:05:07.000Z
2021-11-05T07:40:29.000Z
src/nfchandler.cpp
YuzukiTsuru/AmiiboTap
ceb8dd57fd87d30078e9927c87cbc80da4239376
[ "BSD-3-Clause" ]
null
null
null
#include <ColorCout.hpp> #include "nfchandler.h" NFCHandler::NFCHandler() { std::cout << cc::cyan << "Initializing NFC adapter" << cc::reset << std::endl; // init nfc nfc_init(&context); if (!context) { std::cout << cc::red << "Unable to init libnfc (malloc)" << cc::reset << std::endl; throw nfc_init_fault(); } device = nfc_open(context, nullptr); if (device == nullptr) { std::cout << cc::red << "Unable to open NFC device." << cc::reset << std::endl; throw nfc_not_found(); } nfc_initiator_init(device); std::cout << cc::green << "NFC Reader: OPENED, DO NOT DISCONNECT" << cc::reset << std::endl; } void NFCHandler::read_tag_UUID(AMIIBIN uuidBuffer[]) { std::cout << cc::cyan << "Scaning TAG..." << cc::reset << std::endl; if (nfc_initiator_select_passive_target(device, nmMifare, nullptr, 0, &target) > 0) { size_t uidSize = target.nti.nai.szUidLen; std::cout << cc::cyan << "Read UID: " << cc::yellow; for (int i = 0; i < uidSize; i++) { std::cout << " " << +target.nti.nai.abtUid[i]; } std::cout << cc::reset << std::endl; if (UUID_SIZE != uidSize) { std::cout << cc::red << "Read wrong size UID" << cc::reset << std::endl; } for (int i = 0; i < UUID_SIZE; ++i) { uuidBuffer[i] = target.nti.nai.abtUid[i]; } } } void NFCHandler::write_amiibo(Amiibo amiibo) { AMIIBIN uuid[UUID_SIZE]; read_tag_UUID(uuid); amiibo.set_UUID(uuid); write_buffer(amiibo.get_amiibo_data()); } void NFCHandler::write_buffer(const AMIIBIN *buffer) { std::cout << cc::cyan << "Writing tag..." << cc::reset << std::endl; write_data_pages(buffer); write_dynamic_lock_bytes(); write_static_lock_bytes(); std::cout << cc::cyan << "Finished writing tag." << cc::reset << std::endl; } void NFCHandler::write_data_pages(const AMIIBIN *buffer) { std::cout << cc::cyan << "Writing encrypted bin..." << cc::reset << std::endl; for (AMIIBIN i = 3; i < PAGE_COUNT; i++) { write_page(i, buffer + (i * 4)); } std::cout << cc::cyan << "Writing encrypted bin done." << cc::reset << std::endl; } void NFCHandler::write_dynamic_lock_bytes() { std::cout << cc::cyan << "Writing dynamic lock bytes..." << cc::reset << std::endl; write_page(130, dynamic_lock_bytes); std::cout << cc::cyan << "Writing dynamic lock bytes done." << cc::reset << std::endl; } void NFCHandler::write_static_lock_bytes() { std::cout << cc::cyan << "Writing static lock bytes..." << cc::reset << std::endl; write_page(2, static_lock_bytes); std::cout << cc::cyan << "Writing static lock bytes done." << cc::reset << std::endl; } void NFCHandler::write_page(AMIIBIN page, const AMIIBIN *buffer) { // +page http://cpp.indi.frih.net/blog/2014/09/tippet-printing-numeric-values-for-chars-and-AMIIBIN/ std::cout << cc::cyan << "Writing to " << cc::magenta << +page << cc::reset; std::cout << " " << cc::yellow << +buffer[0] << " " << +buffer[1] << " " << +buffer[2] << " " << +buffer[3] << cc::reset << std::endl; AMIIBIN sendData[6] = {WRITE_COMMAND, page, buffer[0], buffer[1], buffer[2], buffer[3]}; if (!nfc_initiator_transceive_bytes(device, sendData, 6, nullptr, 0, 0)) { std::cout << cc::green << "done." << cc::reset << std::endl; } else { throw amiibo_write_error(nfc_strerror(device)); } }
34.673267
104
0.584809
YuzukiTsuru
72b7d6bd60fa0c0510d3dd698c0d4bed63131ce0
3,151
cpp
C++
src/unittest/AlgorithmsTest.cpp
szekizoli/graphlib
2be4790024c20f2e2ad3b96010efa1e8aa35907c
[ "MIT" ]
null
null
null
src/unittest/AlgorithmsTest.cpp
szekizoli/graphlib
2be4790024c20f2e2ad3b96010efa1e8aa35907c
[ "MIT" ]
null
null
null
src/unittest/AlgorithmsTest.cpp
szekizoli/graphlib
2be4790024c20f2e2ad3b96010efa1e8aa35907c
[ "MIT" ]
null
null
null
#include "GraphLibTestUtils.h" #include <iostream> #include "GraphTestHelper.h" #include "graph\Algorithms.h" #include "graph\Graph.h" #include "graph\GraphBuilder.h" #include "graph\Node.h" #include "graph\function\Function.h" namespace GraphLibraryTest { using namespace graphlib::graph; using namespace graphlib::graph::function; TEST(algorithmsTests, TestCreateTopologicalSort) { CREATE_MEMORY_SNAPSHOT{ Graph g = createTestGraph(); unsigned expected_size = 0; auto order = algorithms::topologicalSort<Graph, Node>(g); EXPECT_EQ(2, order.size()); EXPECT_EQ(Label{ L"const"}, order[0]->label()); EXPECT_EQ(Label{ L"oppos"}, order[1]->label()); } ASSERT_MEMORY_SNAPSHOT } TEST(algorithmsTests, TestCreatePredecessorCountWithEmptyGraph) { CREATE_MEMORY_SNAPSHOT{ Graph g = GraphBuilder{}.build(); auto count = algorithms::predecessorCount<Graph, Node>(g); EXPECT_EQ(g.size(), count.size()); } ASSERT_MEMORY_SNAPSHOT } TEST(algorithmsTests, TestCreatePredecessorCountWithTestGraph) { CREATE_MEMORY_SNAPSHOT{ Graph g = createTestGraph(); auto count = algorithms::predecessorCount<Graph, Node>(g); EXPECT_EQ(g.order(), count.size()); EXPECT_EQ(0, count[0]); EXPECT_EQ(1, count[1]); } ASSERT_MEMORY_SNAPSHOT } TEST(algorithmsTests, TestCountWithTestGraph) { CREATE_MEMORY_SNAPSHOT{ Graph g = createTestGraph(); auto count = algorithms::count<Graph, Node>(g, [](const Node& n) {return n.predecessorSize(); }); EXPECT_EQ(g.order(), count.size()); EXPECT_EQ(0, count[0]); EXPECT_EQ(1, count[1]); } ASSERT_MEMORY_SNAPSHOT } TEST(algorithmsTests, TestCountWithTestGraphSuccessor) { CREATE_MEMORY_SNAPSHOT{ Graph g = createTestGraph(); auto count = algorithms::count<Graph, Node>(g, [](const Node& n) {return n.successorSize(); }); EXPECT_EQ(g.order(), count.size()); EXPECT_EQ(1, count[0]); EXPECT_EQ(0, count[1]); } ASSERT_MEMORY_SNAPSHOT } TEST(algorithmsTests, TestCreatePredecessorCountWithQuadraticGraph) { CREATE_MEMORY_SNAPSHOT{ Graph g = createQuadraticGraph(); auto count = algorithms::predecessorCount<Graph, Node>(g); EXPECT_EQ(g.order(), count.size()); for (unsigned i = 0; i < g.order(); ++i) { EXPECT_EQ(g[i].predecessorSize(), count[i]); } } ASSERT_MEMORY_SNAPSHOT } TEST(algorithmsTests, TestStackSort) { CREATE_MEMORY_SNAPSHOT{ Graph g = createMultiOutputGraph(); auto order = algorithms::stackSort<Graph, Node>(g); EXPECT_EQ(g.order(), order.size()); for (const auto& n : order) { std::wcout << n->label() << std::endl; } } ASSERT_MEMORY_SNAPSHOT } TEST(algorithmsTests, CreateTopologicalSortQuadraticGraph) { CREATE_MEMORY_SNAPSHOT{ Graph g = createQuadraticGraph(); unsigned expected_size = 0; auto order = algorithms::topologicalSort<Graph, Node>(g); EXPECT_EQ(17, order.size()); auto count = algorithms::predecessorCount<Graph, Node>(g); for (const auto& n : order) { EXPECT_EQ(0, count[n->id()]);// the predecessors left for this is 0. // decrement number of predecessors for successors for (const auto& s : n->successors()) { --count[s->id()]; } } } ASSERT_MEMORY_SNAPSHOT } }
30.592233
99
0.715011
szekizoli
72bbfc2087c1d269c123beda08d082c88453644f
3,034
hh
C++
benchmarks/solvers/minizinc/include/minizinc/chain_compressor.hh
95A31/MDD-LNS
9b78143e13ce8b3916bf3cc9662d9cbfe63fd7c7
[ "MIT" ]
null
null
null
benchmarks/solvers/minizinc/include/minizinc/chain_compressor.hh
95A31/MDD-LNS
9b78143e13ce8b3916bf3cc9662d9cbfe63fd7c7
[ "MIT" ]
null
null
null
benchmarks/solvers/minizinc/include/minizinc/chain_compressor.hh
95A31/MDD-LNS
9b78143e13ce8b3916bf3cc9662d9cbfe63fd7c7
[ "MIT" ]
null
null
null
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Jip J. Dekker <jip.dekker@monash.edu> */ /* 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/. */ #pragma once #include <minizinc/model.hh> #include <map> namespace MiniZinc { class ChainCompressor { public: ChainCompressor(EnvI& env, Model& m, std::vector<VarDecl*>& deletedVarDecls) : _env(env), _m(m), _deletedVarDecls(deletedVarDecls){}; virtual bool trackItem(Item* i) = 0; virtual void compress() = 0; protected: EnvI& _env; Model& _m; std::vector<VarDecl*>& _deletedVarDecls; std::multimap<VarDecl*, Item*> _items; typedef std::multimap<VarDecl*, Item*>::iterator iterator; void storeItem(VarDecl* v, Item* i) { _items.emplace(v, i); } void updateCount(); unsigned long count(VarDecl* v) { return _items.count(v); } std::pair<iterator, iterator> find(VarDecl* v) { return _items.equal_range(v); }; void removeItem(Item* i); int addItem(Item* i); // Replaces the Nth argument of a Call c by Expression e, c must be located on Item i void replaceCallArgument(Item* i, Call* c, unsigned int n, Expression* e); }; class ImpCompressor : public ChainCompressor { public: ImpCompressor(EnvI& env, Model& m, std::vector<VarDecl*>& deletedVarDecls, std::vector<int>& boolConstraints0) : ChainCompressor(env, m, deletedVarDecls), _boolConstraints(boolConstraints0){}; bool trackItem(Item* i) override; void compress() override; protected: std::vector<int>& _boolConstraints; // Compress two implications. e.g. (x -> y) /\ (y -> z) => x -> z // In this case i: (y -> z), newLHS: x // Function returns true if compression was successful (and the implication that contains newLHS // can be removed) Side effect: Item i might be removed. bool compressItem(Item* i, VarDecl* newLHS); // Constructs a clause constraint item with pos and neg as parameters. // if pos/neg are not ArrayLit then they will inserted into an ArrayLit. ConstraintI* constructClause(Expression* pos, Expression* neg); ConstraintI* constructHalfReif(Call* call, Id* control); }; class LECompressor : public ChainCompressor { public: LECompressor(EnvI& env, Model& m, std::vector<VarDecl*>& deletedVarDecls) : ChainCompressor(env, m, deletedVarDecls){}; bool trackItem(Item* i) override; void compress() override; protected: std::map<VarDecl*, VarDecl*> _aliasMap; /// Replace the use a variable within an inequality /// e.g. i: int_lin_le([1,2,3], [a,b,c], 10), oldVar: a, newVar d -> int_lin_le([1,2,3], [d,b,c], /// 10) Occurrence count is updated for variables involved. template <class Lit> void leReplaceVar(Item* i, VarDecl* oldVar, VarDecl* newVar); /// Check if the bounds of two Variables are equal bool eqBounds(Expression* a, Expression* b); }; } // namespace MiniZinc
30.039604
99
0.689519
95A31
72bc188cff3736eb2054c864007c1eb426d48644
23,777
cpp
C++
data/converted/genre__demoscene_svg.cpp
AdoPi/custom-es-fork
49d23b57173612531fdf0f1c996592fb161df779
[ "MIT" ]
null
null
null
data/converted/genre__demoscene_svg.cpp
AdoPi/custom-es-fork
49d23b57173612531fdf0f1c996592fb161df779
[ "MIT" ]
null
null
null
data/converted/genre__demoscene_svg.cpp
AdoPi/custom-es-fork
49d23b57173612531fdf0f1c996592fb161df779
[ "MIT" ]
null
null
null
// this file was auto-generated from "demoscene.svg" by res2h #include "../Resources.h" const uint16_t genre__demoscene_svg_size = 4288; const uint8_t genre__demoscene_svg_data[4288] = { 0x3c,0x3f,0x78,0x6d,0x6c,0x20,0x76,0x65,0x72,0x73, 0x69,0x6f,0x6e,0x3d,0x22,0x31,0x2e,0x30,0x22,0x20, 0x73,0x74,0x61,0x6e,0x64,0x61,0x6c,0x6f,0x6e,0x65, 0x3d,0x22,0x6e,0x6f,0x22,0x3f,0x3e,0x0a,0x3c,0x21, 0x44,0x4f,0x43,0x54,0x59,0x50,0x45,0x20,0x73,0x76, 0x67,0x20,0x50,0x55,0x42,0x4c,0x49,0x43,0x20,0x22, 0x2d,0x2f,0x2f,0x57,0x33,0x43,0x2f,0x2f,0x44,0x54, 0x44,0x20,0x53,0x56,0x47,0x20,0x32,0x30,0x30,0x31, 0x30,0x39,0x30,0x34,0x2f,0x2f,0x45,0x4e,0x22,0x0a, 0x20,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77, 0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f, 0x54,0x52,0x2f,0x32,0x30,0x30,0x31,0x2f,0x52,0x45, 0x43,0x2d,0x53,0x56,0x47,0x2d,0x32,0x30,0x30,0x31, 0x30,0x39,0x30,0x34,0x2f,0x44,0x54,0x44,0x2f,0x73, 0x76,0x67,0x31,0x30,0x2e,0x64,0x74,0x64,0x22,0x3e, 0x0a,0x3c,0x73,0x76,0x67,0x20,0x76,0x65,0x72,0x73, 0x69,0x6f,0x6e,0x3d,0x22,0x31,0x2e,0x30,0x22,0x20, 0x78,0x6d,0x6c,0x6e,0x73,0x3d,0x22,0x68,0x74,0x74, 0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x77,0x33, 0x2e,0x6f,0x72,0x67,0x2f,0x32,0x30,0x30,0x30,0x2f, 0x73,0x76,0x67,0x22,0x0a,0x20,0x77,0x69,0x64,0x74, 0x68,0x3d,0x22,0x34,0x31,0x34,0x2e,0x33,0x31,0x32, 0x30,0x39,0x33,0x70,0x74,0x22,0x20,0x68,0x65,0x69, 0x67,0x68,0x74,0x3d,0x22,0x34,0x31,0x36,0x2e,0x33, 0x30,0x32,0x38,0x35,0x31,0x70,0x74,0x22,0x20,0x76, 0x69,0x65,0x77,0x42,0x6f,0x78,0x3d,0x22,0x30,0x20, 0x30,0x20,0x34,0x31,0x34,0x2e,0x33,0x31,0x32,0x30, 0x39,0x33,0x20,0x34,0x31,0x36,0x2e,0x33,0x30,0x32, 0x38,0x35,0x31,0x22,0x0a,0x20,0x70,0x72,0x65,0x73, 0x65,0x72,0x76,0x65,0x41,0x73,0x70,0x65,0x63,0x74, 0x52,0x61,0x74,0x69,0x6f,0x3d,0x22,0x78,0x4d,0x69, 0x64,0x59,0x4d,0x69,0x64,0x20,0x6d,0x65,0x65,0x74, 0x22,0x3e,0x0a,0x3c,0x6d,0x65,0x74,0x61,0x64,0x61, 0x74,0x61,0x3e,0x0a,0x43,0x72,0x65,0x61,0x74,0x65, 0x64,0x20,0x62,0x79,0x20,0x70,0x6f,0x74,0x72,0x61, 0x63,0x65,0x20,0x31,0x2e,0x31,0x33,0x2c,0x20,0x77, 0x72,0x69,0x74,0x74,0x65,0x6e,0x20,0x62,0x79,0x20, 0x50,0x65,0x74,0x65,0x72,0x20,0x53,0x65,0x6c,0x69, 0x6e,0x67,0x65,0x72,0x20,0x32,0x30,0x30,0x31,0x2d, 0x32,0x30,0x31,0x35,0x0a,0x3c,0x2f,0x6d,0x65,0x74, 0x61,0x64,0x61,0x74,0x61,0x3e,0x0a,0x3c,0x67,0x20, 0x74,0x72,0x61,0x6e,0x73,0x66,0x6f,0x72,0x6d,0x3d, 0x22,0x74,0x72,0x61,0x6e,0x73,0x6c,0x61,0x74,0x65, 0x28,0x2d,0x34,0x39,0x2e,0x33,0x35,0x36,0x35,0x39, 0x38,0x2c,0x34,0x36,0x32,0x2e,0x36,0x33,0x34,0x31, 0x36,0x30,0x29,0x20,0x73,0x63,0x61,0x6c,0x65,0x28, 0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x2c,0x2d, 0x30,0x2e,0x31,0x30,0x30,0x30,0x30,0x30,0x29,0x22, 0x0a,0x66,0x69,0x6c,0x6c,0x3d,0x22,0x23,0x30,0x30, 0x30,0x30,0x30,0x30,0x22,0x20,0x73,0x74,0x72,0x6f, 0x6b,0x65,0x3d,0x22,0x6e,0x6f,0x6e,0x65,0x22,0x3e, 0x0a,0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22, 0x4d,0x32,0x32,0x39,0x30,0x20,0x34,0x36,0x32,0x34, 0x20,0x63,0x2d,0x31,0x34,0x20,0x2d,0x32,0x20,0x2d, 0x37,0x30,0x20,0x2d,0x31,0x31,0x20,0x2d,0x31,0x32, 0x35,0x20,0x2d,0x32,0x30,0x20,0x2d,0x33,0x31,0x30, 0x20,0x2d,0x34,0x39,0x20,0x2d,0x36,0x35,0x38,0x20, 0x2d,0x32,0x30,0x35,0x20,0x2d,0x39,0x31,0x30,0x20, 0x2d,0x34,0x30,0x37,0x0a,0x2d,0x37,0x36,0x20,0x2d, 0x36,0x32,0x20,0x2d,0x32,0x37,0x30,0x20,0x2d,0x32, 0x35,0x34,0x20,0x2d,0x33,0x33,0x34,0x20,0x2d,0x33, 0x33,0x32,0x20,0x2d,0x32,0x31,0x35,0x20,0x2d,0x32, 0x36,0x31,0x20,0x2d,0x33,0x36,0x34,0x20,0x2d,0x35, 0x38,0x35,0x20,0x2d,0x34,0x32,0x37,0x20,0x2d,0x39, 0x33,0x30,0x20,0x2d,0x32,0x37,0x20,0x2d,0x31,0x34, 0x36,0x20,0x2d,0x32,0x37,0x20,0x2d,0x36,0x33,0x34, 0x0a,0x30,0x20,0x2d,0x37,0x38,0x30,0x20,0x36,0x31, 0x20,0x2d,0x33,0x33,0x32,0x20,0x32,0x30,0x39,0x20, 0x2d,0x36,0x36,0x30,0x20,0x34,0x30,0x39,0x20,0x2d, 0x39,0x31,0x30,0x20,0x36,0x32,0x20,0x2d,0x37,0x36, 0x20,0x32,0x35,0x34,0x20,0x2d,0x32,0x37,0x30,0x20, 0x33,0x33,0x32,0x20,0x2d,0x33,0x33,0x34,0x20,0x32, 0x36,0x31,0x20,0x2d,0x32,0x31,0x35,0x20,0x35,0x38, 0x35,0x20,0x2d,0x33,0x36,0x34,0x0a,0x39,0x33,0x30, 0x20,0x2d,0x34,0x32,0x37,0x20,0x31,0x34,0x36,0x20, 0x2d,0x32,0x37,0x20,0x36,0x33,0x34,0x20,0x2d,0x32, 0x37,0x20,0x37,0x38,0x30,0x20,0x30,0x20,0x33,0x34, 0x35,0x20,0x36,0x33,0x20,0x36,0x36,0x39,0x20,0x32, 0x31,0x32,0x20,0x39,0x33,0x30,0x20,0x34,0x32,0x37, 0x20,0x37,0x38,0x20,0x36,0x34,0x20,0x32,0x37,0x30, 0x20,0x32,0x35,0x38,0x20,0x33,0x33,0x32,0x20,0x33, 0x33,0x34,0x0a,0x32,0x30,0x30,0x20,0x32,0x35,0x30, 0x20,0x33,0x34,0x38,0x20,0x35,0x37,0x38,0x20,0x34, 0x30,0x39,0x20,0x39,0x31,0x30,0x20,0x32,0x37,0x20, 0x31,0x34,0x36,0x20,0x32,0x37,0x20,0x36,0x33,0x34, 0x20,0x30,0x20,0x37,0x38,0x30,0x20,0x2d,0x36,0x31, 0x20,0x33,0x33,0x32,0x20,0x2d,0x32,0x30,0x39,0x20, 0x36,0x36,0x30,0x20,0x2d,0x34,0x30,0x39,0x20,0x39, 0x31,0x30,0x20,0x2d,0x36,0x32,0x0a,0x37,0x36,0x20, 0x2d,0x32,0x35,0x34,0x20,0x32,0x37,0x30,0x20,0x2d, 0x33,0x33,0x32,0x20,0x33,0x33,0x34,0x20,0x2d,0x32, 0x30,0x35,0x20,0x31,0x36,0x39,0x20,0x2d,0x34,0x36, 0x31,0x20,0x33,0x30,0x33,0x20,0x2d,0x37,0x31,0x35, 0x20,0x33,0x37,0x36,0x20,0x2d,0x32,0x30,0x36,0x20, 0x35,0x39,0x20,0x2d,0x32,0x37,0x37,0x20,0x36,0x38, 0x20,0x2d,0x35,0x37,0x35,0x20,0x37,0x31,0x0a,0x2d, 0x31,0x34,0x38,0x20,0x31,0x20,0x2d,0x32,0x38,0x31, 0x20,0x30,0x20,0x2d,0x32,0x39,0x35,0x20,0x2d,0x32, 0x7a,0x20,0x6d,0x35,0x37,0x20,0x2d,0x31,0x37,0x30, 0x20,0x63,0x2d,0x33,0x20,0x2d,0x33,0x20,0x2d,0x31, 0x32,0x20,0x2d,0x34,0x20,0x2d,0x31,0x39,0x20,0x2d, 0x31,0x20,0x2d,0x38,0x20,0x33,0x20,0x2d,0x35,0x20, 0x36,0x20,0x36,0x20,0x36,0x20,0x31,0x31,0x20,0x31, 0x20,0x31,0x37,0x0a,0x2d,0x32,0x20,0x31,0x33,0x20, 0x2d,0x35,0x7a,0x20,0x6d,0x2d,0x33,0x37,0x20,0x2d, 0x31,0x37,0x20,0x63,0x30,0x20,0x2d,0x31,0x33,0x20, 0x32,0x33,0x20,0x2d,0x32,0x33,0x20,0x32,0x31,0x33, 0x20,0x2d,0x38,0x39,0x20,0x6c,0x31,0x31,0x38,0x20, 0x2d,0x34,0x31,0x20,0x2d,0x33,0x33,0x20,0x2d,0x32, 0x30,0x20,0x63,0x2d,0x31,0x32,0x30,0x20,0x2d,0x37, 0x32,0x20,0x2d,0x33,0x35,0x36,0x0a,0x2d,0x32,0x39, 0x36,0x20,0x2d,0x34,0x36,0x33,0x20,0x2d,0x34,0x33, 0x39,0x20,0x2d,0x32,0x37,0x20,0x2d,0x33,0x37,0x20, 0x2d,0x35,0x36,0x20,0x2d,0x36,0x37,0x20,0x2d,0x36, 0x33,0x20,0x2d,0x36,0x38,0x20,0x2d,0x31,0x32,0x20, 0x30,0x20,0x2d,0x35,0x32,0x34,0x20,0x31,0x38,0x34, 0x20,0x2d,0x35,0x34,0x39,0x20,0x31,0x39,0x39,0x20, 0x2d,0x31,0x31,0x20,0x36,0x20,0x2d,0x31,0x20,0x31, 0x39,0x0a,0x33,0x39,0x20,0x35,0x33,0x20,0x31,0x39, 0x31,0x20,0x31,0x36,0x33,0x20,0x34,0x34,0x36,0x20, 0x33,0x30,0x39,0x20,0x36,0x35,0x31,0x20,0x33,0x37, 0x34,0x20,0x33,0x31,0x20,0x31,0x30,0x20,0x35,0x37, 0x20,0x32,0x34,0x20,0x35,0x37,0x20,0x33,0x31,0x20, 0x30,0x20,0x37,0x20,0x37,0x20,0x31,0x33,0x20,0x31, 0x35,0x20,0x31,0x33,0x20,0x38,0x20,0x30,0x20,0x31, 0x35,0x20,0x2d,0x36,0x20,0x31,0x35,0x0a,0x2d,0x31, 0x33,0x7a,0x20,0x6d,0x38,0x34,0x38,0x20,0x2d,0x36, 0x37,0x20,0x63,0x32,0x33,0x20,0x2d,0x37,0x20,0x34, 0x32,0x20,0x2d,0x31,0x39,0x20,0x34,0x32,0x20,0x2d, 0x32,0x35,0x20,0x30,0x20,0x2d,0x37,0x20,0x2d,0x31, 0x36,0x20,0x2d,0x35,0x36,0x20,0x2d,0x33,0x36,0x20, 0x2d,0x31,0x30,0x38,0x20,0x6c,0x2d,0x33,0x36,0x20, 0x2d,0x39,0x35,0x20,0x2d,0x39,0x37,0x20,0x33,0x34, 0x0a,0x63,0x2d,0x32,0x32,0x30,0x20,0x37,0x39,0x20, 0x2d,0x33,0x35,0x31,0x20,0x31,0x32,0x39,0x20,0x2d, 0x33,0x35,0x31,0x20,0x31,0x33,0x35,0x20,0x30,0x20, 0x37,0x20,0x31,0x32,0x30,0x20,0x36,0x32,0x20,0x31, 0x37,0x30,0x20,0x37,0x38,0x20,0x31,0x30,0x36,0x20, 0x33,0x33,0x20,0x31,0x34,0x33,0x20,0x33,0x30,0x20, 0x33,0x30,0x38,0x20,0x2d,0x31,0x39,0x7a,0x20,0x6d, 0x34,0x38,0x32,0x0a,0x2d,0x32,0x34,0x33,0x20,0x63, 0x31,0x31,0x35,0x20,0x2d,0x37,0x37,0x20,0x32,0x31, 0x30,0x20,0x2d,0x31,0x35,0x38,0x20,0x32,0x36,0x32, 0x20,0x2d,0x32,0x32,0x34,0x20,0x6c,0x34,0x37,0x20, 0x2d,0x36,0x30,0x20,0x2d,0x31,0x30,0x37,0x20,0x33, 0x39,0x20,0x63,0x2d,0x35,0x39,0x20,0x32,0x32,0x20, 0x2d,0x31,0x33,0x35,0x20,0x34,0x39,0x20,0x2d,0x31, 0x36,0x39,0x20,0x36,0x31,0x20,0x2d,0x33,0x35,0x0a, 0x31,0x32,0x20,0x2d,0x36,0x33,0x20,0x32,0x37,0x20, 0x2d,0x36,0x33,0x20,0x33,0x34,0x20,0x30,0x20,0x32, 0x35,0x20,0x2d,0x35,0x31,0x20,0x31,0x32,0x36,0x20, 0x2d,0x39,0x35,0x20,0x31,0x39,0x30,0x20,0x6c,0x2d, 0x34,0x36,0x20,0x36,0x36,0x20,0x34,0x38,0x20,0x2d, 0x32,0x38,0x20,0x63,0x32,0x36,0x20,0x2d,0x31,0x35, 0x20,0x38,0x32,0x20,0x2d,0x35,0x30,0x20,0x31,0x32, 0x33,0x20,0x2d,0x37,0x38,0x7a,0x0a,0x6d,0x2d,0x33, 0x31,0x36,0x20,0x2d,0x37,0x31,0x20,0x63,0x39,0x34, 0x20,0x2d,0x33,0x35,0x20,0x31,0x39,0x36,0x20,0x2d, 0x37,0x32,0x20,0x32,0x32,0x37,0x20,0x2d,0x38,0x31, 0x20,0x6c,0x35,0x37,0x20,0x2d,0x31,0x38,0x20,0x32, 0x31,0x20,0x2d,0x37,0x31,0x20,0x63,0x34,0x35,0x20, 0x2d,0x31,0x35,0x35,0x20,0x37,0x39,0x20,0x2d,0x34, 0x39,0x30,0x20,0x36,0x34,0x20,0x2d,0x36,0x32,0x37, 0x0a,0x6c,0x2d,0x38,0x20,0x2d,0x36,0x36,0x20,0x2d, 0x33,0x38,0x30,0x20,0x31,0x33,0x38,0x20,0x63,0x2d, 0x32,0x30,0x39,0x20,0x37,0x36,0x20,0x2d,0x33,0x38, 0x36,0x20,0x31,0x33,0x39,0x20,0x2d,0x33,0x39,0x34, 0x20,0x31,0x33,0x39,0x20,0x2d,0x37,0x20,0x30,0x20, 0x2d,0x31,0x31,0x20,0x36,0x20,0x2d,0x38,0x20,0x31, 0x33,0x20,0x32,0x20,0x36,0x20,0x35,0x35,0x20,0x31, 0x35,0x33,0x20,0x31,0x31,0x38,0x0a,0x33,0x32,0x35, 0x20,0x36,0x32,0x20,0x31,0x37,0x31,0x20,0x31,0x31, 0x38,0x20,0x33,0x31,0x32,0x20,0x31,0x32,0x33,0x20, 0x33,0x31,0x32,0x20,0x35,0x20,0x30,0x20,0x38,0x36, 0x20,0x2d,0x32,0x39,0x20,0x31,0x38,0x30,0x20,0x2d, 0x36,0x34,0x7a,0x20,0x6d,0x2d,0x31,0x39,0x30,0x35, 0x20,0x2d,0x35,0x32,0x20,0x6c,0x37,0x31,0x20,0x2d, 0x32,0x36,0x20,0x2d,0x38,0x33,0x20,0x2d,0x38,0x38, 0x0a,0x63,0x2d,0x39,0x38,0x20,0x2d,0x31,0x30,0x33, 0x20,0x2d,0x31,0x38,0x33,0x20,0x2d,0x32,0x31,0x33, 0x20,0x2d,0x32,0x36,0x30,0x20,0x2d,0x33,0x33,0x37, 0x20,0x2d,0x37,0x38,0x20,0x2d,0x31,0x32,0x38,0x20, 0x2d,0x31,0x33,0x30,0x20,0x2d,0x32,0x33,0x31,0x20, 0x2d,0x31,0x38,0x37,0x20,0x2d,0x33,0x38,0x30,0x20, 0x6c,0x2d,0x39,0x20,0x2d,0x32,0x31,0x20,0x2d,0x39, 0x32,0x20,0x33,0x34,0x0a,0x63,0x2d,0x35,0x31,0x20, 0x31,0x39,0x20,0x2d,0x39,0x34,0x20,0x33,0x36,0x20, 0x2d,0x39,0x36,0x20,0x33,0x38,0x20,0x2d,0x32,0x20, 0x32,0x20,0x31,0x36,0x20,0x34,0x38,0x20,0x34,0x30, 0x20,0x31,0x30,0x32,0x20,0x35,0x32,0x20,0x31,0x31, 0x38,0x20,0x31,0x34,0x34,0x20,0x32,0x37,0x34,0x20, 0x32,0x32,0x33,0x20,0x33,0x38,0x32,0x20,0x36,0x30, 0x20,0x38,0x30,0x20,0x32,0x39,0x34,0x0a,0x33,0x32, 0x32,0x20,0x33,0x31,0x32,0x20,0x33,0x32,0x32,0x20, 0x36,0x20,0x30,0x20,0x34,0x33,0x20,0x2d,0x31,0x32, 0x20,0x38,0x31,0x20,0x2d,0x32,0x36,0x7a,0x20,0x6d, 0x32,0x35,0x39,0x31,0x20,0x2d,0x32,0x30,0x36,0x20, 0x63,0x39,0x35,0x20,0x2d,0x31,0x30,0x31,0x20,0x32, 0x33,0x36,0x20,0x2d,0x33,0x33,0x30,0x20,0x33,0x31, 0x31,0x20,0x2d,0x35,0x30,0x34,0x20,0x34,0x38,0x0a, 0x2d,0x31,0x31,0x33,0x20,0x31,0x32,0x37,0x20,0x2d, 0x33,0x36,0x30,0x20,0x31,0x31,0x37,0x20,0x2d,0x33, 0x36,0x39,0x20,0x2d,0x33,0x20,0x2d,0x33,0x20,0x2d, 0x33,0x37,0x20,0x37,0x20,0x2d,0x37,0x36,0x20,0x32, 0x31,0x20,0x2d,0x36,0x38,0x20,0x32,0x35,0x20,0x2d, 0x37,0x32,0x20,0x32,0x39,0x20,0x2d,0x37,0x38,0x20, 0x36,0x33,0x20,0x2d,0x35,0x30,0x20,0x32,0x39,0x33, 0x20,0x2d,0x31,0x34,0x37,0x0a,0x35,0x36,0x35,0x20, 0x2d,0x32,0x36,0x37,0x20,0x37,0x35,0x34,0x20,0x2d, 0x33,0x39,0x20,0x36,0x31,0x20,0x2d,0x34,0x31,0x20, 0x37,0x31,0x20,0x2d,0x37,0x20,0x33,0x35,0x7a,0x20, 0x6d,0x2d,0x31,0x34,0x34,0x30,0x20,0x2d,0x32,0x31, 0x33,0x20,0x63,0x31,0x36,0x32,0x20,0x2d,0x35,0x39, 0x20,0x32,0x39,0x39,0x20,0x2d,0x31,0x31,0x31,0x20, 0x33,0x30,0x33,0x20,0x2d,0x31,0x31,0x35,0x20,0x37, 0x0a,0x2d,0x36,0x20,0x2d,0x33,0x30,0x33,0x20,0x2d, 0x38,0x38,0x34,0x20,0x2d,0x33,0x31,0x37,0x20,0x2d, 0x38,0x39,0x37,0x20,0x2d,0x33,0x20,0x2d,0x33,0x20, 0x2d,0x39,0x30,0x35,0x20,0x33,0x32,0x33,0x20,0x2d, 0x39,0x31,0x32,0x20,0x33,0x32,0x39,0x20,0x2d,0x35, 0x20,0x35,0x20,0x38,0x36,0x20,0x32,0x31,0x39,0x20, 0x31,0x34,0x36,0x20,0x33,0x34,0x35,0x20,0x36,0x35, 0x20,0x31,0x33,0x37,0x0a,0x31,0x34,0x33,0x20,0x32, 0x37,0x32,0x20,0x32,0x33,0x37,0x20,0x34,0x31,0x35, 0x20,0x6c,0x36,0x34,0x20,0x39,0x37,0x20,0x39,0x32, 0x20,0x2d,0x33,0x34,0x20,0x63,0x35,0x31,0x20,0x2d, 0x31,0x38,0x20,0x32,0x32,0x35,0x20,0x2d,0x38,0x31, 0x20,0x33,0x38,0x37,0x20,0x2d,0x31,0x34,0x30,0x7a, 0x20,0x6d,0x31,0x33,0x33,0x32,0x20,0x2d,0x34,0x38, 0x36,0x20,0x63,0x31,0x30,0x36,0x20,0x2d,0x33,0x39, 0x0a,0x32,0x33,0x34,0x20,0x2d,0x38,0x34,0x20,0x32, 0x38,0x35,0x20,0x2d,0x31,0x30,0x32,0x20,0x6c,0x39, 0x31,0x20,0x2d,0x33,0x31,0x20,0x38,0x20,0x2d,0x39, 0x36,0x20,0x63,0x31,0x37,0x20,0x2d,0x32,0x32,0x39, 0x20,0x2d,0x31,0x34,0x20,0x2d,0x35,0x31,0x33,0x20, 0x2d,0x38,0x32,0x20,0x2d,0x37,0x35,0x31,0x20,0x2d, 0x31,0x39,0x20,0x2d,0x36,0x36,0x20,0x2d,0x33,0x34, 0x20,0x2d,0x31,0x32,0x32,0x0a,0x2d,0x33,0x34,0x20, 0x2d,0x31,0x32,0x35,0x20,0x30,0x20,0x2d,0x31,0x31, 0x20,0x2d,0x34,0x37,0x20,0x34,0x20,0x2d,0x33,0x30, 0x30,0x20,0x39,0x37,0x20,0x2d,0x31,0x35,0x31,0x20, 0x35,0x35,0x20,0x2d,0x32,0x39,0x38,0x20,0x31,0x30, 0x38,0x20,0x2d,0x33,0x32,0x36,0x20,0x31,0x31,0x37, 0x20,0x6c,0x2d,0x35,0x31,0x20,0x31,0x36,0x20,0x31, 0x38,0x20,0x34,0x37,0x20,0x63,0x37,0x38,0x0a,0x32, 0x30,0x33,0x20,0x31,0x35,0x35,0x20,0x35,0x35,0x37, 0x20,0x31,0x38,0x34,0x20,0x38,0x33,0x37,0x20,0x34, 0x20,0x33,0x34,0x20,0x39,0x20,0x36,0x32,0x20,0x31, 0x31,0x20,0x36,0x32,0x20,0x32,0x20,0x30,0x20,0x39, 0x30,0x20,0x2d,0x33,0x32,0x20,0x31,0x39,0x36,0x20, 0x2d,0x37,0x31,0x7a,0x20,0x6d,0x2d,0x32,0x35,0x39, 0x37,0x20,0x2d,0x38,0x39,0x20,0x63,0x31,0x37,0x31, 0x20,0x2d,0x36,0x32,0x0a,0x33,0x31,0x32,0x20,0x2d, 0x31,0x31,0x34,0x20,0x33,0x31,0x34,0x20,0x2d,0x31, 0x31,0x36,0x20,0x32,0x20,0x2d,0x32,0x20,0x2d,0x31, 0x34,0x20,0x2d,0x36,0x31,0x20,0x2d,0x33,0x37,0x20, 0x2d,0x31,0x33,0x31,0x20,0x2d,0x37,0x36,0x20,0x2d, 0x32,0x33,0x36,0x20,0x2d,0x31,0x32,0x39,0x20,0x2d, 0x34,0x37,0x38,0x20,0x2d,0x31,0x35,0x32,0x20,0x2d, 0x37,0x30,0x33,0x20,0x2d,0x37,0x20,0x2d,0x35,0x38, 0x0a,0x2d,0x31,0x33,0x20,0x2d,0x31,0x30,0x36,0x20, 0x2d,0x31,0x34,0x20,0x2d,0x31,0x30,0x38,0x20,0x2d, 0x32,0x20,0x2d,0x31,0x20,0x2d,0x31,0x33,0x32,0x20, 0x34,0x34,0x20,0x2d,0x32,0x38,0x39,0x20,0x31,0x30, 0x30,0x20,0x6c,0x2d,0x32,0x38,0x35,0x20,0x31,0x30, 0x33,0x20,0x2d,0x38,0x20,0x39,0x35,0x20,0x63,0x2d, 0x31,0x36,0x20,0x32,0x32,0x31,0x20,0x31,0x35,0x20, 0x35,0x32,0x33,0x20,0x37,0x36,0x0a,0x37,0x33,0x30, 0x20,0x34,0x33,0x20,0x31,0x34,0x32,0x20,0x34,0x38, 0x20,0x31,0x35,0x33,0x20,0x36,0x38,0x20,0x31,0x34, 0x38,0x20,0x39,0x20,0x2d,0x33,0x20,0x31,0x35,0x37, 0x20,0x2d,0x35,0x36,0x20,0x33,0x32,0x37,0x20,0x2d, 0x31,0x31,0x38,0x7a,0x20,0x6d,0x31,0x36,0x33,0x36, 0x20,0x2d,0x35,0x39,0x36,0x20,0x63,0x32,0x30,0x36, 0x20,0x2d,0x37,0x35,0x20,0x34,0x31,0x30,0x0a,0x2d, 0x31,0x34,0x39,0x20,0x34,0x35,0x33,0x20,0x2d,0x31, 0x36,0x35,0x20,0x34,0x34,0x20,0x2d,0x31,0x36,0x20, 0x38,0x31,0x20,0x2d,0x33,0x30,0x20,0x38,0x32,0x20, 0x2d,0x33,0x32,0x20,0x37,0x20,0x2d,0x37,0x20,0x2d, 0x39,0x33,0x20,0x2d,0x32,0x33,0x38,0x20,0x2d,0x31, 0x37,0x31,0x20,0x2d,0x33,0x39,0x32,0x20,0x2d,0x38, 0x30,0x20,0x2d,0x31,0x35,0x38,0x20,0x2d,0x32,0x31, 0x31,0x0a,0x2d,0x33,0x37,0x39,0x20,0x2d,0x32,0x36, 0x32,0x20,0x2d,0x34,0x34,0x32,0x20,0x6c,0x2d,0x31, 0x38,0x20,0x2d,0x32,0x31,0x20,0x2d,0x33,0x39,0x30, 0x20,0x31,0x34,0x32,0x20,0x63,0x2d,0x33,0x31,0x37, 0x20,0x31,0x31,0x36,0x20,0x2d,0x33,0x39,0x30,0x20, 0x31,0x34,0x36,0x20,0x2d,0x33,0x38,0x38,0x20,0x31, 0x36,0x30,0x20,0x31,0x20,0x31,0x37,0x20,0x33,0x31, 0x34,0x20,0x38,0x38,0x36,0x0a,0x33,0x31,0x38,0x20, 0x38,0x38,0x36,0x20,0x32,0x20,0x30,0x20,0x31,0x37, 0x31,0x20,0x2d,0x36,0x31,0x20,0x33,0x37,0x36,0x20, 0x2d,0x31,0x33,0x36,0x7a,0x20,0x6d,0x2d,0x32,0x31, 0x34,0x39,0x20,0x2d,0x32,0x35,0x33,0x20,0x63,0x33, 0x32,0x20,0x2d,0x31,0x31,0x20,0x33,0x38,0x20,0x2d, 0x31,0x38,0x20,0x34,0x34,0x20,0x2d,0x34,0x39,0x20, 0x35,0x33,0x20,0x2d,0x33,0x30,0x36,0x20,0x31,0x34, 0x34,0x0a,0x2d,0x35,0x36,0x33,0x20,0x32,0x36,0x37, 0x20,0x2d,0x37,0x35,0x35,0x20,0x6c,0x33,0x37,0x20, 0x2d,0x35,0x37,0x20,0x2d,0x33,0x37,0x20,0x31,0x35, 0x20,0x63,0x2d,0x32,0x30,0x20,0x38,0x20,0x2d,0x34, 0x32,0x20,0x32,0x33,0x20,0x2d,0x35,0x30,0x20,0x33, 0x33,0x20,0x2d,0x31,0x35,0x33,0x20,0x31,0x39,0x36, 0x20,0x2d,0x32,0x38,0x31,0x20,0x34,0x34,0x36,0x20, 0x2d,0x33,0x34,0x38,0x0a,0x36,0x38,0x32,0x20,0x2d, 0x31,0x38,0x20,0x36,0x33,0x20,0x2d,0x33,0x35,0x20, 0x31,0x33,0x30,0x20,0x2d,0x33,0x38,0x20,0x31,0x34, 0x37,0x20,0x6c,0x2d,0x36,0x20,0x33,0x32,0x20,0x34, 0x37,0x20,0x2d,0x31,0x38,0x20,0x63,0x32,0x36,0x20, 0x2d,0x31,0x30,0x20,0x36,0x34,0x20,0x2d,0x32,0x34, 0x20,0x38,0x34,0x20,0x2d,0x33,0x30,0x7a,0x20,0x6d, 0x33,0x34,0x38,0x36,0x20,0x2d,0x32,0x33,0x33,0x0a, 0x63,0x39,0x35,0x20,0x2d,0x33,0x35,0x20,0x39,0x33, 0x20,0x2d,0x32,0x30,0x20,0x32,0x37,0x20,0x2d,0x31, 0x36,0x38,0x20,0x2d,0x35,0x31,0x20,0x2d,0x31,0x31, 0x35,0x20,0x2d,0x31,0x34,0x34,0x20,0x2d,0x32,0x37, 0x33,0x20,0x2d,0x32,0x32,0x32,0x20,0x2d,0x33,0x37, 0x38,0x20,0x2d,0x35,0x37,0x20,0x2d,0x37,0x37,0x20, 0x2d,0x32,0x34,0x34,0x20,0x2d,0x32,0x37,0x37,0x20, 0x2d,0x32,0x37,0x33,0x0a,0x2d,0x32,0x39,0x32,0x20, 0x2d,0x39,0x20,0x2d,0x35,0x20,0x2d,0x34,0x37,0x20, 0x34,0x20,0x2d,0x39,0x38,0x20,0x32,0x32,0x20,0x6c, 0x2d,0x38,0x33,0x20,0x33,0x30,0x20,0x38,0x33,0x20, 0x38,0x37,0x20,0x63,0x39,0x36,0x20,0x39,0x39,0x20, 0x31,0x35,0x30,0x20,0x31,0x36,0x38,0x20,0x32,0x33, 0x38,0x20,0x33,0x30,0x31,0x20,0x37,0x32,0x20,0x31, 0x30,0x39,0x20,0x31,0x36,0x39,0x20,0x32,0x39,0x39, 0x0a,0x31,0x39,0x36,0x20,0x33,0x38,0x33,0x20,0x31, 0x34,0x20,0x34,0x33,0x20,0x32,0x33,0x20,0x35,0x36, 0x20,0x33,0x34,0x20,0x35,0x31,0x20,0x38,0x20,0x2d, 0x33,0x20,0x35,0x32,0x20,0x2d,0x31,0x39,0x20,0x39, 0x38,0x20,0x2d,0x33,0x36,0x7a,0x20,0x6d,0x2d,0x32, 0x33,0x37,0x32,0x20,0x2d,0x31,0x37,0x32,0x20,0x63, 0x31,0x36,0x30,0x20,0x2d,0x35,0x38,0x20,0x32,0x39, 0x37,0x20,0x2d,0x31,0x30,0x36,0x0a,0x33,0x30,0x34, 0x20,0x2d,0x31,0x30,0x36,0x20,0x37,0x20,0x30,0x20, 0x31,0x30,0x20,0x2d,0x36,0x20,0x38,0x20,0x2d,0x31, 0x32,0x20,0x2d,0x33,0x20,0x2d,0x37,0x20,0x2d,0x35, 0x36,0x20,0x2d,0x31,0x35,0x34,0x20,0x2d,0x31,0x31, 0x39,0x20,0x2d,0x33,0x32,0x35,0x20,0x2d,0x36,0x32, 0x20,0x2d,0x31,0x37,0x32,0x20,0x2d,0x31,0x31,0x38, 0x20,0x2d,0x33,0x31,0x33,0x20,0x2d,0x31,0x32,0x33, 0x0a,0x2d,0x33,0x31,0x33,0x20,0x2d,0x35,0x20,0x30, 0x20,0x2d,0x38,0x36,0x20,0x32,0x39,0x20,0x2d,0x31, 0x38,0x30,0x20,0x36,0x34,0x20,0x2d,0x39,0x34,0x20, 0x33,0x35,0x20,0x2d,0x31,0x39,0x37,0x20,0x37,0x32, 0x20,0x2d,0x32,0x32,0x38,0x20,0x38,0x32,0x20,0x2d, 0x34,0x30,0x20,0x31,0x32,0x20,0x2d,0x35,0x38,0x20, 0x32,0x33,0x20,0x2d,0x36,0x33,0x20,0x33,0x38,0x20, 0x2d,0x32,0x30,0x20,0x37,0x30,0x0a,0x2d,0x34,0x35, 0x20,0x31,0x38,0x30,0x20,0x2d,0x35,0x34,0x20,0x32, 0x33,0x36,0x20,0x2d,0x31,0x38,0x20,0x31,0x31,0x32, 0x20,0x2d,0x33,0x31,0x20,0x33,0x34,0x31,0x20,0x2d, 0x32,0x34,0x20,0x34,0x32,0x37,0x20,0x6c,0x36,0x20, 0x38,0x31,0x20,0x39,0x31,0x20,0x2d,0x33,0x33,0x20, 0x63,0x35,0x30,0x20,0x2d,0x31,0x38,0x20,0x32,0x32, 0x32,0x20,0x2d,0x38,0x31,0x20,0x33,0x38,0x32,0x0a, 0x2d,0x31,0x33,0x39,0x7a,0x20,0x6d,0x31,0x34,0x30, 0x35,0x20,0x2d,0x35,0x31,0x32,0x20,0x63,0x31,0x34, 0x35,0x20,0x2d,0x35,0x32,0x20,0x32,0x37,0x30,0x20, 0x2d,0x39,0x39,0x20,0x32,0x37,0x38,0x20,0x2d,0x31, 0x30,0x33,0x20,0x31,0x30,0x20,0x2d,0x36,0x20,0x2d, 0x36,0x20,0x2d,0x32,0x35,0x20,0x2d,0x36,0x33,0x20, 0x2d,0x37,0x32,0x20,0x2d,0x31,0x37,0x37,0x20,0x2d, 0x31,0x34,0x36,0x0a,0x2d,0x33,0x39,0x38,0x20,0x2d, 0x32,0x37,0x33,0x20,0x2d,0x35,0x39,0x36,0x20,0x2d, 0x33,0x34,0x33,0x20,0x2d,0x35,0x32,0x20,0x2d,0x31, 0x39,0x20,0x2d,0x39,0x36,0x20,0x2d,0x33,0x38,0x20, 0x2d,0x39,0x38,0x20,0x2d,0x34,0x34,0x20,0x2d,0x31, 0x20,0x2d,0x35,0x20,0x31,0x30,0x20,0x2d,0x31,0x34, 0x20,0x32,0x35,0x20,0x2d,0x32,0x30,0x20,0x6c,0x32, 0x38,0x20,0x2d,0x31,0x30,0x20,0x2d,0x32,0x35,0x0a, 0x2d,0x36,0x20,0x63,0x2d,0x36,0x39,0x20,0x2d,0x31, 0x36,0x20,0x2d,0x31,0x39,0x36,0x20,0x2d,0x32,0x36, 0x20,0x2d,0x33,0x32,0x33,0x20,0x2d,0x32,0x35,0x20, 0x6c,0x2d,0x31,0x34,0x32,0x20,0x32,0x20,0x31,0x32, 0x36,0x20,0x38,0x20,0x63,0x36,0x39,0x20,0x34,0x20, 0x31,0x35,0x39,0x20,0x31,0x35,0x20,0x32,0x30,0x30, 0x20,0x32,0x33,0x20,0x34,0x31,0x20,0x39,0x20,0x37, 0x37,0x20,0x31,0x36,0x0a,0x38,0x32,0x20,0x31,0x36, 0x20,0x32,0x31,0x20,0x30,0x20,0x32,0x20,0x32,0x38, 0x20,0x2d,0x32,0x35,0x20,0x33,0x38,0x20,0x2d,0x31, 0x36,0x30,0x20,0x35,0x33,0x20,0x2d,0x32,0x37,0x39, 0x20,0x31,0x30,0x30,0x20,0x2d,0x32,0x37,0x37,0x20, 0x31,0x30,0x38,0x20,0x32,0x20,0x35,0x20,0x33,0x34, 0x20,0x33,0x31,0x20,0x37,0x32,0x20,0x35,0x37,0x20, 0x39,0x32,0x20,0x36,0x35,0x20,0x32,0x37,0x31,0x0a, 0x32,0x33,0x39,0x20,0x33,0x37,0x34,0x20,0x33,0x36, 0x35,0x20,0x34,0x37,0x20,0x35,0x36,0x20,0x38,0x38, 0x20,0x31,0x30,0x32,0x20,0x39,0x33,0x20,0x31,0x30, 0x32,0x20,0x34,0x20,0x30,0x20,0x31,0x32,0x36,0x20, 0x2d,0x34,0x33,0x20,0x32,0x37,0x31,0x20,0x2d,0x39, 0x36,0x7a,0x20,0x6d,0x2d,0x31,0x39,0x39,0x31,0x20, 0x2d,0x32,0x31,0x20,0x63,0x35,0x32,0x20,0x2d,0x31, 0x39,0x20,0x31,0x31,0x36,0x0a,0x2d,0x34,0x32,0x20, 0x31,0x34,0x31,0x20,0x2d,0x35,0x30,0x20,0x34,0x30, 0x20,0x2d,0x31,0x34,0x20,0x34,0x37,0x20,0x2d,0x32, 0x30,0x20,0x35,0x38,0x20,0x2d,0x35,0x39,0x20,0x32, 0x30,0x20,0x2d,0x36,0x37,0x20,0x38,0x30,0x20,0x2d, 0x31,0x36,0x32,0x20,0x31,0x35,0x31,0x20,0x2d,0x32, 0x33,0x37,0x20,0x37,0x32,0x20,0x2d,0x37,0x38,0x20, 0x36,0x39,0x20,0x2d,0x37,0x37,0x20,0x2d,0x37,0x36, 0x0a,0x38,0x20,0x2d,0x31,0x32,0x34,0x20,0x37,0x33, 0x20,0x2d,0x33,0x31,0x38,0x20,0x32,0x34,0x38,0x20, 0x2d,0x33,0x39,0x33,0x20,0x33,0x35,0x34,0x20,0x6c, 0x2d,0x32,0x34,0x20,0x33,0x33,0x20,0x32,0x34,0x20, 0x2d,0x37,0x20,0x63,0x31,0x33,0x20,0x2d,0x34,0x20, 0x36,0x37,0x20,0x2d,0x32,0x33,0x20,0x31,0x31,0x39, 0x20,0x2d,0x34,0x32,0x7a,0x20,0x6d,0x31,0x30,0x30, 0x35,0x20,0x2d,0x33,0x36,0x35,0x0a,0x63,0x36,0x31, 0x20,0x2d,0x32,0x32,0x20,0x31,0x31,0x32,0x20,0x2d, 0x34,0x32,0x20,0x31,0x31,0x34,0x20,0x2d,0x34,0x35, 0x20,0x39,0x20,0x2d,0x37,0x20,0x2d,0x33,0x36,0x20, 0x2d,0x33,0x33,0x20,0x2d,0x31,0x30,0x34,0x20,0x2d, 0x35,0x39,0x20,0x2d,0x33,0x38,0x20,0x2d,0x31,0x34, 0x20,0x2d,0x31,0x31,0x38,0x20,0x2d,0x33,0x34,0x20, 0x2d,0x31,0x37,0x38,0x20,0x2d,0x34,0x35,0x0a,0x2d, 0x31,0x30,0x37,0x20,0x2d,0x31,0x38,0x20,0x2d,0x31, 0x30,0x37,0x20,0x2d,0x31,0x38,0x20,0x2d,0x31,0x37, 0x37,0x20,0x33,0x20,0x2d,0x33,0x39,0x20,0x31,0x32, 0x20,0x2d,0x37,0x30,0x20,0x32,0x36,0x20,0x2d,0x37, 0x30,0x20,0x33,0x32,0x20,0x30,0x20,0x36,0x20,0x31, 0x38,0x20,0x36,0x31,0x20,0x34,0x31,0x20,0x31,0x32, 0x32,0x20,0x6c,0x34,0x30,0x20,0x31,0x31,0x31,0x20, 0x31,0x31,0x32,0x0a,0x2d,0x33,0x39,0x20,0x63,0x36, 0x32,0x20,0x2d,0x32,0x31,0x20,0x31,0x36,0x32,0x20, 0x2d,0x35,0x37,0x20,0x32,0x32,0x32,0x20,0x2d,0x38, 0x30,0x7a,0x22,0x2f,0x3e,0x0a,0x3c,0x2f,0x67,0x3e, 0x0a,0x3c,0x2f,0x73,0x76,0x67,0x3e,0x0a };
54.285388
61
0.727552
AdoPi
72bdc0cf2ba737cc4461a473d2c36b8f7560ba23
1,149
cpp
C++
Arrays/(CODEFORCES) Portal.cpp
kothariji/Competitive-Programming
c49f8b0135c8e9dd284ce8ab583e85ba3d809b8c
[ "MIT" ]
1
2020-08-27T06:59:52.000Z
2020-08-27T06:59:52.000Z
Arrays/(CODEFORCES) Portal.cpp
kothariji/Competitive-Programming
c49f8b0135c8e9dd284ce8ab583e85ba3d809b8c
[ "MIT" ]
null
null
null
Arrays/(CODEFORCES) Portal.cpp
kothariji/Competitive-Programming
c49f8b0135c8e9dd284ce8ab583e85ba3d809b8c
[ "MIT" ]
null
null
null
#include<stdio.h> char s[402]; int sum[401][401],f[401]; inline int GetSum(int lx,int ly,int rx,int ry){ return sum[rx][ry]-sum[rx][ly-1]-sum[lx-1][ry]+sum[lx-1][ly-1]; } inline void Solve(){ int n,m,i,j,k,ans=999999,cur; scanf("%d%d",&n,&m); for(i=1;i<=n;i++){ scanf("%s",s+1); for(j=1;j<=m;j++){ sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(s[j]=='1'); } } for(i=1;i!=n;i++){ for(j=i+4;j<=n;j++){ for(k=4;k<=m;k++){ f[k]=GetSum(i+1,1,j-1,k-1)-GetSum(i,1,i,k-1)-GetSum(j,1,j,k-1)-GetSum(i+1,k,j-1,k)+(k<<1)+j-i-3; } for(k=m-1;k!=3;k--){ if(f[k+1]<f[k]){ f[k]=f[k+1]; } } for(k=1;k!=m-2;k++){ cur=f[k+3]-GetSum(i+1,1,j-1,k)+GetSum(i,1,i,k)+GetSum(j,1,j,k)-(k<<1)-GetSum(i+1,k,j-1,k)+j-i-1; if(cur<ans){ ans=cur; } } } } printf("%d\n",ans); } int main(){ int t; scanf("%d",&t); while(t!=0){ Solve(); t--; } return 0; }
26.113636
112
0.375979
kothariji
72bef293b29669b20cf58d7f34dd52a00e4bd62e
20,016
cpp
C++
mainwindow.cpp
b0bh00d/ClipNet
cefb3cc8d56d21070bff46e51786dae8b39e81c3
[ "MIT" ]
null
null
null
mainwindow.cpp
b0bh00d/ClipNet
cefb3cc8d56d21070bff46e51786dae8b39e81c3
[ "MIT" ]
1
2021-12-24T14:50:32.000Z
2021-12-24T14:50:32.000Z
mainwindow.cpp
b0bh00d/ClipNet
cefb3cc8d56d21070bff46e51786dae8b39e81c3
[ "MIT" ]
null
null
null
#include <random> #include <limits> #ifdef QT_WIN #define WIN32_MEAN_AND_LEAN // necessary to avoid compiler errors #include <Windows.h> #define AS_LPCWSTR(str) reinterpret_cast<const wchar_t*>(str.utf16()) #define AS_LPBYTE(str) reinterpret_cast<const BYTE*>(str.utf16()) #endif #include <QTimer> #include <QDateTime> #include <QMimeData> #include <QSettings> #include <QDataStream> #include <QMessageBox> #include <QNetworkDatagram> #include <QNetworkInterface> #include <QJsonDocument> #include "mainwindow.h" #include "ui_mainwindow.h" static const QString& settings_version = "1.0"; MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_ui(new Ui::MainWindow) { m_ui->setupUi(this); setWindowTitle(tr("ClipNet by Bob Hood")); setWindowIcon(QIcon(":/images/ClipNet.png")); // generate a random integer to identify this sender std::random_device rd; std::mt19937 rd_mt(rd()); std::uniform_int_distribution<> sender_id(1, std::numeric_limits<int>::max()); m_sender_id = sender_id(rd_mt); #ifdef QT_WIN TCHAR buffer[MAX_COMPUTERNAME_LENGTH + 1]; DWORD buffer_size{MAX_COMPUTERNAME_LENGTH}; if(GetComputerName(buffer, &buffer_size)) m_host_name = QString::fromWCharArray(buffer); else m_host_name = QString::number(m_sender_id, 16); #endif m_housekeeping_timer.setInterval(1000); m_housekeeping_timer.callOnTimeout(this, &MainWindow::slot_housekeeping); load_settings(); QFont f(font()); f.setFamily("Consolas"); m_ui->edit_Log->setFont(f); connect(m_ui->check_AutoStart, &QCheckBox::clicked, this, &MainWindow::slot_set_startup); connect(m_ui->check_Channels_IPv4, &QCheckBox::clicked, this, &MainWindow::slot_set_control_states); connect(m_ui->button_MulticastGroupIPv4_Randomize, &QPushButton::clicked, this, &MainWindow::slot_randomize_ipv4); connect(m_ui->check_Channels_IPv6, &QCheckBox::clicked, this, &MainWindow::slot_set_control_states); connect(m_ui->button_MulticastGroupIPv6_Randomize, &QPushButton::clicked, this, &MainWindow::slot_randomize_ipv6); connect(m_ui->button_Channels_Join, &QPushButton::clicked, this, &MainWindow::slot_multicast_group_join); connect(m_ui->check_Channels_AutoRejoin, &QCheckBox::clicked, this, &MainWindow::slot_set_control_states); #if defined(USE_ENCRYPTION) connect(m_ui->check_Encryption, &QCheckBox::clicked, this, &MainWindow::slot_set_control_states); #else m_ui->check_Encryption->setVisible(false); m_ui->line_Passphrase->setVisible(false); #endif connect(m_ui->check_ClearClipboard, &QCheckBox::clicked, this, &MainWindow::slot_clear_clipboard); m_restore_action = new QAction(QIcon(":/images/Restore.png"), tr("&Restore"), this); connect(m_restore_action, &QAction::triggered, this, &MainWindow::showNormal); m_quit_action = new QAction(QIcon(":/images/Quit.png"), tr("&Quit"), this); connect(m_quit_action, &QAction::triggered, this, &MainWindow::slot_quit); m_trayIcon = new QSystemTrayIcon(this); connect(m_trayIcon, &QSystemTrayIcon::messageClicked, this, &MainWindow::slot_tray_message_clicked); connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::slot_tray_icon_activated); m_trayIcon->setIcon(QIcon(":/images/ClipNet.png")); m_trayIcon->setToolTip(tr("ClipNet")); build_tray_menu(); m_trayIcon->show(); m_clipboard = QGuiApplication::clipboard(); } MainWindow::~MainWindow() {} void MainWindow::build_tray_menu() { if (m_trayIconMenu) { disconnect(m_trayIconMenu, &QMenu::triggered, this, &MainWindow::slot_tray_menu_action); delete m_trayIconMenu; } m_trayIconMenu = new QMenu(this); //trayIconMenu->addSeparator(); m_trayIconMenu->addAction(m_restore_action); m_trayIconMenu->addAction(m_quit_action); m_trayIcon->setContextMenu(m_trayIconMenu); connect(m_trayIconMenu, &QMenu::triggered, this, &MainWindow::slot_tray_menu_action); } void MainWindow::setVisible(bool visible) { //restoreAction->setEnabled(isMaximized() || !visible); QWidget::setVisible(visible); } void MainWindow::closeEvent(QCloseEvent* event) { if (m_trayIcon->isVisible()) { //QMessageBox::information(this, // tr("Tray"), // tr("The program will keep running in the " // "system tray. To terminate the program, " // "choose <b>Quit</b> in the context menu " // "of the system tray entry.")); hide(); event->ignore(); } } void MainWindow::load_settings() { m_multicast_group_member = false; QString settings_file_name; settings_file_name = QDir::toNativeSeparators(QString("%1/ClipNet/Settings.ini").arg(qgetenv("APPDATA").constData())); QSettings settings(settings_file_name, QSettings::IniFormat); m_ui->check_AutoStart->setChecked(settings.value("startup_enabled", false).toBool()); m_ui->line_MulticastGroupPort->setText(settings.value("group_port", "").toString()); // m_protocol = static_cast<Protocol>(settings.value("protocol", 0).toInt()); // m_ui->group_MulticastGroupIPv4->setChecked(settings.value("ipv4_multicast_group_enabled", true).toBool()); m_ui->check_Channels_IPv4->setChecked(settings.value("ipv4_multicast_group_enabled", false).toBool()); m_ui->line_MulticastGroupIPv4->setText(settings.value("ipv4_multicast_group_address", "").toString()); m_ui->check_Channels_IPv6->setChecked(settings.value("ipv6_multicast_group_enabled", false).toBool()); m_ui->line_MulticastGroupIPv6->setText(settings.value("ipv6_multicast_group_address", "").toString()); m_ui->check_Channels_AutoRejoin->setChecked(settings.value("channels_autorejoin", false).toBool()); #ifdef USE_ENCRYPTION m_ui->check_Encryption->setChecked(settings.value("use_encryption", false).toBool()); auto passphrase{settings.value("passphrase", "").toString()}; m_ui->line_Passphrase->setText(passphrase); #endif m_ui->check_ClearClipboard->setChecked(settings.value("clear_clipboard", false).toBool()); m_ui->line_ClearClipboardSeconds->setText(settings.value("clear_clipboard_seconds", "").toString()); if (m_ui->check_ClearClipboard->isChecked()) m_housekeeping_timer.start(); QTimer::singleShot(0, this, &MainWindow::slot_set_control_states); if (!m_ui->check_Channels_AutoRejoin->isChecked()) // open the main window to remind them that they need // to initiate the connection manually showNormal(); else QTimer::singleShot(0, this, &MainWindow::slot_multicast_group_join); } void MainWindow::save_settings() { QString settings_file_name; settings_file_name = QDir::toNativeSeparators(QString("%1/ClipNet/Settings.ini").arg(qgetenv("APPDATA").constData())); QSettings settings(settings_file_name, QSettings::IniFormat); settings.clear(); settings.setValue("startup_enabled", m_ui->check_AutoStart->isChecked()); settings.setValue("group_port", m_ui->line_MulticastGroupPort->text()); settings.setValue("ipv4_multicast_group_enabled", m_ui->check_Channels_IPv4->isChecked()); settings.setValue("ipv4_multicast_group_address", m_ui->line_MulticastGroupIPv4->text()); settings.setValue("ipv6_multicast_group_enabled", m_ui->check_Channels_IPv6->isChecked()); settings.setValue("ipv6_multicast_group_address", m_ui->line_MulticastGroupIPv6->text()); settings.setValue("channels_autorejoin", m_ui->check_Channels_AutoRejoin->isChecked()); #if defined(USE_ENCRYPTION) settings.setValue("use_encryption", m_ui->check_Encryption->isChecked()); settings.setValue("passphrase", m_ui->line_Passphrase->text()); #endif settings.setValue("clear_clipboard", m_ui->check_ClearClipboard->isChecked()); settings.setValue("clear_clipboard_seconds", m_ui->line_ClearClipboardSeconds->text()); } void MainWindow::notify_clipboard_event(const QByteArray& payload) { auto packet_size{static_cast<int>(sizeof(Packet)) + static_cast<int>(payload.length())}; auto data{QByteArray(packet_size, 0)}; auto packet{reinterpret_cast<Packet*>(data.data())}; packet->magic = magic_number; packet->sender = m_sender_id; packet->action = static_cast<int>(Action::ClipData); packet->payload_size = static_cast<int>(payload.length()); ::memcpy(&packet->payload, payload.constData(), static_cast<size_t>(packet->payload_size)); m_multicast_sender->send_datagram(data); } void MainWindow::slot_housekeeping() { if (m_clear_clipboard_countdown != -1) { if (--m_clear_clipboard_countdown == 0) { // clear the clipbaord m_clipboard->setText(""); m_clear_clipboard_countdown = -1; } } } void MainWindow::slot_set_control_states() { bool ipv4_enabled{m_ui->check_Channels_IPv4->isChecked()}; bool ipv6_enabled{m_ui->check_Channels_IPv6->isChecked()}; m_ui->line_MulticastGroupPort->setEnabled(!m_multicast_group_member); m_ui->line_MulticastGroupIPv4->setEnabled(ipv4_enabled && !m_multicast_group_member); m_ui->button_MulticastGroupIPv4_Randomize->setEnabled(ipv4_enabled && !m_multicast_group_member); m_ui->line_MulticastGroupIPv6->setEnabled(ipv6_enabled && !m_multicast_group_member); m_ui->button_MulticastGroupIPv6_Randomize->setEnabled(ipv6_enabled && !m_multicast_group_member); m_ui->check_Channels_AutoRejoin->setEnabled(!m_multicast_group_member); #if defined(USE_ENCRYPTION) m_use_encryption = m_ui->check_Encryption->isChecked(); m_ui->check_Encryption->setEnabled(!m_multicast_group_member); m_ui->line_Passphrase->setEnabled(m_use_encryption && !m_multicast_group_member); #endif auto clear_clipboard{m_ui->check_ClearClipboard->isChecked()}; m_ui->check_ClearClipboard->setEnabled(!m_multicast_group_member); m_ui->line_ClearClipboardSeconds->setEnabled(clear_clipboard && !m_multicast_group_member); } void MainWindow::slot_tray_menu_action(QAction* /*action*/) {} void MainWindow::slot_tray_message_clicked() { QMessageBox::information( nullptr, tr("ClipNet"), tr("Sorry, I already gave what help I could.\n" "Maybe you should try asking a human?")); } void MainWindow::slot_tray_icon_activated(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case QSystemTrayIcon::Trigger: setVisible(!isVisible()); if (isVisible()) activateWindow(); break; case QSystemTrayIcon::DoubleClick: case QSystemTrayIcon::MiddleClick: default: break; } } void MainWindow::slot_process_peer_event(const QByteArray& datagram) { auto packet{reinterpret_cast<const Packet*>(datagram.constData())}; if (packet->magic == magic_number && packet->sender != m_sender_id) { auto timestamp{QDateTime::currentDateTime().toString()}; switch (static_cast<Action>(packet->action)) { case Action::ClipData: { QString peer_id; QString payload; #ifdef USE_ENCRYPTION bool success{false}; peer_id = QString::number(packet->sender, 16); QByteArray buffer(reinterpret_cast<const char*>(&packet->payload[0]), packet->payload_size); auto decrypted{m_security->decrypt(buffer, success)}; if (success) { auto json{QJsonDocument::fromJson(decrypted)}; peer_id = json["host"].toString(); payload = json["payload"].toString(); } #else auto buffer{QString::fromUtf8(reinterpret_cast<const char*>(&packet->payload[0]), packet->payload_size)}; auto json{QJsonDocument::fromJson(buffer)}; peer_id = json["host"].toString(); payload = json["payload"].toString(); #endif ++m_clipboard_debt; m_clipboard->setText(payload); if (m_ui->check_ClearClipboard->isChecked()) { m_clear_clipboard_countdown = m_ui->line_ClearClipboardSeconds->text().toLongLong(); if (!m_clear_clipboard_countdown) m_clear_clipboard_countdown = -1; } QStringList info; info << timestamp << QString("Peer %1: Clipboard event").arg(peer_id); m_ui->edit_Log->insertPlainText(QString("%1\n").arg(info.join(" :: "))); m_ui->edit_Log->ensureCursorVisible(); } break; default: break; } } } void MainWindow::slot_read_clipboard() { if(m_clipboard_debt) --m_clipboard_debt; else { auto mime_data{m_clipboard->mimeData()}; if (mime_data->hasText()) { auto timestamp{QDateTime::currentDateTime().toString()}; QStringList info; auto text{mime_data->text()}; info << timestamp << tr("Sending clipboard data to multicast group"); QJsonObject json; json["host"] = m_host_name; json["payload"] = text; auto payload{QJsonDocument(json).toJson()}; // braodcast new clipboard text to peers #if defined(USE_ENCRYPTION) bool success{false}; auto encrypted{m_security->encrypt(payload, success)}; if (success) notify_clipboard_event(encrypted); #else notify_clipboard_event(text.toUtf8()); #endif m_ui->edit_Log->insertPlainText(QString("%1\n").arg(info.join(" :: "))); m_ui->edit_Log->ensureCursorVisible(); } } } void MainWindow::slot_quit() { // do any cleanup needed... if (m_multicast_sender) { m_multicast_sender->deleteLater(); m_multicast_sender = nullptr; } if (m_multicast_receiver) { m_multicast_receiver->deleteLater(); m_multicast_receiver = nullptr; } save_settings(); // ...and leave. QTimer::singleShot(100, qApp, &QApplication::quit); } void MainWindow::slot_multicast_group_join() { save_settings(); if (m_multicast_group_member) { disconnect(m_clipboard, &QClipboard::dataChanged, this, &MainWindow::slot_read_clipboard); m_ui->button_Channels_Join->setText(tr("Join")); m_multicast_sender->deleteLater(); m_multicast_sender = nullptr; m_multicast_receiver->deleteLater(); m_multicast_receiver = nullptr; m_security.clear(); } else { connect(m_clipboard, &QClipboard::dataChanged, this, &MainWindow::slot_read_clipboard); #if defined(USE_ENCRYPTION) m_use_encryption = m_ui->group_Encryption->isChecked() && !m_ui->line_Passphrase->text().isEmpty(); auto passphrase{m_ui->line_Passphrase->text()}; if (passphrase.isEmpty()) // is there placeholder text? passphrase = m_ui->line_Passphrase->placeholderText(); m_security = Secure::create(passphrase); #endif m_ui->button_Channels_Join->setText(tr("Leave")); auto group_port_str{m_ui->line_MulticastGroupPort->text()}; if (group_port_str.isEmpty()) group_port_str = m_ui->line_MulticastGroupPort->placeholderText(); auto group_port{static_cast<uint16_t>(group_port_str.toInt())}; QString ipv4_multcast_group; if (m_ui->check_Channels_IPv4->isChecked()) { ipv4_multcast_group = m_ui->line_MulticastGroupIPv4->text(); if (ipv4_multcast_group.isEmpty()) ipv4_multcast_group = m_ui->line_MulticastGroupIPv4->placeholderText(); } QString ipv6_multcast_group; if (m_ui->check_Channels_IPv6->isChecked()) { ipv6_multcast_group = m_ui->line_MulticastGroupIPv6->text(); if (ipv6_multcast_group.isEmpty()) ipv6_multcast_group = m_ui->line_MulticastGroupIPv6->placeholderText(); } if (m_randomized_addresses && (!m_ui->line_MulticastGroupIPv4->text().isEmpty() || !m_ui->line_MulticastGroupIPv6->text().isEmpty())) { QMessageBox::warning( this, "Randomized Addresses", "You have randomized one or more multicast addresses.\n\n" "Please ensure other member machines are using the\n" "same new address or your ClipNet may not function."); m_randomized_addresses = false; } m_multicast_sender = new Sender(group_port, ipv4_multcast_group, ipv6_multcast_group, this); m_multicast_receiver = new Receiver(group_port, ipv4_multcast_group, ipv6_multcast_group, this); connect(m_multicast_receiver, &Receiver::signal_datagram_avaialble, this, &MainWindow::slot_process_peer_event); } m_multicast_group_member = !m_multicast_group_member; QTimer::singleShot(0, this, &MainWindow::slot_set_control_states); } void MainWindow::slot_randomize_ipv4() { std::random_device rd; std::mt19937 rd_mt(rd()); std::uniform_int_distribution<> byte(0, 255); auto b1{byte(rd_mt)}; auto b2{byte(rd_mt)}; auto b3{byte(rd_mt)}; m_ui->line_MulticastGroupIPv4->setText(QString("239.%1.%2.%3").arg(b1).arg(b2).arg(b3)); m_randomized_addresses = !m_randomized_addresses && true; } void MainWindow::slot_randomize_ipv6() { std::random_device rd; std::mt19937 rd_mt(rd()); std::uniform_int_distribution<> byte(1, 65535); m_ui->line_MulticastGroupIPv6->setText(QString("ff12::%1").arg(byte(rd_mt))); m_randomized_addresses = !m_randomized_addresses && true; } void MainWindow::slot_set_startup() { #ifdef QT_WIN HKEY hkey; QString key_str = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; QString label_str = "ClipNet"; if (m_ui->check_AutoStart->isChecked()) { QString buffer_str; wchar_t path[MAX_PATH]; GetModuleFileName(nullptr, path, MAX_PATH); QString path_str = QString::fromWCharArray(path); if (!path_str.startsWith('"')) path_str = QString("\"%1\"").arg(path_str); if (RegOpenKeyEx(HKEY_CURRENT_USER, AS_LPCWSTR(key_str), 0, KEY_SET_VALUE, &hkey) == ERROR_SUCCESS) { int len = path_str.size(); #ifdef UNICODE len *= 2; #endif RegSetValueEx(hkey, AS_LPCWSTR(label_str), 0, REG_SZ, AS_LPBYTE(path_str), len); RegCloseKey(hkey); } } else { if (RegOpenKeyEx(HKEY_CURRENT_USER, AS_LPCWSTR(key_str), 0, KEY_SET_VALUE, &hkey) == ERROR_SUCCESS) { RegDeleteValue(hkey, AS_LPCWSTR(label_str)); RegCloseKey(hkey); } } #endif } void MainWindow::slot_clear_clipboard() { if (!m_ui->check_ClearClipboard->isChecked()) m_housekeeping_timer.stop(); else if (!m_housekeeping_timer.isActive()) m_housekeeping_timer.start(); QTimer::singleShot(0, this, &MainWindow::slot_set_control_states); }
35.239437
142
0.648581
b0bh00d
72c0a107f6ce55840d3ac585812d1e18774bf5f1
334
cpp
C++
tournaments/knapsackLight/knapsackLight.cpp
gurfinkel/codeSignal
114817947ac6311bd53a48f0f0e17c0614bf7911
[ "MIT" ]
5
2020-02-06T09:51:22.000Z
2021-03-19T00:18:44.000Z
tournaments/knapsackLight/knapsackLight.cpp
gurfinkel/codeSignal
114817947ac6311bd53a48f0f0e17c0614bf7911
[ "MIT" ]
null
null
null
tournaments/knapsackLight/knapsackLight.cpp
gurfinkel/codeSignal
114817947ac6311bd53a48f0f0e17c0614bf7911
[ "MIT" ]
3
2019-09-27T13:06:21.000Z
2021-04-20T23:13:17.000Z
int knapsackLight(int value1, int weight1, int value2, int weight2, int maxW) { if (weight1 + weight2 <= maxW) { return value1 + value2; } if (std::min(weight1, weight2) > maxW) { return 0; } if (weight1 <= maxW && (value1 >= value2 || weight2 > maxW)) { return value1; } return value2; }
22.266667
64
0.57485
gurfinkel
72c0c072422b271b0c872612a60d713b4384cbb8
757
hpp
C++
Firmware/modules/InputSense.hpp
jimkoeh/ActiveLoad
77ad16cd16365efc226c3384b1ad5ba39d782c83
[ "MIT" ]
2
2017-12-25T10:00:39.000Z
2020-05-25T09:03:12.000Z
Firmware/modules/InputSense.hpp
jimkoeh/ActiveLoad
77ad16cd16365efc226c3384b1ad5ba39d782c83
[ "MIT" ]
null
null
null
Firmware/modules/InputSense.hpp
jimkoeh/ActiveLoad
77ad16cd16365efc226c3384b1ad5ba39d782c83
[ "MIT" ]
3
2019-08-25T05:32:01.000Z
2021-01-18T00:29:03.000Z
/** * @file InputSense.hpp * * @date 19.12.2015 * @author Andre * @description */ #ifndef INPUTSENSE_HPP_ #define INPUTSENSE_HPP_ #include "SystemState.hpp" #include "SystemCommand.hpp" #include "driver/DS18B20.hpp" #include <stdint.h> #include "tools/EMAFilter.hpp" class InputSense { public: InputSense(); virtual ~InputSense() { } void lowLevelInit(); void execute(SystemCommand& systemCommand, SystemState& systemState); private: float getActualVoltage(); float getActualCurrent(); DS18B20 _tempPower; unsigned int _timeLastTemperature; volatile uint16_t _adcVoltageRaw[2]; EMAFilter _filterActualVoltage; EMAFilter _filterActualCurrent; float _actualVoltage; float _actualCurrent; }; #endif /* INPUTSENSE_HPP_ */
18.463415
71
0.746367
jimkoeh
72c0d8fa9db6dc30caa52837c4ea4a02024ee7b6
4,812
cpp
C++
src/dustfluids/dustfluids_noCs_solver.cpp
PinghuiHuang/athena-pp-dustfluids
fce21992cc107aa553e83dd76b8d03ae90e990c7
[ "BSD-3-Clause" ]
2
2020-07-02T09:48:49.000Z
2020-08-25T02:37:21.000Z
src/dustfluids/dustfluids_noCs_solver.cpp
PinghuiHuang/athena-pp-dustfluids
fce21992cc107aa553e83dd76b8d03ae90e990c7
[ "BSD-3-Clause" ]
null
null
null
src/dustfluids/dustfluids_noCs_solver.cpp
PinghuiHuang/athena-pp-dustfluids
fce21992cc107aa553e83dd76b8d03ae90e990c7
[ "BSD-3-Clause" ]
1
2021-11-12T13:39:48.000Z
2021-11-12T13:39:48.000Z
//======================================================================================== // Athena++ astrophysical MHD code // Copyright(C) 2014 James M. Stone <jmstone@princeton.edu> and other code contributors // Licensed under the 3-clause BSD License, see LICENSE file for details //======================================================================================== //! \file dustfluids_noCs_solver.cpp //! \brief HLLE Riemann solver for dust fludis (no dust sound speed) //! //! Computes 1D fluxes using the Harten-Lax-van Leer (HLL) Riemann solver. This flux is //! very diffusive, especially for contacts, and so it is not recommended for use in //! applications. However, as shown by Einfeldt et al.(1991), it is positively //! conservative (cannot return negative densities or pressure), so it is a useful //! option when other approximate solvers fail and/or when extra dissipation is needed. //! //!REFERENCES: //!- E.F. Toro, "Riemann Solvers and numerical methods for fluid dynamics", 2nd ed., //! Springer-Verlag, Berlin, (1999) chpt. 10. //!- Einfeldt et al., "On Godunov-type methods near low densities", JCP, 92, 273 (1991) //!- A. Harten, P. D. Lax and B. van Leer, "On upstream differencing and Godunov-type //! schemes for hyperbolic conservation laws", SIAM Review 25, 35-61 (1983). // C headers // C++ headers #include <algorithm> // max(), min() #include <cmath> // sqrt() // Athena++ headers #include "../athena.hpp" #include "../athena_arrays.hpp" #include "../eos/eos.hpp" #include "dustfluids.hpp" //---------------------------------------------------------------------------------------- //! \fn void DustFluids::HLLE_RiemannSolver_DustFluids //! \brief The HLLE Riemann solver for Dust Fluids (no dust sound speed) void DustFluids::HLLENoCsRiemannSolverDustFluids(const int k, const int j, const int il, const int iu, const int index, AthenaArray<Real> &prim_df_l, AthenaArray<Real> &prim_df_r, AthenaArray<Real> &dust_flux) { Real df_prim_li[(NDUSTVARS)], df_prim_ri[(NDUSTVARS)], df_prim_roe[(NDUSTVARS)]; Real df_fl[(NDUSTVARS)], df_fr[(NDUSTVARS)], df_flxi[(NDUSTVARS)]; for (int n=0; n<NDUSTFLUIDS; ++n) { int idust = n; int irho = 4*idust; int ivx = (IVX + ((index-IVX))%3) + irho; int ivy = (IVX + ((index-IVX)+1)%3) + irho; int ivz = (IVX + ((index-IVX)+2)%3) + irho; #pragma omp simd private(df_prim_li, df_prim_ri, df_prim_roe, df_fl, df_fr, df_flxi) for (int i=il; i<=iu; ++i) { //Load L/R states into local variables df_prim_li[irho] = prim_df_l(irho, i); df_prim_li[ivx] = prim_df_l(ivx, i); df_prim_li[ivy] = prim_df_l(ivy, i); df_prim_li[ivz] = prim_df_l(ivz, i); df_prim_ri[irho] = prim_df_r(irho, i); df_prim_ri[ivx] = prim_df_r(ivx, i); df_prim_ri[ivy] = prim_df_r(ivy, i); df_prim_ri[ivz] = prim_df_r(ivz, i); //Compute middle state estimates with PVRS (Toro 10.5.2) //Real al, ar, el, er; Real sqrtdl = std::sqrt(df_prim_li[irho]); Real sqrtdr = std::sqrt(df_prim_ri[irho]); Real isdlpdr = 1.0/(sqrtdl + sqrtdr); df_prim_roe[irho] = sqrtdl*sqrtdr; df_prim_roe[ivx] = (sqrtdl*df_prim_li[ivx] + sqrtdr*df_prim_ri[ivx])*isdlpdr; //Compute the max/min wave speeds based on L/R and Roe-averaged values Real al = std::min(df_prim_roe[ivx],df_prim_li[ivx]); Real ar = std::max(df_prim_roe[ivx],df_prim_ri[ivx]); Real bp = ar > 0.0 ? ar : 0.0; Real bm = al < 0.0 ? al : 0.0; //Compute L/R df_fluxes along lines bm/bp: F_L - (S_L)U_L; F_R - (S_R)U_R Real vxl = df_prim_li[ivx] - bm; Real vxr = df_prim_ri[ivx] - bp; df_fl[irho] = vxl * df_prim_li[irho]; df_fr[irho] = vxr * df_prim_ri[irho]; df_fl[ivx] = df_prim_li[ivx] * df_fl[irho]; df_fr[ivx] = df_prim_ri[ivx] * df_fr[irho]; df_fl[ivy] = df_prim_li[ivy] * df_fl[irho]; df_fr[ivy] = df_prim_ri[ivy] * df_fr[irho]; df_fl[ivz] = df_prim_li[ivz] * df_fl[irho]; df_fr[ivz] = df_prim_ri[ivz] * df_fr[irho]; //Compute the HLLE df_flux at interface. Real tmp = 0.0; if (bp != bm) tmp = 0.5*(bp + bm)/(bp - bm); df_flxi[irho] = 0.5*(df_fl[irho] + df_fr[irho]) + (df_fl[irho] - df_fr[irho])*tmp; df_flxi[ivx] = 0.5*(df_fl[ivx]+df_fr[ivx]) + (df_fl[ivx]-df_fr[ivx])*tmp; df_flxi[ivy] = 0.5*(df_fl[ivy]+df_fr[ivy]) + (df_fl[ivy]-df_fr[ivy])*tmp; df_flxi[ivz] = 0.5*(df_fl[ivz]+df_fr[ivz]) + (df_fl[ivz]-df_fr[ivz])*tmp; dust_flux(irho, k, j, i) = df_flxi[irho]; dust_flux(ivx, k, j, i) = df_flxi[ivx]; dust_flux(ivy, k, j, i) = df_flxi[ivy]; dust_flux(ivz, k, j, i) = df_flxi[ivz]; } } return; }
42.584071
102
0.593932
PinghuiHuang
72c1f3333c2bc79576dfeef27ab7985f0803b4e5
17,317
cpp
C++
src/Painless_Mesh/painlessMeshSync.cpp
jaafreitas/IoTmeshToy
bb6bc6b95415f87167ef7fbd489baef9e8829044
[ "MIT" ]
7
2017-05-04T02:49:02.000Z
2019-08-01T19:17:46.000Z
src/Painless_Mesh/painlessMeshSync.cpp
jaafreitas/IoTmeshToy
bb6bc6b95415f87167ef7fbd489baef9e8829044
[ "MIT" ]
null
null
null
src/Painless_Mesh/painlessMeshSync.cpp
jaafreitas/IoTmeshToy
bb6bc6b95415f87167ef7fbd489baef9e8829044
[ "MIT" ]
5
2017-04-26T01:07:09.000Z
2020-09-17T15:29:57.000Z
#include "painlessMesh.h" #include "painlessMeshSync.h" #include "painlessMeshJson.h" #include "time.h" extern painlessMesh* staticThis; uint32_t timeAdjuster = 0; // timeSync Functions //*********************************************************************** uint32_t ICACHE_FLASH_ATTR painlessMesh::getNodeTime(void) { auto base_time = micros(); uint32_t ret = base_time + timeAdjuster; debugMsg(GENERAL, "getNodeTime(): time=%u\n", ret); return ret; } //*********************************************************************** String ICACHE_FLASH_ATTR timeSync::buildTimeStamp(timeSyncMessageType_t timeSyncMessageType, uint32_t originateTS, uint32_t receiveTS, uint32_t transmitTS) { staticThis->debugMsg(S_TIME, "buildTimeStamp(): Type = %u, t0 = %u, t1 = %u, t2 = %u\n", timeSyncMessageType, originateTS, receiveTS, transmitTS); #if ARDUINOJSON_VERSION_MAJOR==6 StaticJsonDocument<75> jsonBuffer; JsonObject timeStampObj = jsonBuffer.to<JsonObject>(); #else StaticJsonBuffer<75> jsonBuffer; JsonObject& timeStampObj = jsonBuffer.createObject(); #endif timeStampObj["type"] = (int)timeSyncMessageType; if (originateTS > 0) timeStampObj["t0"] = originateTS; if (receiveTS > 0) timeStampObj["t1"] = receiveTS; if (transmitTS > 0) timeStampObj["t2"] = transmitTS; String timeStampStr; #if ARDUINOJSON_VERSION_MAJOR==6 serializeJson(timeStampObj, timeStampStr); #else timeStampObj.printTo(timeStampStr); #endif staticThis->debugMsg(S_TIME, "buildTimeStamp(): timeStamp=%s\n", timeStampStr.c_str()); return timeStampStr; } //*********************************************************************** timeSyncMessageType_t ICACHE_FLASH_ATTR timeSync::processTimeStampDelay(String &str) { // Extracts and fills timestamp values from json timeSyncMessageType_t ret = TIME_SYNC_ERROR; staticThis->debugMsg(S_TIME, "processTimeStamp(): str=%s\n", str.c_str()); #if ARDUINOJSON_VERSION_MAJOR==6 DynamicJsonDocument jsonBuffer(1024 + str.length()); DeserializationError error = deserializeJson(jsonBuffer, str); if (error) { staticThis->debugMsg(ERROR, "processTimeStamp(): out of memory1?\n"); return TIME_SYNC_ERROR; } JsonObject timeStampObj = jsonBuffer.as<JsonObject>(); #else DynamicJsonBuffer jsonBuffer(75); JsonObject& timeStampObj = jsonBuffer.parseObject(str); if (!timeStampObj.success()) { staticThis->debugMsg(ERROR, "processTimeStamp(): out of memory1?\n"); return TIME_SYNC_ERROR; } #endif ret = static_cast<timeSyncMessageType_t>(timeStampObj["type"].as<int>()); if (ret == TIME_REQUEST || ret == TIME_RESPONSE) { timeDelay[0] = timeStampObj["t0"].as<uint32_t>(); } if (ret == TIME_RESPONSE) { timeDelay[1] = timeStampObj["t1"].as<uint32_t>(); timeDelay[2] = timeStampObj["t2"].as<uint32_t>(); } return ret; // return type of sync message } //*********************************************************************** int32_t ICACHE_FLASH_ATTR timeSync::calcAdjustment(uint32_t times[NUMBER_OF_TIMESTAMPS]) { staticThis->debugMsg(S_TIME, "calcAdjustment(): Start calculation. t0 = %u, t1 = %u, t2 = %u, t3 = %u\n", times[0], times[1], times[2], times[3]); if (times[0] == 0 || times[1] == 0 || times[2] == 0 || times[3] == 0) { // if any value is 0 staticThis->debugMsg(ERROR, "calcAdjustment(): TimeStamp error.\n"); return 0x7FFFFFFF; // return max value } // We use the SNTP protocol https://en.wikipedia.org/wiki/Network_Time_Protocol#Clock_synchronization_algorithm. uint32_t offset = ((int32_t)(times[1] - times[0]) / 2) + ((int32_t)(times[2] - times[3]) / 2); if (offset < TASK_SECOND && offset > 4) timeAdjuster += offset/4; // Take small steps to avoid over correction else timeAdjuster += offset; // Accumulate offset staticThis->debugMsg(S_TIME, "calcAdjustment(): Calculated offset %d us.\n", offset); staticThis->debugMsg(S_TIME, "calcAdjustment(): New adjuster = %u. New time = %u\n", timeAdjuster, staticThis->getNodeTime()); return offset; // return offset to decide if sync is OK } //*********************************************************************** int32_t ICACHE_FLASH_ATTR timeSync::delayCalc() { staticThis->debugMsg(S_TIME, "delayCalc(): Start calculation. t0 = %u, t1 = %u, t2 = %u, t3 = %u\n", timeDelay[0], timeDelay[1], timeDelay[2], timeDelay[3]); if (timeDelay[0] == 0 || timeDelay[1] == 0 || timeDelay[2] == 0 || timeDelay[3] == 0) { // if any value is 0 staticThis->debugMsg(ERROR, "delayCalc(): TimeStamp error.\n"); return -1; // return max value } // We use the SNTP protocol https://en.wikipedia.org/wiki/Network_Time_Protocol#Clock_synchronization_algorithm. uint32_t tripDelay = ((timeDelay[3] - timeDelay[0]) - (timeDelay[2] - timeDelay[1]))/2; staticThis->debugMsg(S_TIME, "delayCalc(): Calculated Network delay %d us\n", tripDelay); return tripDelay; } //*********************************************************************** void ICACHE_FLASH_ATTR painlessMesh::handleNodeSync(std::shared_ptr<MeshConnection> conn, JsonObject& root) { debugMsg(SYNC, "handleNodeSync(): with %u\n", conn->nodeId); meshPackageType message_type = (meshPackageType)(int)root["type"]; uint32_t remoteNodeId = root["from"]; if (remoteNodeId == 0) { debugMsg(ERROR, "handleNodeSync(): received invalid remote nodeId\n"); return; } if (conn->newConnection) { // There is a small but significant probability that we get connected twice to the // same node, e.g. if scanning happened while sub connection data was incomplete. auto oldConnection = findConnection(remoteNodeId); if (oldConnection) { debugMsg(SYNC, "handleNodeSync(): already connected to %u. Closing the new connection \n", remoteNodeId); conn->close(); return; } // debugMsg(SYNC, "handleNodeSync(): conn->nodeId updated from %u to %u\n", conn->nodeId, remoteNodeId); conn->nodeId = remoteNodeId; // TODO: Move this to its own function newConnectionTask.set(TASK_SECOND, TASK_ONCE, [remoteNodeId]() { staticThis->debugMsg(CONNECTION, "newConnectionTask():\n"); staticThis->debugMsg(CONNECTION, "newConnectionTask(): adding %u now= %u\n", remoteNodeId, staticThis->getNodeTime()); if (staticThis->newConnectionCallback) staticThis->newConnectionCallback(remoteNodeId); // Connection dropped. Signal user }); _scheduler.addTask(newConnectionTask); newConnectionTask.enable(); // Initially interval is every 10 seconds, // this will slow down to TIME_SYNC_INTERVAL // after first succesfull sync conn->timeSyncTask.set(10*TASK_SECOND, TASK_FOREVER, [conn]() { staticThis->debugMsg(S_TIME, "timeSyncTask(): %u\n", conn->nodeId); staticThis->startTimeSync(conn); }); _scheduler.addTask(conn->timeSyncTask); if (conn->station) // We are STA, request time immediately conn->timeSyncTask.enable(); else // We are the AP, give STA the change to initiate time sync conn->timeSyncTask.enableDelayed(); conn->newConnection = false; } if (conn->nodeId != remoteNodeId) { debugMsg(SYNC, "handleNodeSync(): Changed nodeId %u, closing connection %u.\n", conn->nodeId, remoteNodeId); conn->close(); return; } // check to see if subs have changed. String inComingSubs = root["subs"]; bool changed = !conn->subConnections.equals(inComingSubs); painlessmesh::parseNodeSyncRoot(conn, root, changed); if (changed) { // change in the network // Check whether we already know any of the nodes // This is necessary to avoid loops.. Not sure if we need to check // for both this node and master node, but better safe than sorry if ( painlessmesh::stringContainsNumber(inComingSubs, String(conn->nodeId)) || painlessmesh::stringContainsNumber(inComingSubs, String(this->_nodeId))) { // This node is also in the incoming subs, so we have a loop // Disconnecting to break the loop debugMsg(SYNC, "handleNodeSync(): Loop detected, disconnecting %u.\n", remoteNodeId); conn->close(); return; } debugMsg(SYNC, "handleNodeSync(): Changed connections %u.\n", remoteNodeId); conn->subConnections = inComingSubs; if (changedConnectionsCallback) changedConnectionsCallback(); staticThis->syncSubConnections(conn->nodeId); } else { stability += min(1000-stability,(size_t)25); } debugMsg(SYNC, "handleNodeSync(): json = %s\n", inComingSubs.c_str()); switch (message_type) { case NODE_SYNC_REQUEST: { debugMsg(SYNC, "handleNodeSync(): valid NODE_SYNC_REQUEST %u sending NODE_SYNC_REPLY\n", conn->nodeId); String myOtherSubConnections = subConnectionJson(conn); sendMessage(conn, conn->nodeId, _nodeId, NODE_SYNC_REPLY, myOtherSubConnections, true); break; } case NODE_SYNC_REPLY: debugMsg(SYNC, "handleNodeSync(): valid NODE_SYNC_REPLY from %u\n", conn->nodeId); break; default: debugMsg(ERROR, "handleNodeSync(): weird type? %d\n", message_type); } } //*********************************************************************** void ICACHE_FLASH_ATTR painlessMesh::startTimeSync(std::shared_ptr<MeshConnection> conn) { String timeStamp; debugMsg(S_TIME, "startTimeSync(): with %u, local port: %d\n", conn->nodeId, conn->client->getLocalPort()); auto adopt = adoptionCalc(conn); if (adopt) { timeStamp = conn->time.buildTimeStamp(TIME_REQUEST, getNodeTime()); // Ask other party its time debugMsg(S_TIME, "startTimeSync(): Requesting %u to adopt our time\n", conn->nodeId); } else { timeStamp = conn->time.buildTimeStamp(TIME_SYNC_REQUEST); // Tell other party to ask me the time debugMsg(S_TIME, "startTimeSync(): Requesting time from %u\n", conn->nodeId); } sendMessage(conn, conn->nodeId, _nodeId, TIME_SYNC, timeStamp, true); } //*********************************************************************** bool ICACHE_FLASH_ATTR painlessMesh::adoptionCalc(std::shared_ptr<MeshConnection> conn) { if (conn == NULL) // Missing connection return false; // make the adoption calulation. Figure out how many nodes I am connected to exclusive of this connection. // We use length as an indicator for how many subconnections both nodes have uint16_t mySubCount = subConnectionJson(conn).length(); //exclude this connection. uint16_t remoteSubCount = conn->subConnections.length(); bool ap = conn->client->getLocalPort() == _meshPort; // ToDo. Simplify this logic bool ret = (mySubCount > remoteSubCount) ? false : true; if (mySubCount == remoteSubCount && ap) { // in case of draw, ap wins ret = false; } debugMsg(S_TIME, "adoptionCalc(): mySubCount=%d remoteSubCount=%d role=%s adopt=%s\n", mySubCount, remoteSubCount, ap ? "AP" : "STA", ret ? "true" : "false"); return ret; } //*********************************************************************** void ICACHE_FLASH_ATTR painlessMesh::handleTimeSync(std::shared_ptr<MeshConnection> conn, JsonObject& root, uint32_t receivedAt) { auto timeSyncMessageType = static_cast<timeSyncMessageType_t>(root["msg"]["type"].as<int>()); String msg; switch (timeSyncMessageType) { case (TIME_SYNC_ERROR): debugMsg(S_TIME, "handleTimeSync(): Received time sync error. Restarting time sync.\n"); conn->timeSyncTask.forceNextIteration(); break; case (TIME_SYNC_REQUEST): // Other party request me to ask it for time debugMsg(S_TIME, "handleTimeSync(): Received requesto to start TimeSync with node: %u\n", conn->nodeId); root["msg"]["type"] = static_cast<int>(TIME_REQUEST); root["msg"]["t0"] = getNodeTime(); msg = root["msg"].as<String>(); staticThis->sendMessage(conn, conn->nodeId, _nodeId, TIME_SYNC, msg, true); break; case (TIME_REQUEST): root["msg"]["type"] = static_cast<int>(TIME_RESPONSE); root["msg"]["t1"] = receivedAt; root["msg"]["t2"] = getNodeTime(); msg = root["msg"].as<String>(); staticThis->sendMessage(conn, conn->nodeId, _nodeId, TIME_SYNC, msg, true); // Build time response debugMsg(S_TIME, "handleTimeSync(): Response sent %s\n", msg.c_str()); debugMsg(S_TIME, "handleTimeSync(): timeSyncStatus with %u completed\n", conn->nodeId); // After response is sent I assume sync is completed conn->timeSyncTask.delay(TIME_SYNC_INTERVAL); break; case (TIME_RESPONSE): debugMsg(S_TIME, "handleTimeSync(): TIME RESPONSE received.\n"); uint32_t times[NUMBER_OF_TIMESTAMPS] = { root["msg"]["t0"], root["msg"]["t1"], root["msg"]["t2"], receivedAt}; int32_t offset = conn->time.calcAdjustment(times); // Adjust time and get calculated offset // flag all connections for re-timeSync if (nodeTimeAdjustedCallback) { nodeTimeAdjustedCallback(offset); } if (offset < TIME_SYNC_ACCURACY && offset > -TIME_SYNC_ACCURACY) { // mark complete only if offset was less than 10 ms conn->timeSyncTask.delay(TIME_SYNC_INTERVAL); debugMsg(S_TIME, "handleTimeSync(): timeSyncStatus with %u completed\n", conn->nodeId); // Time has changed, update other nodes for (auto &&connection : _connections) { if (connection->nodeId != conn->nodeId) { // exclude this connection connection->timeSyncTask.forceNextIteration(); debugMsg(S_TIME, "handleTimeSync(): timeSyncStatus with %u brought forward\n", connection->nodeId); } } } else { // Iterate sync procedure if accuracy was not enough conn->timeSyncTask.delay(200*TASK_MILLISECOND); // Small delay debugMsg(S_TIME, "handleTimeSync(): timeSyncStatus with %u needs further tries\n", conn->nodeId); } break; } debugMsg(S_TIME, "handleTimeSync(): ----------------------------------\n"); } void ICACHE_FLASH_ATTR painlessMesh::handleTimeDelay(std::shared_ptr<MeshConnection> conn, JsonObject& root, uint32_t receivedAt) { String timeStamp = root["msg"]; uint32_t from = root["from"]; debugMsg(S_TIME, "handleTimeDelay(): from %u in timestamp = %s\n", from, timeStamp.c_str()); timeSyncMessageType_t timeSyncMessageType = conn->time.processTimeStampDelay(timeStamp); // Extract timestamps and get type of message String t_stamp; switch (timeSyncMessageType) { case (TIME_SYNC_ERROR): debugMsg(ERROR, "handleTimeDelay(): Error in requesting time delay. Please try again.\n"); break; case (TIME_REQUEST): //conn->timeSyncStatus == IN_PROGRESS; debugMsg(S_TIME, "handleTimeDelay(): TIME REQUEST received.\n"); // Build time response t_stamp = conn->time.buildTimeStamp(TIME_RESPONSE, conn->time.timeDelay[0], receivedAt, getNodeTime()); staticThis->sendMessage(conn, from, _nodeId, TIME_DELAY, t_stamp); debugMsg(S_TIME, "handleTimeDelay(): Response sent %s\n", t_stamp.c_str()); // After response is sent I assume sync is completed //conn->timeSyncStatus == COMPLETE; //conn->lastTimeSync = getNodeTime(); break; case (TIME_RESPONSE): { debugMsg(S_TIME, "handleTimeDelay(): TIME RESPONSE received.\n"); conn->time.timeDelay[3] = receivedAt; // Calculate fourth timestamp (response received time) int32_t delay = conn->time.delayCalc(); // Adjust time and get calculated offset debugMsg(S_TIME, "handleTimeDelay(): Delay is %d\n", delay); //conn->timeSyncStatus == COMPLETE; if (nodeDelayReceivedCallback) nodeDelayReceivedCallback(from, delay); } break; default: debugMsg(S_TIME, "handleTimeDelay(): Unknown timeSyncMessageType received. Ignoring for now.\n"); } debugMsg(S_TIME, "handleTimeSync(): ----------------------------------\n"); } void ICACHE_FLASH_ATTR painlessMesh::syncSubConnections(uint32_t changedId) { debugMsg(SYNC, "syncSubConnections(): changedId = %u\n", changedId); for (auto &&connection : _connections) { if (connection->connected && !connection->newConnection && connection->nodeId != 0 && connection->nodeId != changedId) { // Exclude current connection->nodeSyncTask.forceNextIteration(); } } staticThis->stability /= 2; }
41.828502
162
0.620951
jaafreitas
72c3cbda03a0d09996564859542dafec9baa5ca8
8,128
cpp
C++
src/bin/settings.cpp
D7ry/valhallaCombat
07929d29a48401c2878a1ed5993b7bba14743c6f
[ "MIT" ]
1
2022-01-19T07:13:48.000Z
2022-01-19T07:13:48.000Z
src/bin/settings.cpp
D7ry/valhallaCombat
07929d29a48401c2878a1ed5993b7bba14743c6f
[ "MIT" ]
null
null
null
src/bin/settings.cpp
D7ry/valhallaCombat
07929d29a48401c2878a1ed5993b7bba14743c6f
[ "MIT" ]
1
2022-01-19T07:13:52.000Z
2022-01-19T07:13:52.000Z
#include "include/stunHandler.h" #include "include/settings.h" #include "ValhallaCombat.hpp" using namespace Utils; void settings::ReadIntSetting(CSimpleIniA& a_ini, const char* a_sectionName, const char* a_settingName, uint32_t& a_setting) { const char* bFound = nullptr; bFound = a_ini.GetValue(a_sectionName, a_settingName); if (bFound) { //INFO("found {} with value {}", a_settingName, bFound); a_setting = static_cast<int>(a_ini.GetDoubleValue(a_sectionName, a_settingName)); } } void settings::ReadFloatSetting(CSimpleIniA& a_ini, const char* a_sectionName, const char* a_settingName, float& a_setting) { const char* bFound = nullptr; bFound = a_ini.GetValue(a_sectionName, a_settingName); if (bFound) { //INFO("found {} with value {}", a_settingName, bFound); a_setting = static_cast<float>(a_ini.GetDoubleValue(a_sectionName, a_settingName)); } } void settings::ReadBoolSetting(CSimpleIniA& a_ini, const char* a_sectionName, const char* a_settingName, bool& a_setting) { const char* bFound = nullptr; bFound = a_ini.GetValue(a_sectionName, a_settingName); if (bFound) { //INFO("found {} with value {}", a_settingName, bFound); a_setting = a_ini.GetBoolValue(a_sectionName, a_settingName); } } void settings::init() { INFO("Initilize settings..."); auto dataHandler = RE::TESDataHandler::GetSingleton(); if (dataHandler) { #define LOOKGLOBAL dataHandler->LookupForm<RE::TESGlobal> glob_Nemesis_EldenCounter_Damage = LOOKGLOBAL(0x56A23, "ValhallaCombat.esp"); glob_Nemesis_EldenCounter_NPC = LOOKGLOBAL(0x56A24, "ValhallaCombat.esp"); glob_TrueHudAPI = LOOKGLOBAL(0x56A25, "ValhallaCombat.esp"); glob_TrueHudAPI_SpecialMeter = LOOKGLOBAL(0x56A26, "ValhallaCombat.esp"); } INFO("...done"); } void settings::updateGlobals() { INFO("Update globals..."); if (glob_TrueHudAPI) { glob_TrueHudAPI->value = ValhallaCombat::GetSingleton()->ersh != nullptr ? 1.f : 0.f; } if (glob_TrueHudAPI_SpecialMeter) { glob_TrueHudAPI_SpecialMeter->value = TrueHudAPI_HasSpecialBarControl ? 1.f : 0.f; } auto pc = RE::PlayerCharacter::GetSingleton(); if (pc) { if (glob_Nemesis_EldenCounter_Damage) { bool bDummy; glob_Nemesis_EldenCounter_Damage->value = pc->GetGraphVariableBool("is_Guard_Countering", bDummy); } if (glob_Nemesis_EldenCounter_NPC) { bool bDummy; glob_Nemesis_EldenCounter_NPC->value = pc->GetGraphVariableBool("IsValGC", bDummy); } } INFO("...done"); } /*read settings from ini, and update them into game settings.*/ void settings::readSettings() { INFO("Read ini settings..."); #if JL_AntiPiracy #define anti_PiracyMsg_PATH "Data\\Val_Config.ini" CSimpleIniA anti_PiracyMsg; anti_PiracyMsg.LoadFile(anti_PiracyMsg_PATH); JueLun_LoadMsg = anti_PiracyMsg.GetValue("load", "msg"); auto hash = std::hash<std::string>{}(JueLun_LoadMsg); INFO(hash); if (hash != 13375109384697678453) { ERROR("Error: Mod Piracy detected"); } #endif #define SETTINGFILE_PATH "Data\\MCM\\Settings\\ValhallaCombat.ini" CSimpleIniA mcm; mcm.LoadFile(SETTINGFILE_PATH); std::list<CSimpleIniA::Entry> ls; /*Read stamina section*/ ReadBoolSetting(mcm, "Stamina", "bUIalert", bUIAlert); ReadBoolSetting(mcm, "Stamina", "bNonCombatStaminaDebuff", bNonCombatStaminaDebuff); ReadFloatSetting(mcm, "Stamina", "fStaminaRegenMult", fStaminaRegenMult); ReadFloatSetting(mcm, "Stamina", "fStaminaRegenLimit", fStaminaRegenLimit); ReadFloatSetting(mcm, "Stamina", "fCombatStaminaRegenMult", fCombatStaminaRegenMult); ReadFloatSetting(mcm, "Stamina", "fStaminaRegenDelay", fStaminaRegenDelay); ReadBoolSetting(mcm, "Stamina", "bBlockStaminaToggle", bBlockStaminaToggle); ReadBoolSetting(mcm, "Stamina", "bGuardBreak", bGuardBreak); ReadFloatSetting(mcm, "Stamina", "fBckShdStaminaMult_NPC_Block_NPC", fBckShdStaminaMult_NPC_Block_NPC); ReadFloatSetting(mcm, "Stamina", "fBckShdStaminaMult_NPC_Block_PC", fBckShdStaminaMult_NPC_Block_PC); ReadFloatSetting(mcm, "Stamina", "fBckShdStaminaMult_PC_Block_NPC", fBckShdStaminaMult_PC_Block_NPC); ReadFloatSetting(mcm, "Stamina", "fBckWpnStaminaMult_NPC_Block_NPC", fBckWpnStaminaMult_NPC_Block_NPC); ReadFloatSetting(mcm, "Stamina", "fBckWpnStaminaMult_NPC_Block_PC", fBckWpnStaminaMult_NPC_Block_PC); ReadFloatSetting(mcm, "Stamina", "fBckWpnStaminaMult_PC_Block_NPC", fBckWpnStaminaMult_PC_Block_NPC); ReadBoolSetting(mcm, "Stamina", "bAttackStaminaToggle", bAttackStaminaToggle); ReadBoolSetting(mcm, "Stamina", "bBlockedHitRegenStamina", bBlockedHitRegenStamina); ReadFloatSetting(mcm, "Stamina", "fMeleeCostLightMiss_Point", fMeleeCostLightMiss_Point); ReadFloatSetting(mcm, "Stamina", "fMeleeRewardLightHit_Percent", fMeleeRewardLightHit_Percent); ReadFloatSetting(mcm, "Stamina", "fMeleeCostHeavyMiss_Percent", fMeleeCostHeavyMiss_Percent); ReadFloatSetting(mcm, "Stamina", "fMeleeCostHeavyHit_Percent", fMeleeCostHeavyHit_Percent); /*Read perfect blocking section*/ ReadBoolSetting(mcm, "Parrying", "bBlockProjectileToggle", bBlockProjectileToggle); ReadBoolSetting(mcm, "Parrying", "bTimedBlockToggle", bTimedBlockToggle); ReadBoolSetting(mcm, "Parrying", "bTimedBlockProjectileToggle", bTimedBlockProjectileToggle); ReadBoolSetting(mcm, "Parrying", "bTimedBlockScreenShake", bTimedBlockScreenShake); ReadBoolSetting(mcm, "Parrying", "bTimeBlockSFX", bTimeBlockSFX); ReadBoolSetting(mcm, "Parrying", "bTimedBlockVFX", bTimedBlockVFX); ReadBoolSetting(mcm, "Parrying", "bTimedBlockSlowTime", bTimedBlockSlowTime); ReadFloatSetting(mcm, "Parrying", "fTimedBlockWindow", fTimedBlockWindow); ReadFloatSetting(mcm, "Parrying", "fTimedBlockCooldownTime", fTimedBlockCooldownTime); ReadFloatSetting(mcm, "Parrying", "fTimedBlockStaminaCostMult", fTimedBlockStaminaCostMult); ReadIntSetting(mcm, "Parrying", "uAltBlockKey", uAltBlockKey); /*Read stun section*/ ReadBoolSetting(mcm, "Stun", "bStunToggle", bStunToggle); ReadBoolSetting(mcm, "Stun", "bStunMeterToggle", bStunMeterToggle); ReadBoolSetting(mcm, "Stun", "bExecutionLimit", bExecutionLimit); ReadFloatSetting(mcm, "Stun", "fStunParryMult", fStunParryMult); ReadFloatSetting(mcm, "Stun", "fStunBashMult", fStunBashMult); ReadFloatSetting(mcm, "Stun", "fStunPowerBashMult", fStunPowerBashMult); ReadFloatSetting(mcm, "Stun", "fStunNormalAttackMult", fStunNormalAttackMult); ReadFloatSetting(mcm, "Stun", "fStunPowerAttackMult", fStunPowerAttackMult); ReadFloatSetting(mcm, "Stun", "fStunUnarmedMult", fStunUnarmedMult); ReadFloatSetting(mcm, "Stun", "fStunDaggerMult", fStunDaggerMult); ReadFloatSetting(mcm, "Stun", "fStunSwordMult", fStunSwordMult); ReadFloatSetting(mcm, "Stun", "fStunWarAxeMult", fStunWarAxeMult); ReadFloatSetting(mcm, "Stun", "fStunMaceMult", fStunMaceMult); ReadFloatSetting(mcm, "Stun", "fStunGreatSwordMult", fStunGreatSwordMult); ReadFloatSetting(mcm, "Stun", "fStun2HBluntMult", fStun2HBluntMult); ReadBoolSetting(mcm, "Stun", "bAutoExecution", bAutoExecution); ReadIntSetting(mcm, "Stun", "uExecutionKey", uExecutionKey); ReadBoolSetting(mcm, "Compatibility", "bPoiseCompatibility", bPoiseCompatibility); /*Read Balance section*/ ReadBoolSetting(mcm, "Balance", "bBalanceToggle", bBalanceToggle); INFO("...done"); INFO("Apply game settings..."); /*Set some game settings*/ setGameSettingf("fDamagedStaminaRegenDelay", fStaminaRegenDelay); setGameSettingf("fCombatStaminaRegenRateMult", fCombatStaminaRegenMult); /* setGameSettingf("fStaggerMin", 0); setGameSettingf("fStaggerPlayerMassMult", 0); setGameSettingf("fStaminaAttackWeaponBase", 0); setGameSettingf("fStaggerAttackMult", 0); setGameSettingf("fStaggerAttackBase", 0); setGameSettingf("fStaggerMassBase", 0); setGameSettingf("fStaggerMassMult", 0); setGameSettingf("fStaggerMassOffsetBase", 0); setGameSettingf("fStaggerMassOffsetMult", 0); setGameSettingb("bPlayStaggers:Combat", false);*/ multStaminaRegen(fStaminaRegenMult, fStaminaRegenLimit); /*Release truehud meter if set so.*/ if (bStunMeterToggle && bStunToggle){ ValhallaCombat::GetSingleton()->requestTrueHudSpecialBarControl(); } else { ValhallaCombat::GetSingleton()->releaseTrueHudSpecialBarControl(); } INFO("...done"); }
45.155556
126
0.779405
D7ry
72c3fe1c2eb1c0d8e098ce9d2704980581650056
1,207
cpp
C++
ch_3/p3-5.cpp
bg2d/accelerated_cpp
a558d90090ceadeedd83e4726f6e7497219e9626
[ "MIT" ]
null
null
null
ch_3/p3-5.cpp
bg2d/accelerated_cpp
a558d90090ceadeedd83e4726f6e7497219e9626
[ "MIT" ]
null
null
null
ch_3/p3-5.cpp
bg2d/accelerated_cpp
a558d90090ceadeedd83e4726f6e7497219e9626
[ "MIT" ]
null
null
null
#include <iostream> #include <string> #include <vector> int main() { const int NO_HOMEWORKS = 3; std::vector<std::string> students; std::vector<double> grades; std::string name; std::cout << "Please give the sutend's name: "; while (std::cin >> name) { students.push_back(name); // ask for and read the midterm and final grades std::cout << "Please enter student's midterm and final exam grades:"; double midterm, final; std::cin >> midterm >> final; // read the homeworks' grades std::cout << "Enter all student's homework grades: "; double grade; double sum = 0; for (int i = 0; i < NO_HOMEWORKS; i++) { std::cin >> grade; sum += grade; } double final_grade = 0.2 * midterm + 0.4 * final + 0.4 * sum / NO_HOMEWORKS; grades.push_back(final_grade); std::cout << std::endl; std::cout << "Please give the name of another student or end-of-file to exit: "; } // display the final result for (int i = 0; i < students.size(); i++) { std::cout << students[i] << " : " << grades[i] << std::endl; } return 0; }
28.069767
88
0.553438
bg2d
72c614948d1978a55a64a0988f3443249e92771e
570
hpp
C++
src/miniframes/miniframe.hpp
helloer/polybobin
63b2cea40d3afcfc9d6f62f49acbfacf6a8783e1
[ "MIT" ]
8
2016-10-06T11:49:14.000Z
2021-11-06T21:06:36.000Z
src/miniframes/miniframe.hpp
helloer/polybobin
63b2cea40d3afcfc9d6f62f49acbfacf6a8783e1
[ "MIT" ]
20
2017-04-25T14:23:02.000Z
2018-12-04T22:46:04.000Z
src/miniframes/miniframe.hpp
helloer/polybobin
63b2cea40d3afcfc9d6f62f49acbfacf6a8783e1
[ "MIT" ]
4
2018-07-04T00:14:41.000Z
2018-07-17T09:08:25.000Z
#ifndef MINIFRAME_HPP #define MINIFRAME_HPP #include <wx/wxprec.h> #ifndef WX_PRECOMP #include <wx/wx.h> #endif #include <wx/minifram.h> /** * \brief Generic mini frame with custom behavior. */ class MiniFrame: public wxMiniFrame { public: MiniFrame(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize &size); void ToggleVisibility(); private: /** * \brief We want custom behavior when the "X" icon is pressed. */ void OnClosed(wxCloseEvent &event); }; #endif
21.111111
119
0.659649
helloer
72c640e5c1c99d1e9d1492a77c840eb641a07413
121
cpp
C++
Source/QuarantineProject/Private/Inventory/QP_InventoryItem.cpp
AInsolence/QuarantineProject
99e07b82edbf05510453822383d713602c4a3510
[ "MIT" ]
1
2021-08-28T04:07:58.000Z
2021-08-28T04:07:58.000Z
Source/QuarantineProject/Private/Inventory/QP_InventoryItem.cpp
AInsolence/QuarantineProject
99e07b82edbf05510453822383d713602c4a3510
[ "MIT" ]
null
null
null
Source/QuarantineProject/Private/Inventory/QP_InventoryItem.cpp
AInsolence/QuarantineProject
99e07b82edbf05510453822383d713602c4a3510
[ "MIT" ]
null
null
null
// Fill out your copyright notice in the Description page of Project Settings. #include "Inventory/QP_InventoryItem.h"
24.2
78
0.793388
AInsolence
72c67f14cdc716bda06664835ca324a5ff1eb16b
2,326
cc
C++
mindspore/lite/tools/converter/parser/onnx/onnx_random_normal_parser.cc
httpsgithu/mindspore
c29d6bb764e233b427319cb89ba79e420f1e2c64
[ "Apache-2.0" ]
1
2022-02-23T09:13:43.000Z
2022-02-23T09:13:43.000Z
mindspore/lite/tools/converter/parser/onnx/onnx_random_normal_parser.cc
949144093/mindspore
c29d6bb764e233b427319cb89ba79e420f1e2c64
[ "Apache-2.0" ]
null
null
null
mindspore/lite/tools/converter/parser/onnx/onnx_random_normal_parser.cc
949144093/mindspore
c29d6bb764e233b427319cb89ba79e420f1e2c64
[ "Apache-2.0" ]
null
null
null
/** * Copyright 2022 Huawei Technologies Co., Ltd * * 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 "tools/converter/parser/onnx/onnx_random_normal_parser.h" #include <algorithm> #include <memory> #include <vector> #include "ops/random_normal.h" #include "nnacl/op_base.h" namespace mindspore { namespace lite { PrimitiveCPtr OnnxRandomNormalParser::Parse(const onnx::GraphProto &onnx_graph, const onnx::NodeProto &onnx_node) { auto prim = std::make_unique<ops::RandomNormal>(); MS_CHECK_TRUE_RET(prim != nullptr, nullptr); for (const auto &onnx_node_attr : onnx_node.attribute()) { if (onnx_node_attr.name() == "dtype") { auto onnx_dtype = static_cast<onnx::TensorProto_DataType>(onnx_node_attr.i()); auto data_type = OnnxNodeParser::GetDataTypeFromOnnx(onnx_dtype); prim->AddAttr(ops::kDataType, api::MakeValue(static_cast<int>(data_type))); } else if (onnx_node_attr.name() == "shape") { std::vector<int64_t> shape; std::transform(onnx_node_attr.ints().begin(), onnx_node_attr.ints().end(), std::back_inserter(shape), [](int ele) { return static_cast<int64_t>(ele); }); prim->AddAttr(ops::kShape, api::MakeValue(shape)); } else if (onnx_node_attr.name() == "seed") { prim->set_seed(static_cast<float>(onnx_node_attr.f())); } else if (onnx_node_attr.name() == "mean") { prim->set_mean(static_cast<float>(onnx_node_attr.f())); } else if (onnx_node_attr.name() == "scale") { prim->set_scale(static_cast<float>(onnx_node_attr.f())); } } return prim->GetPrim(); } OnnxNodeRegistrar g_onnxRandomNormalParser("RandomNormal", new OnnxRandomNormalParser()); OnnxNodeRegistrar g_onnxRandomNormalLikeParser("RandomNormalLike", new OnnxRandomNormalParser()); } // namespace lite } // namespace mindspore
43.886792
115
0.715821
httpsgithu
72caad68f871dedd748f0ac8d3322bee3051eb4e
5,680
cpp
C++
src/utils/MySqlPools.cpp
EricKTCheung/dmlite
7fe31e16fc18e3c3d8b048a3507f7769ef3f8a9d
[ "Apache-2.0" ]
null
null
null
src/utils/MySqlPools.cpp
EricKTCheung/dmlite
7fe31e16fc18e3c3d8b048a3507f7769ef3f8a9d
[ "Apache-2.0" ]
null
null
null
src/utils/MySqlPools.cpp
EricKTCheung/dmlite
7fe31e16fc18e3c3d8b048a3507f7769ef3f8a9d
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2015 CERN * * 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. * */ /// @file MySqlPools.h /// @brief MySQL pool implementation /// @author Fabrizio Furano <furano@cern.ch> /// @date Dec 2015 #ifdef __APPLE__ #include <bsm/audit_errno.h> #endif #include <algorithm> #include <cstring> #include <pthread.h> #include <stdlib.h> #include <mysql/mysql.h> #include "utils/logger.h" #include "utils/mysqlpools.h" using namespace dmlite; // Logger stuff Logger::bitmask mysqlpoolslogmask = ~0; Logger::component mysqlpoolslogname = "Mysqlpools"; pthread_once_t dmlite::initialize_mysql_thread = PTHREAD_ONCE_INIT; pthread_key_t dmlite::destructor_key; void dmlite::destroy_thread(void*) { mysql_thread_end(); } void dmlite::init_thread(void) { mysql_thread_init(); pthread_key_create(&destructor_key, destroy_thread); } //------------------------------------------ // MySqlHolder // Holder of mysql connections, base class singleton holding the mysql conn pool // // Static mysql-related stuff PoolContainer<MYSQL*> *MySqlHolder::connectionPool_ = 0; MySqlHolder *MySqlHolder::instance = 0; MySqlHolder *MySqlHolder::getInstance() { if (!instance) { instance = new MySqlHolder(); } return instance; } MySqlHolder::MySqlHolder() { mysql_library_init(0, NULL, NULL); poolsize = 0; connectionPool_ = 0; } MySqlHolder::~MySqlHolder() { if (connectionPool_) delete connectionPool_; poolsize = 0; connectionPool_ = 0; } PoolContainer<MYSQL*> &MySqlHolder::getMySqlPool() throw(DmException){ MySqlHolder *h = getInstance(); if (!h->connectionPool_) { Log(Logger::Lvl1, mysqlpoolslogmask, mysqlpoolslogname, "Creating MySQL connection pool" << h->connectionFactory_.user << "@" << h->connectionFactory_.host << ":" <<h->connectionFactory_.port << " size: " << h->poolsize); h->connectionPool_ = new PoolContainer<MYSQL*>(&h->connectionFactory_, h->poolsize); } return *(h->connectionPool_); } bool MySqlHolder::configure(const std::string& key, const std::string& value) { MySqlHolder *h = getInstance(); bool gotit = true; LogCfgParm(Logger::Lvl4, mysqlpoolslogmask, mysqlpoolslogname, key, value); if (key == "MySqlHost") h->connectionFactory_.host = value; else if (key == "MySqlUsername") h->connectionFactory_.user = value; else if (key == "MySqlPassword") h->connectionFactory_.passwd = value; else if (key == "MySqlPort") h->connectionFactory_.port = atoi(value.c_str()); else if (key == "NsPoolSize") { int n = atoi(value.c_str()); h->poolsize = (n < h->poolsize ? h->poolsize : n); if (h->connectionPool_) h->connectionPool_->resize(h->poolsize); } else if (key == "MySqlDirectorySpaceReportDepth") h->connectionFactory_.dirspacereportdepth = atoi(value.c_str()); else gotit = false; if (gotit) LogCfgParm(Logger::Lvl4, mysqlpoolslogmask, mysqlpoolslogname, key, value); return gotit; } void MySqlHolder::configure(std::string host, std::string username, std::string password, int port, int poolsize) { MySqlHolder *h = MySqlHolder::getInstance(); Log(Logger::Lvl4, mysqlpoolslogmask, mysqlpoolslogname, "Configuring MySQL access. host:'" << host << "' user:'" << username << "' port:'" << port << "' poolsz:" << poolsize);; h->connectionFactory_.host = host; h->connectionFactory_.user = username; h->connectionFactory_.passwd = password; h->connectionFactory_.port = port; h->poolsize = (poolsize < h->poolsize ? h->poolsize : poolsize); if (h->connectionPool_) h->connectionPool_->resize(h->poolsize); } // ----------------------------------------- // MySqlConnectionFactory // MySqlConnectionFactory::MySqlConnectionFactory() { dirspacereportdepth = 6; Log(Logger::Lvl4, mysqlpoolslogmask, mysqlpoolslogname, "MySqlConnectionFactory started"); // Nothing } MYSQL* MySqlConnectionFactory::create() { MYSQL* c; my_bool reconnect = 1; my_bool truncation = 0; Log(Logger::Lvl4, mysqlpoolslogmask, mysqlpoolslogname, "Connecting... " << user << "@" << host << ":" << port); c = mysql_init(NULL); mysql_options(c, MYSQL_OPT_RECONNECT, &reconnect); mysql_options(c, MYSQL_REPORT_DATA_TRUNCATION, &truncation); if (mysql_real_connect(c, host.c_str(), user.c_str(), passwd.c_str(), NULL, port, NULL, CLIENT_FOUND_ROWS) == NULL) { std::string err("Could not connect! "); err += mysql_error(c); mysql_close(c); #ifdef __APPLE__ throw DmException(DMLITE_DBERR(BSM_ERRNO_ECOMM), err); #else throw DmException(DMLITE_DBERR(ECOMM), err); #endif } Log(Logger::Lvl3, mysqlpoolslogmask, mysqlpoolslogname, "Connected. " << user << "@" << host << ":" << port); return c; } void MySqlConnectionFactory::destroy(MYSQL* c) { Log(Logger::Lvl4, mysqlpoolslogmask, mysqlpoolslogname, "Destroying... "); mysql_close(c); Log(Logger::Lvl3, mysqlpoolslogmask, mysqlpoolslogname, "Destroyed. "); } bool MySqlConnectionFactory::isValid(MYSQL*) { // Reconnect set to 1, so even if the connection dropped, // it will reconnect. return true; }
26.542056
115
0.681514
EricKTCheung
72cecc7e5d7d83c7a40a07c1af0dd53f8fc53f4e
12,655
cpp
C++
Settings.cpp
Bozebo/buddhabrot
71bf4d971c0305e7ef063ebc7bb03b3eab88d81e
[ "Unlicense" ]
1
2018-10-23T21:49:30.000Z
2018-10-23T21:49:30.000Z
Settings.cpp
Bozebo/buddhabrot
71bf4d971c0305e7ef063ebc7bb03b3eab88d81e
[ "Unlicense" ]
null
null
null
Settings.cpp
Bozebo/buddhabrot
71bf4d971c0305e7ef063ebc7bb03b3eab88d81e
[ "Unlicense" ]
null
null
null
#include "Settings.h" //the constructor sets up some workable defaults Settings::Settings() { // ----- Orbits //if an orbit has not been determined as being outside the set in at least this many iterations (n, AKA orbit depth), discard it maxIts = 10000; //if an orbit _has_ been determined as being outside the set in less than this many iterations, discard it minIts = 18; //how orbit start locations are decided orbitMode = 2; // 2; //0 = naive (full random), 1 = apertures (my strange method of finding detailed orbit starts), 2 = metropolis hastings //GA (Genetic Algorithm) settings, the GA allows for painting more detailed orbits (only for apertures orbit mode) //the size of the orbit casting "box", a smaller number makes a smaller box //orbits casts are begun from random seeds within the box (instead of the whole plane) //until the box moves (a "set" of casts), to a new random location //mutStr = 0.005; //mutStr = 0.0025; mutStr = 0.0075; mutStrFocus = 0.0025; //smaller casting box for more exaggerated GA outcome when in "focus mode" (hold I by default) //mutation set "size", the box moves once this reaches 0 //maxMutations = 4096; maxMutations = 2048; maxMutationsFocus = 4096; // ----- Painting xRes = 768; yRes = 768; brightness = 1.0f; gamma = 1.0f; //important: this applies when outputting the buddhabrot to an RGB bitmap (texture or image file). Not when painting orbits. colMethod = 1; //1 = sqrt (better), otherwise linear (poorly shows details). //viewport: //these settings are good for a 0.0, 0.0 julia seed and viewing the zR, zI plane ("default") xScale = 2.7; yScale = 2.5; xOffset = -0.48; yOffset = 0; /* xScale = 3.0; yScale = 2.5; xOffset = -0.5; yOffset = 0.0; */ /* xScale = .017; yScale = .017; xOffset = -0.158; yOffset = 1.034; */ //good for zooming into a minibrot on the stalk //xScale = 0.0002; //yScale = 0.0002; //xScale = 0.00018; //yScale = 0.0002; //xOffset = -1.484472; //yOffset = 0; //start - end orbit depths (n) for paint ranges //intensity is minimum at n=s and maximum at n=e (default painting method) //where n trends from minIts+start*(maxIts-minIts) to minIts+end*(maxIts-minIts) rStart = 0.002f, rEnd = 0.50f; gStart = 0.020f, gEnd = 0.75f; bStart = 0.200f, bEnd = 1.00f; //rStart = 0.01f, rEnd = 0.25f; //gStart = 0.2f, gEnd = 0.3f; //bStart = 0.28f, bEnd = 1.0f; /* sRed = 16; eRed = 512; sGreen = 64; eGreen = 1024; sBlue = 96; eBlue = 1100; */ // ----- Advanced //interesting visuals can be achieved on planes other than Zr, Zi xAxis = 0; //0 = Zr, 1 = Zi, 2 = Cr yAxis = 0; //0 = Zi, 1 = Cr, 2 = Ci //seed for juliabrot (0.0, 0.0 = mandel/buddhabrot) sR = 0; // -0.7; sI = 0; // -0.7; fourDims = false; //if true, z is also seeded at random paintMirror = false; //if using metropolis hastings, this enables mirroring painting around the center x axis of the image (so it should be false if not rendering a symmetrical viewport) skipIsOutsideMandel = false; //if true, isOutsideMandel is skipped forceSkipIsOutsideMandel = false; //if true, override automation of this setting paintStartMap = false; //if true, a buffer will be saved of where orbits that resulted in painting began from //custom orbit start region on the Z complex plane (defaults to mandelbrot range if false) doCustomOrbitStart = false; //mirrorCustomOrbitStart = true; /* orbitXScale = 0.016; orbitYScale = 0.016; orbitXOffset = -.1585; orbitYOffset = 1.033; */ /* xScale = 0.00018; yScale = 0.0002; xOffset = -1.484472; */ /* orbitXScale = 0.00019; orbitYScale = 0.00021; orbitXOffset = -1.484474; orbitYOffset = 0.0; */ } void Settings::init(){ // ----- Internal processing //start - end orbit depths (n) for paint ranges //intensity is minimum at n=s and maximum at n=e (default colouring method) paintStartIts = minIts; //paintStartIts = 4; //checking if there's any reason for paintStartIts to be different from minIts (maybe with some exotic colouring/painting) int intsDiff = maxIts - paintStartIts; sRed = paintStartIts + int(intsDiff * rStart); eRed = paintStartIts + int(intsDiff * rEnd); sGreen = paintStartIts + int(intsDiff * gStart); eGreen = paintStartIts + int(intsDiff * gEnd); sBlue = paintStartIts + int(intsDiff * bStart); eBlue = paintStartIts + int(intsDiff * bEnd); paintStartIts = (sRed < ( (sBlue < sGreen)? sBlue : sGreen))? sRed : ( (sBlue < sGreen)? sBlue : sGreen); //the smallest //skip quick mandelbrot region check if the plane is not default and skipIsOutsideMandel is not forced if(!forceSkipIsOutsideMandel && (xAxis != 0 && yAxis!= 0)) skipIsOutsideMandel = true; //sRed = minIts; //sGreen = minIts; //sBlue = minIts; /* sRed = 16; eRed = 512; sGreen = 64; eGreen = 1024; sBlue = 96; eBlue = 1100; */ /* if (xPlane == 1 && yPlane == 2){ //any other viewports are bad for the zI cI plane so override the setting xScale = 4.2; yScale = 2.3; xOffset = 0.0; yOffset = 0.0; } */ } Settings::~Settings() { } using namespace tinyxml2; int Settings::loadFromFile(const char* path){ settingsFile = new XMLDocument (); XMLError xmlErr = settingsFile->LoadFile(path); if (xmlErr != XML_SUCCESS){ FILE* xmlErrFile; //fopen_s(&xmlErrFile, "xmlErr.txt", "w"); //fprintf_s(xmlErrFile, "settings load failed: %d\n", xmlErr); xmlErrFile = fopen("xmlErr.txt", "w"); fprintf(xmlErrFile, "settings load failed: %d\n", xmlErr); fclose(xmlErrFile); if(xmlErr != XML_ERROR_FILE_NOT_FOUND) return -1; //failed return 0; } //find the first <brot> element with an "active" attribute set to true XMLElement* brot = settingsFile->FirstChildElement("brot"); while(brot != NULL){ bool bActive = false; brot->QueryBoolAttribute("active", &bActive); if(!bActive){ brot = brot->NextSiblingElement("brot"); continue; } //found our way here? then this is the (first, and only one we care about) active <brot> //~read window resolution // -- read texture resolution int sXRes, sYRes; int sRes = -1; brot->QueryIntAttribute("resolution", &sRes); switch(sRes){ //which resolutions can be used depends on the graphics device case 0: sXRes = sYRes = 512; break; case 1: sXRes = sYRes = 768; break; case 2: sXRes = sYRes = 1024; break; case 3: sXRes = sYRes = 2048; break; case 4: sXRes = sYRes = 4096; break; case 5: sXRes = sYRes = 8192; break; } //also read exact resolutions if specified brot->QueryIntAttribute("xRes", &sXRes); brot->QueryIntAttribute("yRes", &sYRes); //constrain values if(sXRes < 128) sXRes = 128; if(sYRes < 128) sYRes = 128; //apply the read values xRes = sXRes; yRes = sYRes; // -- read min and max iterations brot->QueryIntAttribute("minIts", &minIts); brot->QueryIntAttribute("maxIts", &maxIts); //constrain values if(minIts < 1) minIts = 1; if(maxIts < minIts) maxIts = minIts; // -- read colour start & end depths //XMLElement *col = brot->FirstChildElement("col"); //if(col != NULL){ //XMLElement *red = col->FirstChildElement("red"); XMLElement *red = brot->FirstChildElement("red"); if(red != NULL){ red->QueryFloatAttribute("start", &rStart); red->QueryFloatAttribute("end", &rEnd); if(rStart < 0.0f) rStart = 0.0f; if(rStart > 1.0f) rStart = 1.0f; if(rEnd < rStart) rEnd = rStart; } //XMLElement *green = col->FirstChildElement("green"); XMLElement *green = brot->FirstChildElement("green"); if(red != NULL){ green->QueryFloatAttribute("start", &gStart); green->QueryFloatAttribute("end", &gEnd); if(gStart < 0.0f) gStart = 0.0f; if(gStart > 1.0f) gStart = 1.0f; if(gEnd < gStart) gEnd = gStart; } //XMLElement *blue = col->FirstChildElement("blue"); XMLElement *blue = brot->FirstChildElement("blue"); if(red != NULL){ blue->QueryFloatAttribute("start", &bStart); blue->QueryFloatAttribute("end", &bEnd); if(bStart < 0.0f) bStart = 0.0f; if(bStart > 1.0f) bStart = 1.0f; if(bEnd < bStart) bEnd = bStart; } //} // -- read orbit mode brot->QueryIntAttribute("orbitMode", &orbitMode); if(orbitMode < 0) orbitMode = 0; if(orbitMode > 2) orbitMode = 2; // -- read viewport settings (x/y scale and x/y offset) if set XMLElement* viewport = brot->FirstChildElement("viewport"); if(viewport != NULL){ float sXScale, sYScale, sXOffset, sYOffset; viewport->QueryFloatAttribute("xScale", &sXScale); viewport->QueryFloatAttribute("yScale", &sYScale); viewport->QueryFloatAttribute("xOffset", &sXOffset); viewport->QueryFloatAttribute("yOffset", &sYOffset); //apply read values (can only read floats, no problem, but it's a double internally) xScale = sXScale; yScale = sYScale; xOffset = sXOffset; yOffset = sYOffset; //clamp scales as their internal form (double) if(xScale < 0.) xScale = 0.; if(yScale < 0.) yScale = 0.; } // -- read GA settings if orbit mode is apertures if(orbitMode == 1){ XMLElement* GA = brot->FirstChildElement("GA"); if(GA != NULL){ float sMutStr, sMutStrFocus; GA->QueryFloatAttribute("mutStr", &sMutStr); GA->QueryFloatAttribute("mutStrFocus", &sMutStrFocus); if(sMutStr < 0.f) sMutStr = 0.f; //0. is way too small, but let the user do what they want because it shouldn't cause bugs if(sMutStr > 1.f) sMutStr = 1.f; //1. is huge, same as above if(sMutStrFocus < 0.f) sMutStrFocus = 0.f; if(sMutStrFocus > 1.f) sMutStrFocus = 1.f; //don't even constrain this ^ to be sensible in relation to mutStr, it's the user's choice //apply read values (can only read floats, no problem, but it's a double internally) mutStr = sMutStr; mutStrFocus = sMutStrFocus; GA->QueryIntAttribute("maxMutations", &maxMutations); if(maxMutations < 0) maxMutations = 0; GA->QueryIntAttribute("maxMutationsFocus", &maxMutationsFocus); if(maxMutationsFocus < 0) maxMutationsFocus = 0; //again, don't even constrain this ^ to be sensible in relation to maxMutations, it's the user's choice } } // -- read complex planes to be rendered as x/y brot->QueryIntAttribute("xAxis", &xAxis); brot->QueryIntAttribute("yAxis", &yAxis); //clamp if(xAxis < 0) xAxis = 0; else if(xAxis > 2) xAxis = 2; if(yAxis < 0) yAxis = 0; else if(yAxis > 2) yAxis = 2; // -- read julia seed float sSR = float(sR), sSI = float(sI); brot->QueryFloatAttribute("sR", &sSR); brot->QueryFloatAttribute("sI", &sSI); sR = sSR; sI = sSI; // -- read custom orbit start, if set XMLElement* orbitStart = brot->FirstChildElement("orbitStart"); if(orbitStart != NULL){ doCustomOrbitStart = true; float sOXScale, sOYScale, sOXOffset, sOYOffset; //this "convention" is getting hard to read orbitStart->QueryFloatAttribute("xScale", &sOXScale); orbitStart->QueryFloatAttribute("yScale", &sOYScale); orbitStart->QueryFloatAttribute("xOffset", &sOXOffset); orbitStart->QueryFloatAttribute("yOffset", &sOYOffset); //apply read values (can only read floats, no problem, but it's a double internally) orbitXScale = sOXScale; orbitYScale = sOYScale; orbitXOffset = sOXOffset; orbitYOffset = sOYOffset; //clamp scales as their internal form (double) if(orbitXScale < 0.) orbitXScale = 0.; if(orbitYScale < 0.) orbitYScale = 0.; } // -- some more boolean values brot->QueryBoolAttribute("paintStartMap", &paintStartMap); brot->QueryBoolAttribute("randImaginary", &fourDims); brot->QueryBoolAttribute("paintMirror", &paintMirror); brot->QueryBoolAttribute("skipIsOutsideMandel", &skipIsOutsideMandel); brot->QueryBoolAttribute("forceSkipIsOutsideMandel", &forceSkipIsOutsideMandel); // -- should also add int-based colour ranges // -- allowing the start paint value to be specified instead of it being automated to the minimum colour range would also be good break; //don't infinite loop } delete settingsFile; //deconstruct the settings file return 1; //success }
27.391775
188
0.642197
Bozebo
72cf4197d08588a29618b64b9f8326a27d550bd8
2,649
cpp
C++
src/engine/memory/managermusic.cpp
FoFabien/SF2DEngine
3d10964cbdae439584c10ab427ade394d720713f
[ "Zlib" ]
null
null
null
src/engine/memory/managermusic.cpp
FoFabien/SF2DEngine
3d10964cbdae439584c10ab427ade394d720713f
[ "Zlib" ]
null
null
null
src/engine/memory/managermusic.cpp
FoFabien/SF2DEngine
3d10964cbdae439584c10ab427ade394d720713f
[ "Zlib" ]
null
null
null
#include "managermusic.hpp" #ifdef _USE_MUSIC_ #include "../engine.hpp" #define MAX_MUSIC_COUNT 105 ManagerMusic::ManagerMusic() { } ManagerMusic::~ManagerMusic() { for(auto &i : data) { i.second.ptr->stop(); delete (i.second.ptr); } } bool ManagerMusic::load(const std::string &name) { std::map<std::string, MusicContainer>::iterator it = data.find(name); if(it == data.end()) { MusicContainer tmp; tmp.ptr = new Music(); if(!tmp.ptr->load(name)) { delete tmp.ptr; return false; } data[name] = tmp; } data[name].toDelete = false; return true; } void ManagerMusic::unload(const std::string &name) { std::map<std::string, MusicContainer>::iterator it = data.find(name); if(it != data.end()) it->second.toDelete = true; } void ManagerMusic::play(const std::string &name) { if(data.size() >= MAX_MUSIC_COUNT) return; if(load(name)) { data[name].ptr->setVolume(engine.masterVolume); data[name].ptr->play(); } } void ManagerMusic::pause(const std::string &name) { if(data.find(name) != data.end()) { data[name].ptr->pause(); } } void ManagerMusic::stop(const std::string &name) { if(data.find(name) != data.end()) { data[name].ptr->stop(); } } std::vector<std::string> ManagerMusic::getMusicList() const { std::vector<std::string> l; l.reserve(data.size()); for(auto &i : data) l.push_back(i.first); return l; } void ManagerMusic::setLoop(const std::string &name, bool b, int32_t start, int32_t end) { if(data.find(name) != data.end()) { data[name].ptr->loop(b, start, end); } } void ManagerMusic::garbageCollection() { std::map<std::string, MusicContainer>::iterator it = data.begin(); std::map<std::string, MusicContainer>::iterator tmp; while(it != data.end()) { if(it->second.toDelete) { delete it->second.ptr; tmp = it; ++it; data.erase(tmp); } else ++it; } } void ManagerMusic::update() { for(auto &i : data) i.second.ptr->update(); } void ManagerMusic::setVolume(const std::string &name, float v) { if(data.find(name) != data.end()) { data[name].ptr->setVolume(v); } } void ManagerMusic::updateVolume() { for(auto &i : data) { i.second.ptr->setVolume(engine.masterVolume); } } void ManagerMusic::clear() { for(auto &i : data) { i.second.ptr->stop(); delete (i.second.ptr); } data.clear(); } #endif
19.195652
87
0.567761
FoFabien
72cfb271bfa82b0d5a733965b933eb1095e70d8b
866
hpp
C++
Enemy.hpp
polinaucc/galaga
6feea0a6a74669c5d3fa6e106653ceacda19b416
[ "MIT" ]
null
null
null
Enemy.hpp
polinaucc/galaga
6feea0a6a74669c5d3fa6e106653ceacda19b416
[ "MIT" ]
null
null
null
Enemy.hpp
polinaucc/galaga
6feea0a6a74669c5d3fa6e106653ceacda19b416
[ "MIT" ]
null
null
null
#pragma once #include "livingobject.hpp" enum class EnemyType { green, purple }; class Enemy : public LivingObject { private: mutable bool m_state; mutable int m_counter; EnemyType m_type; protected: shared_ptr<Sprite> m_sprite_b; public: Enemy(double x, double y, shared_ptr<Sprite> s1, shared_ptr<Sprite> s2, unsigned int lives, EnemyType type): LivingObject(x, y, s1, lives), m_sprite_b(s2), m_state(false), m_counter(0), m_type(type) {} virtual shared_ptr<Sprite> const sprite() const override; virtual void on_tick() override {} virtual EnemyType type() const {return m_type; } static shared_ptr<Enemy> create(double x, double y, EnemyType type); }; class GreenEnemy: public Enemy { public: GreenEnemy(double x, double y); }; class PurpleEnemy: public Enemy { public: PurpleEnemy(double x, double y); };
21.65
112
0.711316
polinaucc
72d46de2edec4d6e4375be7c006ac9b0ce47b791
16,952
cc
C++
common/test/symbolic_simplification_test.cc
RobotLocomotion/drake-python3.7
ae397a4c6985262d23e9675b9bf3927c08d027f5
[ "BSD-3-Clause" ]
2
2021-02-25T02:01:02.000Z
2021-03-17T04:52:04.000Z
common/test/symbolic_simplification_test.cc
RobotLocomotion/drake-python3.7
ae397a4c6985262d23e9675b9bf3927c08d027f5
[ "BSD-3-Clause" ]
null
null
null
common/test/symbolic_simplification_test.cc
RobotLocomotion/drake-python3.7
ae397a4c6985262d23e9675b9bf3927c08d027f5
[ "BSD-3-Clause" ]
1
2021-06-13T12:05:39.000Z
2021-06-13T12:05:39.000Z
#include "drake/common/symbolic_simplification.h" #include <functional> #include <stdexcept> #include <gtest/gtest.h> #include "drake/common/test_utilities/symbolic_test_util.h" namespace drake { namespace symbolic { namespace { using std::function; using std::runtime_error; using test::ExprEqual; class SymbolicUnificationTest : public ::testing::Test { protected: // Provides common variables that are used by the following tests. const Variable x_{"x"}; const Variable y_{"y"}; const Variable z_{"z"}; const Variable a_{"a"}; const Variable b_{"b"}; const Variable c_{"c"}; }; TEST_F(SymbolicUnificationTest, VariableSuccess) { // Rule: x => x + 1 const RewritingRule rule{x_, x_ + 1}; const Rewriter rewriter = MakeRuleRewriter(rule); const Expression e1{a_ + b_}; // The `rewriter` matches the whole `a + b` with the LHS of the rule, `x`, and // generates a substitution, {x ↦ a + b}. Then, it applies the substitution to // the RHS of the rule, `x + 1`, resulting in `a + b + 1`. // // Note that this is *not* a congruence-rewriter which would traverse the // expression `a + b`, rewrite `a` to `a + 1` and `b` to `b + 1`, and return // `(a + 1) + (b + 1)`, which is `a + b + 2`. EXPECT_PRED2(ExprEqual, rewriter(e1), a_ + b_ + 1); const Expression e2{sin(a_)}; EXPECT_PRED2(ExprEqual, rewriter(e2), sin(a_) + 1); } TEST_F(SymbolicUnificationTest, VariableFailure) { // Rule: pow(x, x) => pow(x + 1, x + 2). const RewritingRule rule{pow(x_, x_), pow(x_ + 1, x_ + 2)}; const Rewriter rewriter = MakeRuleRewriter(rule); // Fails to match pow(a, b) with the above rule // since we can't have x ↦ a and x ↦ b at the same time. const Expression e{pow(a_, b_)}; EXPECT_PRED2(ExprEqual, rewriter(e), e /* no change */); } TEST_F(SymbolicUnificationTest, ConstantSuccess) { // Rule: 3 => 5. const RewritingRule rule{3, 5}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites 3 to 5. const Expression e{3}; EXPECT_PRED2(ExprEqual, rewriter(e), 5); } TEST_F(SymbolicUnificationTest, ConstantFailure) { // Rule: 3 => 5. const RewritingRule rule{3, 5}; const Rewriter rewriter = MakeRuleRewriter(rule); // Fails to match 4 with with the above rule. const Expression e{4}; EXPECT_PRED2(ExprEqual, rewriter(e), e /* no change */); } TEST_F(SymbolicUnificationTest, AdditionSuccessNonZeroCoeff) { // Rule: 2 + x + y => 3 + 4x + 5y. const RewritingRule rule{2 + x_ + y_, 3 + 4 * x_ + 5 * y_}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites 2 + 2a + 3b to 3 + 4(2a) + 5(3b). // Example of Case 4 in UnificationVisitor::VisitAddition. const Expression e1{2 + 2 * a_ + 3 * b_}; EXPECT_PRED2(ExprEqual, rewriter(e1), 3 + 8 * a_ + 15 * b_); // It rewrites 2 + 2a + 3b + 5c to 3 + 4(2a) + 5(3b + 5c). // Example of Case 4 in UnificationVisitor::VisitAddition. const Expression e2{2 + 2 * a_ + 3 * b_ + 5 * c_}; EXPECT_PRED2(ExprEqual, rewriter(e2), 3 + 4 * 2 * a_ + 5 * (3 * b_ + 5 * c_)); } // This is an example of the Case 1 in the description of // UnificationVisitor::VisitAddition method. TEST_F(SymbolicUnificationTest, AdditionSuccessZeroCoeff) { // Rule: x + y => 2x + 3y const RewritingRule rule{x_ + y_, 2 * x_ + 3 * y_}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites a + b => 2a + 3b // Example of Case 1 in UnificationVisitor::VisitAddition. const Expression e1{a_ + b_}; EXPECT_PRED2(ExprEqual, rewriter(e1), 2 * a_ + 3 * b_); // It rewrites 1 + 2a => 2 + 6a // Example of Case 2 in UnificationVisitor::VisitAddition. const Expression e2{1 + 2 * a_}; EXPECT_PRED2(ExprEqual, rewriter(e2), 2 + 6 * a_); } TEST_F(SymbolicUnificationTest, AdditionFailureNonZeroCoeff) { // Rule: 2 + sin(x) + cos(y) => 3 + 4x + 5y. const RewritingRule rule{2 + sin(x_) + cos(y_), 3 + 4 * x_ + 5 * y_}; const Rewriter rewriter = MakeRuleRewriter(rule); // Fails to match the following with with the above rule (constant // mismatched). // Example of Case 4 in UnificationVisitor::VisitAddition. const Expression e1{5 + sin(a_) + cos(b_)}; EXPECT_PRED2(ExprEqual, rewriter(e1), e1 /* no change */); // Fails to match the following with with the above rule (length). // Example of Case 4 in UnificationVisitor::VisitAddition. const Expression e2{2 + sin(a_)}; EXPECT_PRED2(ExprEqual, rewriter(e2), e2 /* no change */); // Fails to match the following with with the above rule (sin != cos). // Example of Case 4 in UnificationVisitor::VisitAddition. const Expression e3{2 + cos(a_) + cos(b_)}; EXPECT_PRED2(ExprEqual, rewriter(e3), e3 /* no change */); // Fails to match the following with with the above rule (cos != tan). // Example of Case 4 in UnificationVisitor::VisitAddition. const Expression e4{2 + sin(a_) + tan(b_)}; EXPECT_PRED2(ExprEqual, rewriter(e4), e4 /* no change */); // Fails to match the following with with the above rule (coefficient // mismatched). // Example of Case 3 in UnificationVisitor::VisitAddition. const Expression e5{sin(a_) + cos(b_)}; EXPECT_PRED2(ExprEqual, rewriter(e5), e5 /* no change */); } TEST_F(SymbolicUnificationTest, AdditionFailureZeroCoeff) { // Rule: sin(x) + cos(y) + sin(z) => x + y + z. const RewritingRule rule{sin(x_) + cos(y_) + sin(z_), x_ + y_ + z_}; const Rewriter rewriter = MakeRuleRewriter(rule); // Fails to match the following with with the above rule (not addition). const Expression e1{cos(a_)}; EXPECT_PRED2(ExprEqual, rewriter(e1), e1 /* no change */); // Fails to match the following with with the above rule (length). // Example of Case 2 in UnificationVisitor::VisitAddition. const Expression e2{3 + cos(a_)}; EXPECT_PRED2(ExprEqual, rewriter(e2), e2 /* no change */); // Fails to match the following with with the above rule (sin(x) vs 1). // Example of Case 2 in UnificationVisitor::VisitAddition. const Expression e3{1 + log(a_) + abs(b_)}; EXPECT_PRED2(ExprEqual, rewriter(e3), e3 /* no change */); // Fails to match the following with with the above rule (sin != tan). // Example of Case 1 in UnificationVisitor::VisitAddition. const Expression e4{sin(b_) + cos(a_) + tan(c_)}; EXPECT_PRED2(ExprEqual, rewriter(e4), e4 /* no change */); } TEST_F(SymbolicUnificationTest, UnaryMinus) { // -x => x. const RewritingRule rule{-x_, x_}; const Rewriter rewriter = MakeRuleRewriter(rule); const Expression e1{-a_}; const Expression expected1{a_}; EXPECT_PRED2(ExprEqual, rewriter(e1), expected1); const Expression e2{-2 * a_}; const Expression expected2{2 * a_}; EXPECT_PRED2(ExprEqual, rewriter(e2), expected2); } TEST_F(SymbolicUnificationTest, MultiplicationSuccess1) { // Rule: x * y => x + y const RewritingRule rule{x_ * y_, x_ + y_}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites a * b to a + b. // Example of Case 1 in UnificationVisitor::VisitMultiplication. const Expression e1{a_ * b_}; EXPECT_PRED2(ExprEqual, rewriter(e1), a_ + b_); // It rewrites 3 * a to 3 + a. // Example of Case 2 in UnificationVisitor::VisitMultiplication. const Expression e2{3 * a_}; EXPECT_PRED2(ExprEqual, rewriter(e2), 3 + a_); } TEST_F(SymbolicUnificationTest, MultiplicationSuccess2) { // Rule: x * pow(sin(y), 2) * cos(z) // => x * pow(sin(y), 3) * tan(z). const RewritingRule rule{x_ * pow(sin(y_), 2) * cos(z_), x_ * pow(sin(y_), 3) * tan(z_)}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites a*sin²(y)cos(z) to a sin³(y)tan(z). // Example of Case 1 in UnificationVisitor::VisitMultiplication. const Expression e{a_ * pow(sin(b_), 2) * cos(c_)}; EXPECT_PRED2(ExprEqual, rewriter(e), a_ * pow(sin(b_), 3) * tan(c_)); } TEST_F(SymbolicUnificationTest, MultiplicationSuccess3) { // Rule: 2 * x * y => x + y. const RewritingRule rule{2 * x_ * y_, x_ + y_}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites 2 * a * b to a + b. // Example of Case 4 in UnificationVisitor::VisitMultiplication. const Expression e{2 * a_ * b_}; EXPECT_PRED2(ExprEqual, rewriter(e), a_ + b_); } TEST_F(SymbolicUnificationTest, MultiplicationFailure1) { // Rule: 3pow(sin(x), cos(y))tan(z) // => 4pow(x, y)pow(2, z) const RewritingRule rule{3 * pow(sin(x_), cos(y_)) * tan(z_), 4 * pow(x_, y_) * pow(2, z_)}; const Rewriter rewriter = MakeRuleRewriter(rule); // Fails to match the following with with the above rule. // Example of Case 3 in UnificationVisitor::VisitMultiplication. const Expression e{pow(cos(a_), c_) * cos(b_)}; EXPECT_PRED2(ExprEqual, rewriter(e), e /* no change */); } TEST_F(SymbolicUnificationTest, MultiplicationFailure2) { // Rule: sin(x) * cos(y) * tan(z) // => x + y + z const RewritingRule rule{sin(x_) * cos(y_) * tan(z_), x_ + y_ + z_}; const Rewriter rewriter = MakeRuleRewriter(rule); // Fails to match the following with with the above rule. // Example of Case 1 in UnificationVisitor::VisitMultiplication. const Expression e1{sin(a_) * acos(b_) * tan(c_)}; EXPECT_PRED2(ExprEqual, rewriter(e1), e1 /* no change */); // Fails to match the following with with the above rule. // Example of Case 1 in UnificationVisitor::VisitMultiplication. const Expression e2{a_ * sin(b_)}; EXPECT_PRED2(ExprEqual, rewriter(e2), e2 /* no change */); // Fails to match the following with with the above rule. // Example of Case 2 in UnificationVisitor::VisitMultiplication. const Expression e3{5 * cos(b_) * tan(z_)}; EXPECT_PRED2(ExprEqual, rewriter(e3), e3 /* no change */); // Fails to match the following with with the above rule. const Expression e4{5}; EXPECT_PRED2(ExprEqual, rewriter(e4), e4 /* no change */); } TEST_F(SymbolicUnificationTest, MultiplicationFailure3) { // Rule: 2 * x * y * z => x + y + z. const RewritingRule rule{2 * x_ * y_ * z_, x_ + y_ + z_}; const Rewriter rewriter = MakeRuleRewriter(rule); // Fails to match the following with with the above rule (coefficients). // Example of Case 4 in UnificationVisitor::VisitMultiplication. const Expression e1{3 * a_ * b_ * c_}; EXPECT_PRED2(ExprEqual, rewriter(e1), e1 /* no change */); // Fails to match the following with with the above rule (length). // Example of Case 4 in UnificationVisitor::VisitMultiplication. const Expression e2{3 * a_ * b_}; EXPECT_PRED2(ExprEqual, rewriter(e2), e2 /* no change */); } TEST_F(SymbolicUnificationTest, MultiplicationFailure4) { // Rule: x * y * z => x + y + z. const RewritingRule rule{x_ * y_ * z_, x_ + y_ + z_}; const Rewriter rewriter = MakeRuleRewriter(rule); // Fails to match the following with with the above rule. // Example of Case 2 in UnificationVisitor::VisitMultiplication. const Expression e{3 * a_}; EXPECT_PRED2(ExprEqual, rewriter(e), e /* no change */); } // https://github.com/google/googletest/issues/1610 enum UnaryTestOp { Abs, Log, Exp, Sqrt, Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Tanh, Ceil, Floor }; std::function<Expression(const Variable& x)>UnaryOpToFunction(UnaryTestOp op) { switch (op) { case Abs: return [](const Variable& x) { return abs(x); }; case Log: return [](const Variable& x) { return log(x); }; case Exp: return [](const Variable& x) { return exp(x); }; case Sqrt: return [](const Variable& x) { return sqrt(x); }; case Sin: return [](const Variable& x) { return sin(x); }; case Cos: return [](const Variable& x) { return cos(x); }; case Tan: return [](const Variable& x) { return tan(x); }; case Asin: return [](const Variable& x) { return asin(x); }; case Acos: return [](const Variable& x) { return acos(x); }; case Atan: return [](const Variable& x) { return atan(x); }; case Sinh: return [](const Variable& x) { return sinh(x); }; case Cosh: return [](const Variable& x) { return cosh(x); }; case Tanh: return [](const Variable& x) { return tanh(x); }; case Ceil: return [](const Variable& x) { return ceil(x); }; case Floor: return [](const Variable& x) { return floor(x); }; } DRAKE_UNREACHABLE(); } class SymbolicUnificationTestUnary : public ::testing::TestWithParam<UnaryTestOp> { protected: const Variable x_{"x"}; const Variable a_{"a"}; }; TEST_P(SymbolicUnificationTestUnary, Check) { const Expression& lhs = UnaryOpToFunction(GetParam())(x_); const RewritingRule rule{lhs, x_}; const Rewriter rewriter = MakeRuleRewriter(rule); const Expression& e1 = UnaryOpToFunction(GetParam())(a_); EXPECT_PRED2(ExprEqual, rewriter(e1), a_); const Expression e2{a_ * a_}; EXPECT_PRED2(ExprEqual, rewriter(e2), e2 /* no change */); } INSTANTIATE_TEST_SUITE_P( UnaryCases, SymbolicUnificationTestUnary, ::testing::Values( Abs, Log, Exp, Sqrt, Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Tanh, Ceil, Floor )); // https://github.com/google/googletest/issues/1610 enum BinaryTestOp { Pow, Div, Min, Max, Atan2 }; std::function<Expression(const Variable&, const Variable&)> BinaryOpToFunction(BinaryTestOp op) { switch (op) { case Pow: return [](const Variable& x, const Variable& y) { return pow(x, y); }; case Div: return [](const Variable& x, const Variable& y) { return x / y; }; case Min: return [](const Variable& x, const Variable& y) { return min(x, y); }; case Max: return [](const Variable& x, const Variable& y) { return max(x, y); }; case Atan2: return [](const Variable& x, const Variable& y) { return atan2(x, y); }; } // Should not be reachable. DRAKE_UNREACHABLE(); } class SymbolicUnificationTestBinary : public ::testing::TestWithParam<BinaryTestOp> { protected: const Variable x_{"x"}; const Variable y_{"y"}; const Variable a_{"a"}; const Variable b_{"b"}; }; TEST_P(SymbolicUnificationTestBinary, Check) { const Expression& lhs = BinaryOpToFunction(GetParam())(x_, y_); const RewritingRule rule{lhs, x_ + y_}; const Rewriter rewriter = MakeRuleRewriter(rule); const Expression& e1 = BinaryOpToFunction(GetParam())(a_, b_); EXPECT_PRED2(ExprEqual, rewriter(e1), a_ + b_); const Expression e2{a_ + b_}; EXPECT_PRED2(ExprEqual, rewriter(e2), e2 /* no change */); } INSTANTIATE_TEST_SUITE_P( BinaryCases, SymbolicUnificationTestBinary, ::testing::Values(Pow, Div, Min, Max, Atan2)); TEST_F(SymbolicUnificationTest, IfThenElse) { // Not supported. const RewritingRule rule{if_then_else(x_ > y_, x_, y_), x_ + 2 * y_}; const Rewriter rewriter = MakeRuleRewriter(rule); const Expression e{if_then_else(a_ > b_, a_, b_)}; EXPECT_THROW(rewriter(e), runtime_error); } TEST_F(SymbolicUnificationTest, UninterpretedFunction) { // Not supported. const RewritingRule rule{uninterpreted_function("uf", {x_}), x_}; const Rewriter rewriter = MakeRuleRewriter(rule); const Expression e{uninterpreted_function("uf", {a_})}; EXPECT_THROW(rewriter(e), runtime_error); } TEST_F(SymbolicUnificationTest, CheckCommonTrigIdentities1) { // Rule: sin²(x) + cos²(y) => 1. const RewritingRule rule{pow(sin(x_), 2) + pow(cos(y_), 2), 1}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites cos²(a + b) + sin²(a + b) to 1.0. const Expression e{pow(cos(a_ + b_), 2) + pow(sin(a_ + b_), 2)}; EXPECT_PRED2(ExprEqual, rewriter(e), 1.0); } TEST_F(SymbolicUnificationTest, CheckCommonTrigIdentities2) { // Rule: sin(x + y) => sin(x)cos(y) + cos(x)sin(y). const RewritingRule rule{sin(x_ + y_), sin(x_) * cos(y_) + cos(x_) * sin(y_)}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites sin(2a + 3b) = sin(2a)cos(3b) + cos(3b)sin(2a). const Expression e{sin(2 * a_ + 3 * b_)}; EXPECT_PRED2(ExprEqual, rewriter(e), sin(2 * a_) * cos(3 * b_) + cos(2 * a_) * sin(3 * b_)); } TEST_F(SymbolicUnificationTest, CheckCommonTrigIdentities3) { // Rule: tan(x - y) => (tan(x) - tan(y)) / (1 + tan(x)*tan(y)). const RewritingRule rule{tan(x_ - y_), (tan(x_) - tan(y_)) / (1 + tan(x_) * tan(y_))}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites tan(2a - 3b) = (tan(2a) - tan(3b)) / (1 + tan(2a)*tan(3b)). const Expression e{tan(2 * a_ - 3 * b_)}; EXPECT_PRED2(ExprEqual, rewriter(e), (tan(2 * a_) - tan(3 * b_)) / (1 + tan(2 * a_) * tan(3 * b_))); } TEST_F(SymbolicUnificationTest, CheckCommonTrigIdentities4) { // Rule: cos(x) - cos(y) => -2sin((x + y)/2)sin((x - y)/2). const RewritingRule rule{cos(x_) - cos(y_), -2 * sin((x_ + y_) / 2) * sin((x_ - y_) / 2)}; const Rewriter rewriter = MakeRuleRewriter(rule); // It rewrites cos(2a) - cos(4a) => -2sin((2a + 4a)/2)sin((2a - 4a) /2). const Expression e{cos(2 * a_) - cos(4 * a_)}; EXPECT_PRED2(ExprEqual, rewriter(e), -2 * sin(6 * a_ / 2) * sin(-2 * a_ / 2)); } } // namespace } // namespace symbolic } // namespace drake
39.331787
80
0.663285
RobotLocomotion
72d87bc37bd77a2ba4912e02cbe84d9249aeecc9
1,387
hpp
C++
tvm_backend/tvm_backend.hpp
elvin-n/dldt_tools
d77b11aafc389f68305b2514db306c3c0b42cddf
[ "MIT" ]
2
2020-06-20T02:54:37.000Z
2020-07-17T04:38:26.000Z
tvm_backend/tvm_backend.hpp
elvin-nnov/dldt_tools
d77b11aafc389f68305b2514db306c3c0b42cddf
[ "MIT" ]
null
null
null
tvm_backend/tvm_backend.hpp
elvin-nnov/dldt_tools
d77b11aafc389f68305b2514db306c3c0b42cddf
[ "MIT" ]
1
2020-02-11T14:21:32.000Z
2020-02-11T14:21:32.000Z
// Copyright 2021 the dldt tools authors. All rights reserved. // Use of this source code is governed by a BSD-style license #include "backend.hpp" #include "tvm/runtime/module.h" extern "C" { Backend* createBackend(); } class TVMBackend : public Backend { public: virtual bool loadModel(const std::string &model, const std::string &device, const std::vector<std::string> &outputs, const std::map<std::string, std::string>& config)override; virtual std::shared_ptr<InferenceMetrics> process(bool streamOutput = false)override { return nullptr; } virtual void report(const InferenceMetrics &im) const override; virtual bool infer()override; virtual void release()override; virtual std::shared_ptr<VBlob> getBlob(const std::string &name)override; virtual VInputInfo getInputDataMap() const override; virtual VOutputInfo getOutputDataMap() const override; protected: tvm::runtime::PackedFunc run_; tvm::runtime::PackedFunc setInput_; tvm::runtime::PackedFunc getInput_; tvm::runtime::PackedFunc getOutput_; tvm::runtime::Module gmod_; DLDevice ctx_; // TODO: which object retain TVM network not to be released? tvm::runtime::Module mod_factory_; tvm::runtime::NDArray x_, y_; std::map<std::string, std::shared_ptr<VBlob> > _blobs; VInputInfo _inputInfo; VOutputInfo _outputInfo; };
30.822222
86
0.719539
elvin-n
72d977939da19ca1218598fd9ee399e38ef04eb7
3,090
hpp
C++
include/operations/CompoundOperation.hpp
TobiasPrie/qfr
843db11651763ac3aecf10c9aa0dffebdd572055
[ "MIT" ]
null
null
null
include/operations/CompoundOperation.hpp
TobiasPrie/qfr
843db11651763ac3aecf10c9aa0dffebdd572055
[ "MIT" ]
1
2021-08-09T18:42:16.000Z
2021-08-09T18:42:16.000Z
include/operations/CompoundOperation.hpp
TobiasPrie/qfr
843db11651763ac3aecf10c9aa0dffebdd572055
[ "MIT" ]
1
2021-08-08T08:55:10.000Z
2021-08-08T08:55:10.000Z
/* * This file is part of IIC-JKU QFR library which is released under the MIT license. * See file README.md or go to http://iic.jku.at/eda/research/quantum/ for more information. */ #ifndef INTERMEDIATEREPRESENTATION_COMPOUNDOPERATION_H #define INTERMEDIATEREPRESENTATION_COMPOUNDOPERATION_H #include "Operation.hpp" namespace qc { class CompoundOperation : public Operation { protected: std::vector<std::shared_ptr<Operation>> ops{ }; public: explicit CompoundOperation(unsigned short nq) { std::strcpy(name, "Compound operation:"); nqubits = nq; } template<class T, class... Args> auto emplace_back(Args&& ... args) { parameter[0]++; return ops.emplace_back(std::make_shared<T>(args ...)); } void setNqubits(unsigned short nq) override { nqubits = nq; for (auto& op:ops) { op->setNqubits(nq); } } dd::Edge getDD(std::unique_ptr<dd::Package>& dd, std::array<short, MAX_QUBITS>& line) const override { dd::Edge e = dd->makeIdent(0, short(nqubits - 1)); for (auto& op: ops) { e = dd->multiply(op->getDD(dd, line), e); } return e; } dd::Edge getInverseDD(std::unique_ptr<dd::Package>& dd, std::array<short, MAX_QUBITS>& line) const override { dd::Edge e = dd->makeIdent(0, short(nqubits - 1)); for (auto& op: ops) { e = dd->multiply(e, op->getInverseDD(dd, line)); } return e; } dd::Edge getDD(std::unique_ptr<dd::Package>& dd, std::array<short, MAX_QUBITS>& line, std::map<unsigned short, unsigned short>& permutation) const override { dd::Edge e = dd->makeIdent(0, short(nqubits - 1)); for (auto& op: ops) { e = dd->multiply(op->getDD(dd, line, permutation), e); } return e; } dd::Edge getInverseDD(std::unique_ptr<dd::Package>& dd, std::array<short, MAX_QUBITS>& line, std::map<unsigned short, unsigned short>& permutation) const override { dd::Edge e = dd->makeIdent(0, short(nqubits - 1)); for (auto& op: ops) { e = dd->multiply(e, op->getInverseDD(dd, line, permutation)); } return e; } std::ostream& print(std::ostream& os) const override { return print(os, standardPermutation); } std::ostream& print(std::ostream& os, const std::map<unsigned short, unsigned short>& permutation) const override { os << name; for (const auto & op : ops) { os << std::endl << "\t\t"; op->print(os, permutation); } return os; } bool actsOn(unsigned short i) override { for (const auto& op: ops) { if(op->actsOn(i)) return true; } return false; } void dumpOpenQASM(std::ofstream& of, const regnames_t& qreg, const regnames_t& creg) const override { for (auto& op: ops) { op->dumpOpenQASM(of, qreg, creg); } } void dumpReal(std::ofstream& of) const override { for (auto& op: ops) { op->dumpReal(of); } } void dumpQiskit(std::ofstream& of, const regnames_t& qreg, const regnames_t& creg, const char *anc_reg_name) const override { for (auto& op: ops) { op->dumpQiskit(of, qreg, creg, anc_reg_name); } } }; } #endif //INTERMEDIATEREPRESENTATION_COMPOUNDOPERATION_H
28.348624
166
0.653398
TobiasPrie
72db52bf57e9bd068259dc6b3f3ab19f284d8d9b
529
cpp
C++
Exam_3/Program4.cpp
othneildrew/CPP-Programming-Practices
27a20c00b395446a7d2e0dd4b199f4cd9e35591b
[ "MIT" ]
1
2020-12-03T15:26:20.000Z
2020-12-03T15:26:20.000Z
Exam_3/Program4.cpp
othneildrew/CPP-Programming-Practices
27a20c00b395446a7d2e0dd4b199f4cd9e35591b
[ "MIT" ]
null
null
null
Exam_3/Program4.cpp
othneildrew/CPP-Programming-Practices
27a20c00b395446a7d2e0dd4b199f4cd9e35591b
[ "MIT" ]
null
null
null
// Exam 3 - Program 4 /*** Write a C++ Program to find the 15 sequences of Fibonacci number. **/ # include <iostream> using namespace std; int main(void) { int Num1 = 0, Num2 = 1, Result = 0, Generation = 15; cout << "\n\t This program finds the fibonacci number after the 15th generation \n"; while (Result <= Generation) { Num1 = Num2; Num2 = Result; Result = Num1 + Num2; } cout << "Fibonacci Number (15th generation) = " << Result << endl; system("pause"); return 0; } // Code written by: Othneil Drew
18.241379
85
0.642722
othneildrew
72dbb6b45ba77fcab92d7e0471026d4f4dea3b6a
880
hpp
C++
ms29/classes/camera.hpp
LeeFoulger/ProxyDll
d8dd9e736055f3263ac8b1671d009c88dc4ecc04
[ "MIT" ]
1
2022-03-15T21:29:19.000Z
2022-03-15T21:29:19.000Z
ms29/classes/camera.hpp
TwisterForPosterity/ProxyDll
d8dd9e736055f3263ac8b1671d009c88dc4ecc04
[ "MIT" ]
null
null
null
ms29/classes/camera.hpp
TwisterForPosterity/ProxyDll
d8dd9e736055f3263ac8b1671d009c88dc4ecc04
[ "MIT" ]
null
null
null
#pragma once #include <Utils.hpp> #include "../memory/local_types.hpp" char __cdecl sub_553660_hook(uint8_t *a1) { auto result = ((char(__cdecl *)(uint8_t *))GetMainModule(0x153660))(a1); auto fov = ((s_camera_definition*)a1)->Print(true, true, true, true)->field_of_view.Get(); auto new_val = fov < 90 ? Utils::Math::Map<float>(fov, 55, 70, 1.15, 1.0) : Utils::Math::Map<float>(fov, 55, 120, 1.15, 0.7); *(float *)0x1913434 = new_val + fov < 90 ? new_val + 0.0f : fov < 110 ? new_val + 0.05f : fov < 110 ? new_val + 0.15f : new_val + 0.20f; return result; } inline void SubmitCameraHooks(const char *name) { if (ConfigManager.GetBool("Hooks", name)) { HookManager.Submit({ 0x0054690A }, &sub_553660_hook, "camera_definition_validate", HookFlags::IsCall); } } inline void SubmitCameraPatches(const char *name) { if (ConfigManager.GetBool("Patches", name)) { } }
29.333333
137
0.681818
LeeFoulger
72e10863746800a7ea27c702a72b860ec2265d9e
1,510
hh
C++
Reference/HongLi/include/nrmatrix.hh
clwyatt/CTC
284d52dc888bcd997214804715fe690149e33f85
[ "BSD-3-Clause" ]
1
2019-07-29T02:04:06.000Z
2019-07-29T02:04:06.000Z
Reference/HongLi/include/nrmatrix.hh
clwyatt/CTC
284d52dc888bcd997214804715fe690149e33f85
[ "BSD-3-Clause" ]
null
null
null
Reference/HongLi/include/nrmatrix.hh
clwyatt/CTC
284d52dc888bcd997214804715fe690149e33f85
[ "BSD-3-Clause" ]
null
null
null
/*************************************************************************** File: nrmatrix.hh Abstract: allocate a memory block for a matrix Created: 09/2001 (C) 2002 by Wake Forest University School of Medicine Last Revision ($Revision: 1.1.1.1 $) by $Author: hongli $ on $Date: 2002/12/06 21:49:30 $ ***************************************************************************/ #ifndef _MATRIX_HH_ #define _MATRIX_HH_ #include <stdlib.h> #include "nrerror.h" template <class T> T **matrix(int nrl,int nrh,int ncl,int nch); /** * A function template for allocate memory block for a matrix * kernel code comes from 'Numeric Recipe'. It is modified as a template * for various data type. * @param nrl the start row subscript for the matrix * @param nrh the end row subscript for the matrix * @param ncl the start column subscript for the matrix * @param nch the end column subscript for the matrix * @return if success, the memory address for the allocated matrix */ template <class T> T **matrix(int nrl,int nrh,int ncl,int nch) /* Allocates a float matrix with range [nrl..nrh] [mcl..nch]. */ { int i; T **m; /* Allocate pointers to rows. */ m=(T **) malloc((unsigned) (nrh-nrl+1)*sizeof(T*)); if (!m) nrerror("allocation failure 1 in matrix()"); m -=nrl; /* Allocate rows and set pointers to them. */ for(i=nrl;i<=nrh;i++) { m[i]=(T *) malloc((unsigned) (nch-ncl+1)*sizeof (T)); if (!m[i]) nrerror("allocation failure 2 in matrix()"); m[i] -= ncl; } return m; } #endif
28.490566
76
0.611921
clwyatt
72e38c593b970a20f3f17ed36bdbd27083e9fe86
7,612
cc
C++
syzygy/pdb/pdb_symbol_record_unittest.cc
StanMiller45/syzygy
2320676a260ab3713c6a4b793ebefa2837cb766c
[ "Apache-2.0" ]
1
2019-04-03T13:56:37.000Z
2019-04-03T13:56:37.000Z
syzygy/pdb/pdb_symbol_record_unittest.cc
StanMiller45/syzygy
2320676a260ab3713c6a4b793ebefa2837cb766c
[ "Apache-2.0" ]
null
null
null
syzygy/pdb/pdb_symbol_record_unittest.cc
StanMiller45/syzygy
2320676a260ab3713c6a4b793ebefa2837cb766c
[ "Apache-2.0" ]
1
2020-10-10T16:09:45.000Z
2020-10-10T16:09:45.000Z
// Copyright 2012 Google Inc. All Rights Reserved. // // 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 "syzygy/pdb/pdb_symbol_record.h" #include "base/bind.h" #include "base/files/file_util.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "syzygy/core/unittest_util.h" #include "syzygy/pdb/pdb_byte_stream.h" #include "syzygy/pdb/unittest_util.h" #include "third_party/cci/Files/CvInfo.h" namespace cci = Microsoft_Cci_Pdb; namespace pdb { namespace { using testing::_; using testing::Return; class PdbVisitSymbolsTest : public testing::Test { public: void SetUpByteStream() { reader = new PdbByteStream(); writer = reader->GetWritablePdbStream(); } scoped_refptr<PdbStream> reader; scoped_refptr<WritablePdbStream> writer; }; class MockVisitorImpl { public: MOCK_METHOD3(Callback, bool(uint16, uint16, PdbStream*)); }; typedef testing::StrictMock<MockVisitorImpl> MockVisitor; } // namespace TEST(PdbReadSymbolRecordTest, ReadValidSymRecordStream) { base::FilePath valid_sym_record_path = testing::GetSrcRelativePath( testing::kValidPdbSymbolRecordStreamPath); scoped_refptr<pdb::PdbFileStream> valid_sym_record_stream = testing::GetStreamFromFile(valid_sym_record_path); SymbolRecordVector symbol_vector; EXPECT_TRUE(ReadSymbolRecord(valid_sym_record_stream.get(), valid_sym_record_stream->length(), &symbol_vector)); } TEST(PdbReadSymbolRecordTest, ReadInvalidSymRecordStream) { base::FilePath invalid_sym_record_path = testing::GetSrcRelativePath( testing::kInvalidPdbSymbolRecordStreamPath); scoped_refptr<pdb::PdbFileStream> invalid_sym_record_stream = testing::GetStreamFromFile(invalid_sym_record_path); SymbolRecordVector symbol_vector; EXPECT_FALSE(ReadSymbolRecord(invalid_sym_record_stream.get(), invalid_sym_record_stream->length(), &symbol_vector)); } TEST_F(PdbVisitSymbolsTest, FailsOnInvalidTableSize) { SetUpByteStream(); writer->Write(static_cast<uint32>(cci::C13)); // Symbol stream type. writer->Write(static_cast<uint16>(4)); // Symbol length. writer->Write(static_cast<uint16>(0x2937)); // Made up symbol type. writer->Write(static_cast<uint16>(0)); // Dummy data. MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // Don't expect any calls to the visitor callback. EXPECT_FALSE( VisitSymbols(callback, 2 * reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, FailsOnMissingStreamType) { SetUpByteStream(); MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // Don't expect any calls to the visitor callback. EXPECT_FALSE(VisitSymbols(callback, reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, FailsOnInvalidStreamType) { SetUpByteStream(); writer->Write(static_cast<uint32>(cci::C11)); // Symbol stream type. writer->Write(static_cast<uint16>(0)); // Symbol length. MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // Don't expect any calls to the visitor callback. EXPECT_FALSE(VisitSymbols(callback, reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, FailsOnMissingSymbolLength) { SetUpByteStream(); writer->Write(static_cast<uint32>(cci::C13)); // Symbol stream type. writer->Write(static_cast<uint8>(1)); // Partial symbol stream length. MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // Don't expect any calls to the visitor callback. EXPECT_FALSE(VisitSymbols(callback, reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, FailsOnShortSymbolLength) { SetUpByteStream(); writer->Write(static_cast<uint32>(cci::C13)); // Symbol stream type. writer->Write(static_cast<uint16>(1)); // Symbol length. MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // Don't expect any calls to the visitor callback. EXPECT_FALSE(VisitSymbols(callback, reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, FailsOnMissingSymbolType) { SetUpByteStream(); writer->Write(static_cast<uint32>(cci::C13)); // Symbol stream type. writer->Write(static_cast<uint16>(4)); // Symbol length. MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // Don't expect any calls to the visitor callback. EXPECT_FALSE(VisitSymbols(callback, reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, FailsOnMissingSymbolData) { SetUpByteStream(); writer->Write(static_cast<uint32>(cci::C13)); // Symbol stream type. writer->Write(static_cast<uint16>(4)); // Symbol length. writer->Write(static_cast<uint16>(0x1337)); // Symbol type. MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // Don't expect any calls to the visitor callback. EXPECT_FALSE(VisitSymbols(callback, reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, SucceedsOnEmptySymbolStream) { SetUpByteStream(); writer->Write(static_cast<uint32>(cci::C13)); // Symbol stream type. writer->Write(static_cast<uint16>(0)); // Symbol length. MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // Don't expect any calls to the visitor callback. EXPECT_TRUE(VisitSymbols(callback, reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, EarlyTermination) { SetUpByteStream(); writer->Write(static_cast<uint32>(cci::C13)); // Symbol stream type. writer->Write(static_cast<uint16>(4)); // Symbol length. writer->Write(static_cast<uint16>(0x2937)); // Made up symbol type. writer->Write(static_cast<uint16>(0)); // Dummy data. MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); EXPECT_CALL(visitor, Callback(_, _, _)).Times(1).WillOnce(Return(false)); EXPECT_FALSE(VisitSymbols(callback, reader->length(), true, reader.get())); } TEST_F(PdbVisitSymbolsTest, AllSymbolsVisitedNoHeader) { base::FilePath valid_sym_record_path = testing::GetSrcRelativePath( testing::kValidPdbSymbolRecordStreamPath); reader = testing::GetStreamFromFile(valid_sym_record_path); MockVisitor visitor; VisitSymbolsCallback callback = base::Bind( &MockVisitor::Callback, base::Unretained(&visitor)); // There are 697 symbols in the sample symbol stream in test_data. EXPECT_CALL(visitor, Callback(_, _, _)).Times(697). WillRepeatedly(Return(true)); EXPECT_TRUE(VisitSymbols(callback, reader->length(), false, reader.get())); } } // namespace pdb
35.240741
77
0.731083
StanMiller45
72e51aaf39e64e9e4b543b50b1dd0e9cfb3b4208
1,179
cpp
C++
CODECHEF/FTRIP.cpp
aqfaridi/Competitve-Programming-Codes
d055de2f42d3d6bc36e03e67804a1dd6b212241f
[ "MIT" ]
null
null
null
CODECHEF/FTRIP.cpp
aqfaridi/Competitve-Programming-Codes
d055de2f42d3d6bc36e03e67804a1dd6b212241f
[ "MIT" ]
null
null
null
CODECHEF/FTRIP.cpp
aqfaridi/Competitve-Programming-Codes
d055de2f42d3d6bc36e03e67804a1dd6b212241f
[ "MIT" ]
null
null
null
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #define MAX 1010 using namespace std; double Nr1[MAX],Nr2[MAX],Dr[MAX]; double nCr1(long long n,long long r) { Nr1[0] = 1.0; for(int i=1;i<=r;i++) Nr1[i] = (Nr1[i-1]*(n-i+1))/i; } double nCr2(long long n,long long r) { Nr2[0] = 1.0; for(int i=1;i<=r;i++) Nr2[i] = (Nr2[i-1]*(n-i+1))/i; } double nCr3(long long n,long r) { Dr[0] = 1.0; for(int i=1;i<=r;i++) Dr[i] = (Dr[i-1]*(n-i+1))/i; } int main() { int t; long long S,N,M,K; scanf("%d",&t); while(t--) { scanf("%lld %lld %lld %lld",&S,&N,&M,&K); if(S==N) { printf("%.6f\n",1.000000); continue; } if(N<K+1) { printf("%.6f\n",0.000000); continue; } nCr3(S-1,N-1); nCr1(M-1,K); nCr2(S-M,N-1); double a = 1.0; a = a/Dr[N-1]; double sum = 0.0; for(int i=0;i<K;i++) sum += (Nr1[i]*Nr2[N-1-i]); a *= sum; a = 1-a; printf("%.6lf\n",a); } return 0; }
19.327869
49
0.425785
aqfaridi
72e5e1c703489a3be21ed60b0d06e6fac3eda5f6
1,920
cpp
C++
src/clear_benchmark.cpp
jlakness-intel/backend-cpu-helib
ff74311abd749809b732f1f2f63fe78e245c726d
[ "Apache-2.0" ]
1
2022-02-28T17:57:32.000Z
2022-02-28T17:57:32.000Z
src/clear_benchmark.cpp
jlakness-intel/backend-cpu-helib
ff74311abd749809b732f1f2f63fe78e245c726d
[ "Apache-2.0" ]
2
2021-12-06T19:37:42.000Z
2021-12-16T23:37:53.000Z
src/clear_benchmark.cpp
jlakness-intel/backend-cpu-helib
ff74311abd749809b732f1f2f63fe78e245c726d
[ "Apache-2.0" ]
1
2021-11-05T18:01:48.000Z
2021-11-05T18:01:48.000Z
// Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #include <algorithm> #include <cstring> #include <memory> #include <vector> #include "../include/clear_benchmark.h" #include "../include/clear_engine.h" #include "../include/clear_error.h" //------------------------ // class ExampleBenchmark //------------------------ ClearTextBenchmark::ClearTextBenchmark(hebench::cpp::BaseEngine &engine, const hebench::APIBridge::BenchmarkDescriptor &bench_desc) : hebench::cpp::BaseBenchmark(engine, bench_desc) { // } ClearTextBenchmark::~ClearTextBenchmark() { // nothing needed in this example } hebench::APIBridge::Handle ClearTextBenchmark::encrypt(hebench::APIBridge::Handle encoded_data) { // we only do plain text in this example, so, just return a copy of our internal data std::shared_ptr<void> p_encoded_data = this->getEngine().template retrieveFromHandle<std::shared_ptr<void>>(encoded_data); // the copy is shallow, but shared_ptr ensures correct destruction using reference counting return this->getEngine().template createHandle<decltype(p_encoded_data)>(encoded_data.size, 0, p_encoded_data); } hebench::APIBridge::Handle ClearTextBenchmark::decrypt(hebench::APIBridge::Handle encrypted_data) { // we only do plain text in this example, so, just return a copy of our internal data std::shared_ptr<void> p_encrypted_data = this->getEngine().template retrieveFromHandle<std::shared_ptr<void>>(encrypted_data); // the copy is shallow, but shared_ptr ensures correct destruction using reference counting return this->getEngine().template createHandle<decltype(p_encrypted_data)>(encrypted_data.size, 0, p_encrypted_data); }
37.647059
102
0.660417
jlakness-intel
72e72d422c2cffcc31d6228dc082f7c7d7bc23bb
3,466
cc
C++
src/cable_plot_options_dialog.cc
Transmission-Line-Software/SpanAnalyzer
37d5f1f849f4c11d83f767b5539845c18ddc371b
[ "Unlicense" ]
4
2017-04-29T19:55:53.000Z
2020-12-20T13:44:03.000Z
src/cable_plot_options_dialog.cc
Transmission-Line-Software/SpanAnalyzer
37d5f1f849f4c11d83f767b5539845c18ddc371b
[ "Unlicense" ]
null
null
null
src/cable_plot_options_dialog.cc
Transmission-Line-Software/SpanAnalyzer
37d5f1f849f4c11d83f767b5539845c18ddc371b
[ "Unlicense" ]
1
2017-12-19T02:13:43.000Z
2017-12-19T02:13:43.000Z
// This is free and unencumbered software released into the public domain. // For more information, please refer to <http://unlicense.org/> #include "spananalyzer/cable_plot_options_dialog.h" #include "wx/clrpicker.h" #include "wx/spinctrl.h" #include "wx/xrc/xmlres.h" BEGIN_EVENT_TABLE(CablePlotOptionsDialog, wxDialog) EVT_BUTTON(wxID_CANCEL, CablePlotOptionsDialog::OnCancel) EVT_BUTTON(wxID_OK, CablePlotOptionsDialog::OnOk) EVT_CLOSE(CablePlotOptionsDialog::OnClose) END_EVENT_TABLE() CablePlotOptionsDialog::CablePlotOptionsDialog( wxWindow* parent, CablePlotOptions* options) { // loads dialog from virtual xrc file system wxXmlResource::Get()->LoadDialog(this, parent, "cable_plot_options_dialog"); // saves unmodified reference, and copies to modified options_ = options; options_modified_ = CablePlotOptions(*options_); // transfers non-validator data to the window TransferCustomDataToWindow(); // fits the dialog around the sizers this->Fit(); } CablePlotOptionsDialog::~CablePlotOptionsDialog() { } void CablePlotOptionsDialog::OnCancel(wxCommandEvent &event) { EndModal(wxID_CANCEL); } void CablePlotOptionsDialog::OnClose(wxCloseEvent &event) { EndModal(wxID_CLOSE); } void CablePlotOptionsDialog::OnOk(wxCommandEvent &event) { // validates data from form if (this->Validate() == false) { wxMessageBox("Errors on form"); return; } wxBusyCursor cursor; // transfers data from dialog controls TransferCustomDataFromWindow(); // commits changes and exits the dialog *options_ = options_modified_; EndModal(wxID_OK); } void CablePlotOptionsDialog::TransferCustomDataFromWindow() { wxColourPickerCtrl* pickerctrl = nullptr; wxSpinCtrl* spinctrl = nullptr; // transfers color-core pickerctrl = XRCCTRL(*this, "colorpicker_core", wxColourPickerCtrl); options_modified_.color_core = pickerctrl->GetColour(); // transfers color-shell pickerctrl = XRCCTRL(*this, "colorpicker_shell", wxColourPickerCtrl); options_modified_.color_shell = pickerctrl->GetColour(); // transfers color-total pickerctrl = XRCCTRL(*this, "colorpicker_total", wxColourPickerCtrl); options_modified_.color_total = pickerctrl->GetColour(); // transfers color-markers pickerctrl = XRCCTRL(*this, "colorpicker_markers", wxColourPickerCtrl); options_modified_.color_markers = pickerctrl->GetColour(); // transfers thickness-line spinctrl = XRCCTRL(*this, "spinctrl_line_thickness", wxSpinCtrl); options_modified_.thickness_line = spinctrl->GetValue(); } void CablePlotOptionsDialog::TransferCustomDataToWindow() { wxColourPickerCtrl* pickerctrl = nullptr; wxSpinCtrl* spinctrl = nullptr; // transfers color-core pickerctrl = XRCCTRL(*this, "colorpicker_core", wxColourPickerCtrl); pickerctrl->SetColour(options_modified_.color_core); // transfers color-shell pickerctrl = XRCCTRL(*this, "colorpicker_shell", wxColourPickerCtrl); pickerctrl->SetColour(options_modified_.color_shell); // transfers color-total pickerctrl = XRCCTRL(*this, "colorpicker_total", wxColourPickerCtrl); pickerctrl->SetColour(options_modified_.color_total); // transfers color-markers pickerctrl = XRCCTRL(*this, "colorpicker_markers", wxColourPickerCtrl); pickerctrl->SetColour(options_modified_.color_markers); // transfers thickness-line spinctrl = XRCCTRL(*this, "spinctrl_line_thickness", wxSpinCtrl); spinctrl->SetValue(options_modified_.thickness_line); }
31.798165
78
0.772072
Transmission-Line-Software
72e85d40a6647b36be6c11d7eb5ef29e59a4e08b
11,563
cpp
C++
lib/src/test/audioConverterTest.cpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
182
2019-04-19T12:38:30.000Z
2022-03-20T16:48:20.000Z
lib/src/test/audioConverterTest.cpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
107
2019-04-23T10:49:35.000Z
2022-03-02T18:12:28.000Z
lib/src/test/audioConverterTest.cpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
59
2019-06-04T11:27:25.000Z
2022-03-17T23:49:49.000Z
// Copyright (c) 2012-2017 VideoStitch SAS // Copyright (c) 2018 stitchEm #include "../audio/converter.hpp" #include "gpu/testing.hpp" namespace VideoStitch { namespace Testing { std::vector<std::vector<audioSample_t>> makeSamples(size_t nChannels) { std::vector<std::vector<audioSample_t>> samples; std::vector<audioSample_t> tmp; tmp.push_back(-1.0); tmp.push_back(0.0); tmp.push_back(1.0); for (size_t c = 0; c < nChannels; c++) { samples.push_back(tmp); } return samples; } void convDBLToINT16() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::INT16, nChannels, nFrames); ac->convert(samples); int16_t *outData = (int16_t *)ac->getdata(); ENSURE_EQ((int16_t)(-32768), outData[0]); /* -1.0 */ ENSURE_EQ((int16_t)(-32768), outData[1]); /* -1.0 */ ENSURE_EQ((int16_t)0, outData[2]); /* 0.0 */ ENSURE_EQ((int16_t)0, outData[3]); /* 0.0 */ ENSURE_EQ((int16_t)(32767), outData[4]); /* 1.0 */ ENSURE_EQ((int16_t)(32767), outData[5]); /* 1.0 */ delete ac; } void convDBLToINT16_P() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::INT16_P, nChannels, nFrames); ac->convert(samples); int16_t *outData = (int16_t *)ac->getdata(); ENSURE_EQ((int16_t)(-32768), outData[0]); /* -1.0 */ ENSURE_EQ((int16_t)(0), outData[1]); /* 0.0 */ ENSURE_EQ((int16_t)32767, outData[2]); /* 1.0 */ ENSURE_EQ((int16_t)-32768, outData[3]); /* -1.0 */ ENSURE_EQ((int16_t)(0), outData[4]); /* 0.0 */ ENSURE_EQ((int16_t)(32767), outData[5]); /* 1.0 */ delete ac; } void convDBLToUINT8() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::UINT8, nChannels, nFrames); ac->convert(samples); uint8_t *outData = (uint8_t *)ac->getdata(); ENSURE_EQ((uint8_t)(0), outData[0]); /* -1.0 */ ENSURE_EQ((uint8_t)(0), outData[1]); /* -1.0 */ ENSURE_EQ((uint8_t)128, outData[2]); /* 0.0 */ ENSURE_EQ((uint8_t)128, outData[3]); /* 0.0 */ ENSURE_EQ((uint8_t)(255), outData[4]); /* 1.0 */ ENSURE_EQ((uint8_t)(255), outData[5]); /* 1.0 */ delete ac; } void convDBLToUINT8_P() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::UINT8_P, nChannels, nFrames); ac->convert(samples); uint8_t *outData = (uint8_t *)ac->getdata(); ENSURE_EQ((uint8_t)0, outData[0]); /* -1.0 */ ENSURE_EQ((uint8_t)128, outData[1]); /* -1.0 */ ENSURE_EQ((uint8_t)255, outData[2]); /* 0.0 */ ENSURE_EQ((uint8_t)0, outData[3]); /* 0.0 */ ENSURE_EQ((uint8_t)128, outData[4]); /* 1.0 */ ENSURE_EQ((uint8_t)255, outData[5]); /* 1.0 */ delete ac; } int32_t getInt24Val(uint8_t *src) { int32_t y = 0; uint8_t *yy = (uint8_t *)&y; yy[0] = src[0]; yy[1] = src[1]; yy[2] = src[2]; return y; } void convDBLToINT24() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::INT24, nChannels, nFrames); ac->convert(samples); uint8_t *outData = (uint8_t *)ac->getdata(); ENSURE_EQ((int32_t)(0x800000), getInt24Val(outData)); /* -1.0 */ ENSURE_EQ((int32_t)(0x800000), getInt24Val(outData + 3)); /* -1.0 */ ENSURE_EQ((int32_t)0, getInt24Val(outData + 6)); /* 0.0 */ ENSURE_EQ((int32_t)0, getInt24Val(outData + 9)); /* 0.0 */ ENSURE_EQ((int32_t)(0x7fffff), getInt24Val(outData + 12)); /* 1.0 */ ENSURE_EQ((int32_t)(0x7fffff), getInt24Val(outData + 15)); /* 1.0 */ delete ac; } void convDBLToINT24_P() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::INT24_P, nChannels, nFrames); ac->convert(samples); uint8_t *outData = (uint8_t *)ac->getdata(); ENSURE_EQ((int32_t)(0x800000), getInt24Val(outData)); /* -1.0 */ ENSURE_EQ((int32_t)0, getInt24Val(outData + 3)); /* 0.0 */ ENSURE_EQ((int32_t)(0x7fffff), getInt24Val(outData + 6)); /* 1.0 */ ENSURE_EQ((int32_t)(0x800000), getInt24Val(outData + 9)); /* -1.0 */ ENSURE_EQ((int32_t)0, getInt24Val(outData + 12)); /* 0.0 */ ENSURE_EQ((int32_t)(0x7fffff), getInt24Val(outData + 15)); /* 1.0 */ delete ac; } void convDBLToINT32() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::INT32, nChannels, nFrames); ac->convert(samples); int32_t *outData = (int32_t *)ac->getdata(); ENSURE_EQ((int32_t)(-2147483648), outData[0]); /* -1.0 */ ENSURE_EQ((int32_t)(-2147483648), outData[1]); /* -1.0 */ ENSURE_EQ((int32_t)0, outData[2]); /* 0.0 */ ENSURE_EQ((int32_t)0, outData[3]); /* 0.0 */ ENSURE_EQ((int32_t)(2147483647), outData[4]); /* 1.0 */ ENSURE_EQ((int32_t)(2147483647), outData[5]); /* 1.0 */ delete ac; } void convDBLToINT32_P() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::INT32_P, nChannels, nFrames); ac->convert(samples); int32_t *outData = (int32_t *)ac->getdata(); ENSURE_EQ((int32_t)(-2147483648), outData[0]); /* -1.0 */ ENSURE_EQ((int32_t)(0), outData[1]); /* 0.0 */ ENSURE_EQ((int32_t)(2147483647), outData[2]); /* 1.0 */ ENSURE_EQ((int32_t)-2147483648, outData[3]); /* -1.0 */ ENSURE_EQ((int32_t)(0), outData[4]); /* 0.0 */ ENSURE_EQ((int32_t)(2147483647), outData[5]); /* 1.0 */ delete ac; } void convDBLToFLT() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::FLT, nChannels, nFrames); ac->convert(samples); float *outData = (float *)ac->getdata(); ENSURE_EQ((float)(-1.0), outData[0]); /* -1.0 */ ENSURE_EQ((float)(-1.0), outData[1]); /* -1.0 */ ENSURE_EQ((float)0., outData[2]); /* 0.0 */ ENSURE_EQ((float)0., outData[3]); /* 0.0 */ ENSURE_EQ((float)(1.0), outData[4]); /* 1.0 */ ENSURE_EQ((float)(1.0), outData[5]); /* 1.0 */ delete ac; } void convDBLToFLT_P() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::FLT_P, nChannels, nFrames); ac->convert(samples); float *outData = (float *)ac->getdata(); ENSURE_EQ((float)(-1.0), outData[0]); /* -1.0 */ ENSURE_EQ((float)0., outData[1]); /* 0.0 */ ENSURE_EQ((float)(1.0), outData[2]); /* 1.0 */ ENSURE_EQ((float)(-1.0), outData[3]); /* -1.0 */ ENSURE_EQ((float)0., outData[4]); /* 0.0 */ ENSURE_EQ((float)(1.0), outData[5]); /* 1.0 */ delete ac; } void convDBLToDBL() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::DBL, nChannels, nFrames); ac->convert(samples); double *outData = (double *)ac->getdata(); ENSURE_EQ((double)(-1.0), outData[0]); /* -1.0 */ ENSURE_EQ((double)(-1.0), outData[1]); /* -1.0 */ ENSURE_EQ((double)0., outData[2]); /* 0.0 */ ENSURE_EQ((double)0., outData[3]); /* 0.0 */ ENSURE_EQ((double)(1.0), outData[4]); /* 1.0 */ ENSURE_EQ((double)(1.0), outData[5]); /* 1.0 */ delete ac; } void convDBLToDBL_P() { std::vector<std::vector<audioSample_t>> samples = makeSamples(2); size_t nChannels = samples.size(); size_t nFrames = samples[0].size(); Audio::AudioConverter *ac = Audio::AudioConverter::create(Audio::SamplingDepth::DBL_P, nChannels, nFrames); ac->convert(samples); double *outData = (double *)ac->getdata(); ENSURE_EQ((double)(-1.0), outData[0]); /* -1.0 */ ENSURE_EQ((double)0., outData[1]); /* 0.0 */ ENSURE_EQ((double)(1.0), outData[2]); /* 1.0 */ ENSURE_EQ((double)(-1.0), outData[3]); /* -1.0 */ ENSURE_EQ((double)0., outData[4]); /* 0.0 */ ENSURE_EQ((double)(1.0), outData[5]); /* 1.0 */ delete ac; } } // namespace Testing } // namespace VideoStitch int main(/*int argc, char **argv*/) { std::cout << "RUN Test convert DOUBLE to INT16" << std::endl; VideoStitch::Testing::convDBLToINT16(); std::cout << "Test convert DOUBLE to INT16 : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to INT16_P " << std::endl; VideoStitch::Testing::convDBLToINT16_P(); std::cout << "Test convert DOUBLE to INT16_P : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to UINT8 " << std::endl; VideoStitch::Testing::convDBLToUINT8(); std::cout << "Test convert DOUBLE to UINT8 : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to UINT8_P " << std::endl; VideoStitch::Testing::convDBLToUINT8_P(); std::cout << "Test convert DOUBLE to UINT8_P : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to INT24 " << std::endl; VideoStitch::Testing::convDBLToINT24(); std::cout << "Test convert DOUBLE to INT24 : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to INT24_P " << std::endl; VideoStitch::Testing::convDBLToINT24_P(); std::cout << "Test convert DOUBLE to INT24_P : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to INT32 " << std::endl; VideoStitch::Testing::convDBLToINT32(); std::cout << "Test convert DOUBLE to INT32 : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to INT32_P " << std::endl; VideoStitch::Testing::convDBLToINT32_P(); std::cout << "Test convert DOUBLE to INT32_P : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to FLT " << std::endl; VideoStitch::Testing::convDBLToFLT(); std::cout << "Test convert DOUBLE to FLT : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to FLT_P " << std::endl; VideoStitch::Testing::convDBLToFLT_P(); std::cout << "Test convert DOUBLE to FLT_P : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to DBL " << std::endl; VideoStitch::Testing::convDBLToDBL(); std::cout << "Test convert DOUBLE to DBL : PASSED\n" << std::endl; std::cout << "RUN Test convert DOUBLE to DBL_P " << std::endl; VideoStitch::Testing::convDBLToDBL_P(); std::cout << "Test convert DOUBLE to DBL_P : PASSED\n" << std::endl; }
41.894928
111
0.626481
tlalexander
72e92440229ae9d7e56281842b6e9ffb5197ba45
1,109
cpp
C++
fog/Prim/PrimOstrstream.cpp
UltimateScript/Forgotten
ac59ad21767af9628994c0eecc91e9e0e5680d95
[ "BSD-3-Clause" ]
null
null
null
fog/Prim/PrimOstrstream.cpp
UltimateScript/Forgotten
ac59ad21767af9628994c0eecc91e9e0e5680d95
[ "BSD-3-Clause" ]
null
null
null
fog/Prim/PrimOstrstream.cpp
UltimateScript/Forgotten
ac59ad21767af9628994c0eecc91e9e0e5680d95
[ "BSD-3-Clause" ]
null
null
null
#include <Prim/PrimIncludeAll.h> PrimOstrstream::PrimOstrstream() : _fixed_buffer(false), _ends(false) {} PrimOstrstream::PrimOstrstream(char *fixedBuffer, int fixedSize, ios_base::openmode aMode) : Super(fixedBuffer, fixedSize, aMode), _fixed_buffer(true), _ends(false) {} PrimOstrstream::~PrimOstrstream() { if (!_fixed_buffer) delete[] Super::str(); } PrimOstrstream& PrimOstrstream::ends() { std::ends(super()); _ends = true; return *this; } const PrimId& PrimOstrstream::id() { if (!_id) _id = PrimIdHandle(str()); return *_id; } const char *PrimOstrstream::str() { if (!_ends) ends(); return Super::str(); } const char *PrimOstrstream::str() const { return ((PrimOstrstream *)this)->str(); } size_t PrimOstrstream::strlen() { return ::strlen(str()); } const PrimString& PrimOstrstream::string() { if (!_string) _string = str(); return *_string; } std::ostream& operator<<(std::ostream& s, PrimOstrstream& anObject) { s << anObject.str(); return s; } std::ostream& operator<<(std::ostream& s, const PrimOstrstream& anObject) { s << anObject.str(); return s; }
15.191781
90
0.681695
UltimateScript
639229c35f0cc8371b20ad7e53135e49c4d6893f
962
hpp
C++
Sources/SolarTears/Rendering/Vulkan/VulkanMemory.hpp
Sixshaman/SolarTears
97d07730f876508fce8bf93c9dc90f051c230580
[ "BSD-3-Clause" ]
4
2021-06-30T16:00:20.000Z
2021-10-13T06:17:56.000Z
Sources/SolarTears/Rendering/Vulkan/VulkanMemory.hpp
Sixshaman/SolarTears
97d07730f876508fce8bf93c9dc90f051c230580
[ "BSD-3-Clause" ]
null
null
null
Sources/SolarTears/Rendering/Vulkan/VulkanMemory.hpp
Sixshaman/SolarTears
97d07730f876508fce8bf93c9dc90f051c230580
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include <vulkan/vulkan.h> #include "../../Logging/LoggerQueue.hpp" #include "VulkanDeviceParameters.hpp" #include <span> namespace Vulkan { class MemoryManager { public: enum class BufferAllocationType { DEVICE_LOCAL, HOST_VISIBLE }; MemoryManager(LoggerQueue* logger, VkPhysicalDevice physicalDevice, const DeviceParameters& deviceParameters); ~MemoryManager(); VkDeviceMemory AllocateImagesMemory(VkDevice device, std::span<VkBindImageMemoryInfo> inoutBindMemoryInfos) const; VkDeviceMemory AllocateBuffersMemory(VkDevice device, const std::span<VkBuffer> buffers, BufferAllocationType allocationType, std::vector<VkDeviceSize>& outMemoryOffsets) const; VkDeviceMemory AllocateIntermediateBufferMemory(VkDevice device, VkBuffer buffer) const; private: LoggerQueue* mLogger; VkPhysicalDeviceMemoryProperties mMemoryProperties; VkPhysicalDeviceMemoryBudgetPropertiesEXT mMemoryBudgetProperties; }; }
29.151515
179
0.803534
Sixshaman
6395e57e1c318de9d4b5b5aba029b9c50177356b
3,482
cpp
C++
src/StepLibrary/Leaker.cpp
dale-wilson/HSQueue
04d01ed42707069d28e81b5494aba61904e6e591
[ "BSD-3-Clause" ]
2
2015-12-29T17:33:25.000Z
2021-12-20T02:30:44.000Z
src/StepLibrary/Leaker.cpp
dale-wilson/HighQueue
04d01ed42707069d28e81b5494aba61904e6e591
[ "BSD-3-Clause" ]
null
null
null
src/StepLibrary/Leaker.cpp
dale-wilson/HighQueue
04d01ed42707069d28e81b5494aba61904e6e591
[ "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2015 Object Computing, Inc. // All rights reserved. // See the file license.txt for licensing information. #include <Steps/StepPch.hpp> #include "Leaker.hpp" #include <Steps/StepFactory.hpp> #include <Steps/SharedResources.hpp> #include <Steps/Configuration.hpp> #include <HighQueue/MemoryPool.hpp> using namespace HighQueue; using namespace Steps; namespace { StepFactory::Registrar<Leaker> registerStep("leaker", "**TESTING**: Discard selected messages. Pass the rest true to the next step."); const std::string keyStart = "offset"; const std::string keyCount = "count"; const std::string keyEvery = "every"; const std::string keyHeartbeats = "heartbeats"; const std::string keyShutdowns = "shutdowns"; } Leaker::Leaker() : count_(0) , every_(0) , offset_(0) , leakHeartbeats_(false) , leakShutdowns_(false) , messageNumber_(0) , published_(0) , leaked_(0) { } std::ostream & Leaker::usage(std::ostream & out) const { out << " " << keyStart << ": How many messages not to leak at beginning." << std::endl; out << " " << keyCount << ": How many consecutive messages to leak." << std::endl; out << " " << keyEvery << ": How often to leak a block of messages" << std::endl; out << " " << keyHeartbeats << ": Can heartbeats leak? (default is false)" << std::endl; out << " " << keyShutdowns << ": Can shutdown requests leak? (default is false)" << std::endl; return Step::usage(out); } bool Leaker::configureParameter(const std::string & key, const ConfigurationNode & configuration) { if(key == keyCount) { uint64_t value; if(configuration.getValue(value)) { count_ = size_t(value); return true; } } else if(key == keyStart) { uint64_t value; if(configuration.getValue(value)) { offset_ = size_t(value); return true; } } else if(key == keyEvery) { uint64_t value; if(configuration.getValue(value)) { every_ = size_t(value); return true; } } else if(key == keyHeartbeats) { if(configuration.getValue(leakHeartbeats_)) { return true; } } else if(key == keyShutdowns) { if(configuration.getValue(leakShutdowns_)) { return true; } } else { return Step::configureParameter(key, configuration); } return false; } void Leaker::validate() { mustHaveDestination(); if(every_ == 0) { std::stringstream msg; msg << "Leaker: \"" << keyEvery << "\" cannot be zero."; throw std::runtime_error(msg.str()); } Step::validate(); } void Leaker::handle(Message & message) { bool leak = true; auto type = message.getType(); if(type == Message::MessageType::Heartbeat) { leak = leakHeartbeats_; } else if(type == Message::MessageType::Shutdown) { leak = leakShutdowns_; } if(leak) { ++messageNumber_; auto p = (messageNumber_ + offset_ ) % every_; if(p >= count_) { send(message); ++published_; } else { ++leaked_; } } } void Leaker::logStats() { LogStatistics("Leaker published: " << published_); LogStatistics("Leaker leaked: " << leaked_); }
24.180556
139
0.571511
dale-wilson
6398898050a0be2343b5d84dee818f662871c7b0
1,528
cpp
C++
isis/src/base/objs/PrincipalComponentAnalysis/unitTest.cpp
ihumphrey-usgs/ISIS3_old
284cc442b773f8369d44379ee29a9b46961d8108
[ "Unlicense" ]
1
2019-10-13T15:31:33.000Z
2019-10-13T15:31:33.000Z
isis/src/base/objs/PrincipalComponentAnalysis/unitTest.cpp
ihumphrey-usgs/ISIS3_old
284cc442b773f8369d44379ee29a9b46961d8108
[ "Unlicense" ]
null
null
null
isis/src/base/objs/PrincipalComponentAnalysis/unitTest.cpp
ihumphrey-usgs/ISIS3_old
284cc442b773f8369d44379ee29a9b46961d8108
[ "Unlicense" ]
1
2021-07-12T06:05:03.000Z
2021-07-12T06:05:03.000Z
#include <iostream> #include "PrincipalComponentAnalysis.h" #include "Preference.h" using namespace std; double Round(double n); int main(int argc, char *argv[]) { Isis::Preference::Preferences(true); int n = 10; int k = 3; Isis::PrincipalComponentAnalysis pca(k); double original[k*n]; for(int i = 0; i < k; i++) { for(int j = 0; j < n; j++) { original[i*n+j] = (i + j) % 10; } } pca.AddData(original, n); pca.ComputeTransform(); double components[k*n]; double inverted[k*n]; for(int i = 0; i < n; i++) { TNT::Array2D<double> x(1, k); for(int j = 0; j < k; j++) { x[0][j] = original[i+n*j]; } TNT::Array2D<double> y = pca.Transform(x); for(int j = 0; j < k; j++) { components[i+n*j] = y[0][j]; } TNT::Array2D<double> z = pca.Inverse(y); for(int j = 0; j < k; j++) { inverted[i+n*j] = z[0][j]; } } cout << " Original Principal Components Inverted" << endl; for(int i = 0; i < n; i++) { cout << " "; for(int j = 0; j < k; j++) { cout << Round(original[i+n*j]) << " "; } cout << " -> "; for(int j = 0; j < k; j++) { cout << Round(components[i+n*j]) << " "; } cout << " -> "; for(int j = 0; j < k; j++) { cout << Round(inverted[i+n*j]) << " "; } cout << endl; } } // To fix round off error and differences between architecture double Round(double n) { double CUTOFF = std::pow(10.0, -14.0); if(abs(n) < CUTOFF) return 0; return n; }
21.828571
75
0.507853
ihumphrey-usgs
6398902ff4ec5ba793b8f209850e794e7954368c
849
cpp
C++
examples/with_json_cpp_be/cppbackend.cpp
jnietol/bppgrid
71efe785a262c5ce4438be2452308499cec45ac9
[ "MIT" ]
59
2019-11-04T11:19:35.000Z
2022-02-28T13:15:54.000Z
examples/with_json_cpp_be/cppbackend.cpp
jnietol/bppgrid
71efe785a262c5ce4438be2452308499cec45ac9
[ "MIT" ]
7
2020-03-16T15:41:49.000Z
2022-01-10T08:42:14.000Z
examples/with_json_cpp_be/cppbackend.cpp
jnietol/bppgrid
71efe785a262c5ce4438be2452308499cec45ac9
[ "MIT" ]
10
2019-11-05T04:38:57.000Z
2022-02-15T13:22:21.000Z
#include "cppbackend.h" #include <QVariantMap> #include <QColor> CppBackend::CppBackend(QObject *parent) : QObject(parent) { } QVariantList CppBackend::getData(int whatTab) { QVariantList records; int numRecs(10); for(int iRec = 0; iRec<numRecs; iRec++){ QVariantMap record; int r(0), g(0), b(0); switch (whatTab) { case 0: r = 255 * iRec / numRecs; break; case 1: g = 255 * iRec / numRecs; break; case 2: b = 255 * iRec / numRecs; break; } QColor theColor(r,g,b); record["pkid"] = iRec; record["name"] = QString("Record %1 of tab %2").arg(iRec).arg(whatTab); record["color"] = theColor.name(); records.append(record); } return records; }
19.744186
79
0.515901
jnietol
6399098dadb69348216d3863c1a2c08b94ecde2a
1,983
cpp
C++
Inchworm/src/__deprecated/KtreeKmerCounter.cpp
genome-vendor/trinity
edf531351bf5c244ae699d0ad69348a249900cce
[ "BSD-3-Clause" ]
4
2015-02-10T06:56:03.000Z
2021-06-30T23:33:07.000Z
Inchworm/src/__deprecated/KtreeKmerCounter.cpp
genome-vendor/trinity
edf531351bf5c244ae699d0ad69348a249900cce
[ "BSD-3-Clause" ]
null
null
null
Inchworm/src/__deprecated/KtreeKmerCounter.cpp
genome-vendor/trinity
edf531351bf5c244ae699d0ad69348a249900cce
[ "BSD-3-Clause" ]
7
2015-03-24T14:23:58.000Z
2020-01-15T16:54:10.000Z
#include <stdlib.h> #include "Fasta_reader.hpp" #include "Fasta_entry.hpp" #include "string_util.hpp" #include "sequenceUtil.hpp" #include "argProcessor.hpp" #include <string> #include <iostream> #include <sstream> #include "Ktree.hpp" int run(int argc, char* argv[]); int main (int argc, char* argv[]) { try { return(run(argc, argv)); } catch (string errmsg) { cerr << errmsg; return(1); } } int run (int argc, char* argv[]) { if (argc < 3) { stringstream s; s << "Usage: " << argv[0] << " file.fasta kmer_length [DS_mode]" << endl << endl; cerr << s.str(); return(1); } string fasta_filename (argv[1]); unsigned int kmer_length = atoi(argv[2]); bool DS_mode = (argc >= 3) ? true : false; Fasta_reader fasta_reader(fasta_filename); Ktree ktree; long read_counter = 0; while (fasta_reader.hasNext()) { read_counter++; if (read_counter % 1000 == 0) { cerr << "\rread[" << read_counter << "] "; } Fasta_entry fe = fasta_reader.getNext(); string accession = fe.get_accession(); string sequence = fe.get_sequence(); // cerr << "Processing: " << sequence << endl; if (sequence.length() < kmer_length + 1) { continue; } for (unsigned int i = 0; i <= sequence.length() - kmer_length; i++) { string kmer = sequence.substr(i, kmer_length); if (! contains_non_gatc(kmer)) { ktree.add_kmer(kmer); if (DS_mode) { kmer = revcomp(kmer); ktree.add_kmer(kmer); } } } } ktree.report_kmer_counts(); return(0); }
20.030303
89
0.475038
genome-vendor
639c035b8fa2958a6d4d18fff0b7366fe04bdabc
21,588
cpp
C++
src/utils/crc.cpp
acelyc111/rdsn
298769147750167949af800b96d5b9dcdfab0aeb
[ "MIT" ]
149
2017-10-16T03:24:58.000Z
2022-03-25T02:29:13.000Z
src/utils/crc.cpp
acelyc111/rdsn
298769147750167949af800b96d5b9dcdfab0aeb
[ "MIT" ]
297
2017-10-19T03:23:34.000Z
2022-03-17T08:00:12.000Z
src/utils/crc.cpp
acelyc111/rdsn
298769147750167949af800b96d5b9dcdfab0aeb
[ "MIT" ]
63
2017-10-19T01:55:27.000Z
2022-03-09T11:09:00.000Z
#include <cstdio> #include <dsn/utility/crc.h> namespace dsn { namespace utils { template <typename uintxx_t, uintxx_t uPoly> struct crc_generator { typedef uintxx_t uint; static const uintxx_t MSB = ((uintxx_t)1) << (8 * sizeof(uintxx_t) - 1); static const uintxx_t POLY = uPoly; static uintxx_t _crc_table[256]; static uintxx_t _uX2N[64]; // // compute CRC // static uintxx_t compute(const void *pSrc, size_t uSize, uintxx_t uCrc) { const uint8_t *pData = (const uint8_t *)pSrc; size_t uBytes; uCrc = ~uCrc; while (uSize > 15) { uBytes = 0x80000000u; if (uBytes > uSize) uBytes = uSize; uSize -= uBytes; for (; uBytes > 15; uBytes -= 16, pData += 16) { uCrc = _crc_table[(uint8_t)(uCrc ^ pData[0])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[1])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[2])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[3])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[4])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[5])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[6])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[7])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[8])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[9])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[10])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[11])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[12])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[13])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[14])] ^ (uCrc >> 8); uCrc = _crc_table[(uint8_t)(uCrc ^ pData[15])] ^ (uCrc >> 8); } uSize += uBytes; } for (uBytes = uSize; uBytes > 0; uBytes -= 1, pData += 1) uCrc = _crc_table[(uint8_t)(uCrc ^ pData[0])] ^ (uCrc >> 8); uCrc = ~uCrc; return (uCrc); }; // // Returns (a * b) mod POLY. // "a" and "b" are represented in "reversed" order -- LSB is x**(XX-1) coefficient, MSB is x^0 // coefficient. // "POLY" is represented in the same manner except for omitted x**XX coefficient // static uintxx_t MulPoly(uintxx_t a, uintxx_t b) { uintxx_t r; if (a == 0) return (0); r = 0; do { if (a & MSB) r ^= b; if (b & 1) b = (b >> 1) ^ POLY; else b >>= 1; a <<= 1; } while (a != 0); return (r); }; // // Returns (x ** (8*uSize)) mod POLY // static uintxx_t ComputeX_N(uint64_t uSize) { size_t i; uintxx_t r; r = MSB; // r = 1 for (i = 0; uSize != 0; uSize >>= 1, i += 1) { if (uSize & 1) r = MulPoly(r, _uX2N[i]); } return (r); }; // // Allows to change initial CRC value // static uintxx_t ConvertInitialCrc(uintxx_t uNew, uintxx_t uOld, uintxx_t uCrc, size_t uSize) { // // CRC (A, uSize, uCrc) = (uCrc * x**uSize + A * x**XX) mod POLY (let's forget about double // NOTs of uCrc) // // we know uCrc(uOld) = (uOld * x**uSize + A * x**XX) mod POLY; we need to compute // uCrc(uNew) = (uNew * x**uSize + A * x**XX) mod POLY // // uCrc(uNew) = uCrc(Old) + (uNew - uOld) * x**uSize) // uNew ^= uOld; uOld = ComputeX_N(uSize); uOld = MulPoly(uOld, uNew); uCrc ^= uOld; return (uCrc); }; // // Given // uFinalCrcA = ComputeCrc (A, uSizeA, uInitialCrcA) // and // uFinalCrcB = ComputeCrc (B, uSizeB, uInitialCrcB), // compute CRC of concatenation of A and B // uFinalCrcAB = ComputeCrc (AB, uSizeA + uSizeB, uInitialCrcAB) // without touching A and B // // NB: uSizeA and/or uSizeB may be 0s (this trick may be used to "recompute" CRC for another // initial value) // static uintxx_t concatenate(uintxx_t uInitialCrcAB, uintxx_t uInitialCrcA, uintxx_t uFinalCrcA, uint64_t uSizeA, uintxx_t uInitialCrcB, uintxx_t uFinalCrcB, uint64_t uSizeB) { uintxx_t uX_nA, uX_nB, uFinalCrcAB; // // Crc (X, uSizeX, uInitialCrcX) = ~(((~uInitialCrcX) * x**uSizeX + X * x**XX) mod POLY) // // // first, convert CRC's to canonical values getting rid of double bitwise NOT around uCrc // uInitialCrcAB = ~uInitialCrcAB; uInitialCrcA = ~uInitialCrcA; uFinalCrcA = ~uFinalCrcA; uInitialCrcB = ~uInitialCrcB; uFinalCrcB = ~uFinalCrcB; // // convert uFinalCrcX into canonical form, so that // uFinalCrcX = (X * x**XX) mod POLY // uX_nA = ComputeX_N(uSizeA); uFinalCrcA ^= MulPoly(uX_nA, uInitialCrcA); uX_nB = ComputeX_N(uSizeB); uFinalCrcB ^= MulPoly(uX_nB, uInitialCrcB); // // we know // uFinalCrcA = (A * x**XX) mod POLY // uFinalCrcB = (B * x**XX) mod POLY // and need to compute // uFinalCrcAB = (AB * x**XX) mod POLY = // = ((A * x**uSizeB + B) * x**XX) mod POLY = // = (A * x**XX) * x**uSizeB + B * x**XX mod POLY = // = uFinalCrcB + (uFinalCrcA * x**uSizeB) mod POLY // uFinalCrcAB = uFinalCrcB ^ MulPoly(uFinalCrcA, uX_nB); // // Finally, adjust initial value; we have // uFinalCrcAB = (AB * x**XX) mod POLY // but want to have // uFinalCrcAB = (UInitialCrcAB * x**(uSizeA + uSizeB) + AB * x**XX) mod POLY // uFinalCrcAB ^= MulPoly(uInitialCrcAB, MulPoly(uX_nA, uX_nB)); // convert back to double NOT uFinalCrcAB = ~uFinalCrcAB; return (uFinalCrcAB); }; static void InitializeTables(void) { size_t i, j; uintxx_t k; _uX2N[0] = MSB >> 8; for (i = 1; i < sizeof(_uX2N) / sizeof(_uX2N[0]); ++i) _uX2N[i] = MulPoly(_uX2N[i - 1], _uX2N[i - 1]); for (i = 0; i < 256; ++i) { k = (uintxx_t)i; for (j = 0; j < 8; ++j) { if (k & 1) k = (k >> 1) ^ POLY; else k = (k >> 1); } _crc_table[i] = k; } } static void PrintTables(char *pTypeName, char *pClassName) { size_t i, w; InitializeTables(); printf("%s %s::_uX2N[sizeof (%s::_uX2N) / sizeof (%s::_uX2N[0])] = {", pTypeName, pClassName, pClassName, pClassName); for (i = w = 0; i < sizeof(_uX2N) / sizeof(_uX2N[0]); ++i) { if (i != 0) printf(","); if (w == 0) printf("\n "); printf(" 0x%0*llx", static_cast<int>(sizeof(uintxx_t) * 2), (uint64_t)_uX2N[i]); w = (w + sizeof(uintxx_t)) & 31; } printf("\n};\n\n"); printf("%s %s::_crc_table[sizeof (%s::_crc_table) / sizeof (%s::_crc_table[0])] = {", pTypeName, pClassName, pClassName, pClassName); for (i = w = 0; i < sizeof(_crc_table) / sizeof(_crc_table[0]); ++i) { if (i != 0) printf(","); if (w == 0) printf("\n "); printf(" 0x%0*llx", static_cast<int>(sizeof(uintxx_t) * 2), (uint64_t)_crc_table[i]); w = (w + sizeof(uintxx_t)) & 31; } printf("\n};\n\n"); }; }; #define BIT64(n) (1ull << (63 - (n))) #define crc64_POLY \ (BIT64(63) + BIT64(61) + BIT64(59) + BIT64(58) + BIT64(56) + BIT64(55) + BIT64(52) + \ BIT64(49) + BIT64(48) + BIT64(47) + BIT64(46) + BIT64(44) + BIT64(41) + BIT64(37) + \ BIT64(36) + BIT64(34) + BIT64(32) + BIT64(31) + BIT64(28) + BIT64(26) + BIT64(23) + \ BIT64(22) + BIT64(19) + BIT64(16) + BIT64(13) + BIT64(12) + BIT64(10) + BIT64(9) + BIT64(6) + \ BIT64(4) + BIT64(3) + BIT64(0)) #define BIT32(n) (1u << (31 - (n))) #define crc32_POLY \ (BIT32(28) + BIT32(27) + BIT32(26) + BIT32(25) + BIT32(23) + BIT32(22) + BIT32(20) + \ BIT32(19) + BIT32(18) + BIT32(14) + BIT32(13) + BIT32(11) + BIT32(10) + BIT32(9) + BIT32(8) + \ BIT32(6) + BIT32(0)) typedef crc_generator<uint32_t, crc32_POLY> crc32; typedef crc_generator<uint64_t, crc64_POLY> crc64; template <> uint32_t crc32::_uX2N[sizeof(crc32::_uX2N) / sizeof(crc32::_uX2N[0])] = { 0x00800000, 0x00008000, 0x82f63b78, 0x6ea2d55c, 0x18b8ea18, 0x510ac59a, 0xb82be955, 0xb8fdb1e7, 0x88e56f72, 0x74c360a4, 0xe4172b16, 0x0d65762a, 0x35d73a62, 0x28461564, 0xbf455269, 0xe2ea32dc, 0xfe7740e6, 0xf946610b, 0x3c204f8f, 0x538586e3, 0x59726915, 0x734d5309, 0xbc1ac763, 0x7d0722cc, 0xd289cabe, 0xe94ca9bc, 0x05b74f3f, 0xa51e1f42, 0x40000000, 0x20000000, 0x08000000, 0x00800000, 0x00008000, 0x82f63b78, 0x6ea2d55c, 0x18b8ea18, 0x510ac59a, 0xb82be955, 0xb8fdb1e7, 0x88e56f72, 0x74c360a4, 0xe4172b16, 0x0d65762a, 0x35d73a62, 0x28461564, 0xbf455269, 0xe2ea32dc, 0xfe7740e6, 0xf946610b, 0x3c204f8f, 0x538586e3, 0x59726915, 0x734d5309, 0xbc1ac763, 0x7d0722cc, 0xd289cabe, 0xe94ca9bc, 0x05b74f3f, 0xa51e1f42, 0x40000000, 0x20000000, 0x08000000, 0x00800000, 0x00008000}; template <> uint32_t crc32::_crc_table[sizeof(crc32::_crc_table) / sizeof(crc32::_crc_table[0])] = { 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6, 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351}; template <> uint64_t crc64::_uX2N[sizeof(crc64::_uX2N) / sizeof(crc64::_uX2N[0])] = { 0x0080000000000000, 0x0000800000000000, 0x0000000080000000, 0x9a6c9329ac4bc9b5, 0x10f4bb0f129310d6, 0x70f05dcea2ebd226, 0x311211205672822d, 0x2fc297db0f46c96e, 0xca4d536fabf7da84, 0xfb4cdc3b379ee6ed, 0xea261148df25140a, 0x59ccb2c07aa6c9b4, 0x20b3674a839af27a, 0x2d8e1986da94d583, 0x42cdf4c20337635d, 0x1d78724bf0f26839, 0xb96c84e0afb34bd5, 0x5d2e1fcd2df0a3ea, 0xcd9506572332be42, 0x23bda2427f7d690f, 0x347a953232374f07, 0x1c2a807ac2a8ceea, 0x9b92ad0e14fe1460, 0x2574114889f670b2, 0x4a84a6c45e3bf520, 0x915bbac21cd1c7ff, 0xb0290ec579f291f5, 0xcf2548505c624e6e, 0xb154f27bf08a8207, 0xce4e92344baf7d35, 0x51da8d7e057c5eb3, 0x9fb10823f5be15df, 0x73b825b3ff1f71cf, 0x5db436c5406ebb74, 0xfa7ed8f3ec3f2bca, 0xc4d58efdc61b9ef6, 0xa7e39e61e855bd45, 0x97ad46f9dd1bf2f1, 0x1a0abb01f853ee6b, 0x3f0827c3348f8215, 0x4eb68c4506134607, 0x4a46f6de5df34e0a, 0x2d855d6a1c57a8dd, 0x8688da58e1115812, 0x5232f417fc7c7300, 0xa4080fb2e767d8da, 0xd515a7e17693e562, 0x1181f7c862e94226, 0x9e23cd058204ca91, 0x9b8992c57a0aed82, 0xb2c0afb84609b6ff, 0x2f7160553a5ea018, 0x3cd378b5c99f2722, 0x814054ad61a3b058, 0xbf766189fce806d8, 0x85a5e898ac49f86f, 0x34830d11bc84f346, 0x9644d95b173c8c1c, 0x150401ac9ac759b1, 0xebe1f7f46fb00eba, 0x8ee4ce0c2e2bd662, 0x4000000000000000, 0x2000000000000000, 0x0800000000000000}; template <> uint64_t crc64::_crc_table[sizeof(crc64::_crc_table) / sizeof(crc64::_crc_table[0])] = { 0x0000000000000000, 0x7f6ef0c830358979, 0xfedde190606b12f2, 0x81b31158505e9b8b, 0xc962e5739841b68f, 0xb60c15bba8743ff6, 0x37bf04e3f82aa47d, 0x48d1f42bc81f2d04, 0xa61cecb46814fe75, 0xd9721c7c5821770c, 0x58c10d24087fec87, 0x27affdec384a65fe, 0x6f7e09c7f05548fa, 0x1010f90fc060c183, 0x91a3e857903e5a08, 0xeecd189fa00bd371, 0x78e0ff3b88be6f81, 0x078e0ff3b88be6f8, 0x863d1eabe8d57d73, 0xf953ee63d8e0f40a, 0xb1821a4810ffd90e, 0xceecea8020ca5077, 0x4f5ffbd87094cbfc, 0x30310b1040a14285, 0xdefc138fe0aa91f4, 0xa192e347d09f188d, 0x2021f21f80c18306, 0x5f4f02d7b0f40a7f, 0x179ef6fc78eb277b, 0x68f0063448deae02, 0xe943176c18803589, 0x962de7a428b5bcf0, 0xf1c1fe77117cdf02, 0x8eaf0ebf2149567b, 0x0f1c1fe77117cdf0, 0x7072ef2f41224489, 0x38a31b04893d698d, 0x47cdebccb908e0f4, 0xc67efa94e9567b7f, 0xb9100a5cd963f206, 0x57dd12c379682177, 0x28b3e20b495da80e, 0xa900f35319033385, 0xd66e039b2936bafc, 0x9ebff7b0e12997f8, 0xe1d10778d11c1e81, 0x606216208142850a, 0x1f0ce6e8b1770c73, 0x8921014c99c2b083, 0xf64ff184a9f739fa, 0x77fce0dcf9a9a271, 0x08921014c99c2b08, 0x4043e43f0183060c, 0x3f2d14f731b68f75, 0xbe9e05af61e814fe, 0xc1f0f56751dd9d87, 0x2f3dedf8f1d64ef6, 0x50531d30c1e3c78f, 0xd1e00c6891bd5c04, 0xae8efca0a188d57d, 0xe65f088b6997f879, 0x9931f84359a27100, 0x1882e91b09fcea8b, 0x67ec19d339c963f2, 0xd75adabd7a6e2d6f, 0xa8342a754a5ba416, 0x29873b2d1a053f9d, 0x56e9cbe52a30b6e4, 0x1e383fcee22f9be0, 0x6156cf06d21a1299, 0xe0e5de5e82448912, 0x9f8b2e96b271006b, 0x71463609127ad31a, 0x0e28c6c1224f5a63, 0x8f9bd7997211c1e8, 0xf0f5275142244891, 0xb824d37a8a3b6595, 0xc74a23b2ba0eecec, 0x46f932eaea507767, 0x3997c222da65fe1e, 0xafba2586f2d042ee, 0xd0d4d54ec2e5cb97, 0x5167c41692bb501c, 0x2e0934dea28ed965, 0x66d8c0f56a91f461, 0x19b6303d5aa47d18, 0x980521650afae693, 0xe76bd1ad3acf6fea, 0x09a6c9329ac4bc9b, 0x76c839faaaf135e2, 0xf77b28a2faafae69, 0x8815d86aca9a2710, 0xc0c42c4102850a14, 0xbfaadc8932b0836d, 0x3e19cdd162ee18e6, 0x41773d1952db919f, 0x269b24ca6b12f26d, 0x59f5d4025b277b14, 0xd846c55a0b79e09f, 0xa72835923b4c69e6, 0xeff9c1b9f35344e2, 0x90973171c366cd9b, 0x1124202993385610, 0x6e4ad0e1a30ddf69, 0x8087c87e03060c18, 0xffe938b633338561, 0x7e5a29ee636d1eea, 0x0134d92653589793, 0x49e52d0d9b47ba97, 0x368bddc5ab7233ee, 0xb738cc9dfb2ca865, 0xc8563c55cb19211c, 0x5e7bdbf1e3ac9dec, 0x21152b39d3991495, 0xa0a63a6183c78f1e, 0xdfc8caa9b3f20667, 0x97193e827bed2b63, 0xe877ce4a4bd8a21a, 0x69c4df121b863991, 0x16aa2fda2bb3b0e8, 0xf86737458bb86399, 0x8709c78dbb8deae0, 0x06bad6d5ebd3716b, 0x79d4261ddbe6f812, 0x3105d23613f9d516, 0x4e6b22fe23cc5c6f, 0xcfd833a67392c7e4, 0xb0b6c36e43a74e9d, 0x9a6c9329ac4bc9b5, 0xe50263e19c7e40cc, 0x64b172b9cc20db47, 0x1bdf8271fc15523e, 0x530e765a340a7f3a, 0x2c608692043ff643, 0xadd397ca54616dc8, 0xd2bd67026454e4b1, 0x3c707f9dc45f37c0, 0x431e8f55f46abeb9, 0xc2ad9e0da4342532, 0xbdc36ec59401ac4b, 0xf5129aee5c1e814f, 0x8a7c6a266c2b0836, 0x0bcf7b7e3c7593bd, 0x74a18bb60c401ac4, 0xe28c6c1224f5a634, 0x9de29cda14c02f4d, 0x1c518d82449eb4c6, 0x633f7d4a74ab3dbf, 0x2bee8961bcb410bb, 0x548079a98c8199c2, 0xd53368f1dcdf0249, 0xaa5d9839ecea8b30, 0x449080a64ce15841, 0x3bfe706e7cd4d138, 0xba4d61362c8a4ab3, 0xc52391fe1cbfc3ca, 0x8df265d5d4a0eece, 0xf29c951de49567b7, 0x732f8445b4cbfc3c, 0x0c41748d84fe7545, 0x6bad6d5ebd3716b7, 0x14c39d968d029fce, 0x95708ccedd5c0445, 0xea1e7c06ed698d3c, 0xa2cf882d2576a038, 0xdda178e515432941, 0x5c1269bd451db2ca, 0x237c997575283bb3, 0xcdb181ead523e8c2, 0xb2df7122e51661bb, 0x336c607ab548fa30, 0x4c0290b2857d7349, 0x04d364994d625e4d, 0x7bbd94517d57d734, 0xfa0e85092d094cbf, 0x856075c11d3cc5c6, 0x134d926535897936, 0x6c2362ad05bcf04f, 0xed9073f555e26bc4, 0x92fe833d65d7e2bd, 0xda2f7716adc8cfb9, 0xa54187de9dfd46c0, 0x24f29686cda3dd4b, 0x5b9c664efd965432, 0xb5517ed15d9d8743, 0xca3f8e196da80e3a, 0x4b8c9f413df695b1, 0x34e26f890dc31cc8, 0x7c339ba2c5dc31cc, 0x035d6b6af5e9b8b5, 0x82ee7a32a5b7233e, 0xfd808afa9582aa47, 0x4d364994d625e4da, 0x3258b95ce6106da3, 0xb3eba804b64ef628, 0xcc8558cc867b7f51, 0x8454ace74e645255, 0xfb3a5c2f7e51db2c, 0x7a894d772e0f40a7, 0x05e7bdbf1e3ac9de, 0xeb2aa520be311aaf, 0x944455e88e0493d6, 0x15f744b0de5a085d, 0x6a99b478ee6f8124, 0x224840532670ac20, 0x5d26b09b16452559, 0xdc95a1c3461bbed2, 0xa3fb510b762e37ab, 0x35d6b6af5e9b8b5b, 0x4ab846676eae0222, 0xcb0b573f3ef099a9, 0xb465a7f70ec510d0, 0xfcb453dcc6da3dd4, 0x83daa314f6efb4ad, 0x0269b24ca6b12f26, 0x7d0742849684a65f, 0x93ca5a1b368f752e, 0xeca4aad306bafc57, 0x6d17bb8b56e467dc, 0x12794b4366d1eea5, 0x5aa8bf68aecec3a1, 0x25c64fa09efb4ad8, 0xa4755ef8cea5d153, 0xdb1bae30fe90582a, 0xbcf7b7e3c7593bd8, 0xc399472bf76cb2a1, 0x422a5673a732292a, 0x3d44a6bb9707a053, 0x759552905f188d57, 0x0afba2586f2d042e, 0x8b48b3003f739fa5, 0xf42643c80f4616dc, 0x1aeb5b57af4dc5ad, 0x6585ab9f9f784cd4, 0xe436bac7cf26d75f, 0x9b584a0fff135e26, 0xd389be24370c7322, 0xace74eec0739fa5b, 0x2d545fb4576761d0, 0x523aaf7c6752e8a9, 0xc41748d84fe75459, 0xbb79b8107fd2dd20, 0x3acaa9482f8c46ab, 0x45a459801fb9cfd2, 0x0d75adabd7a6e2d6, 0x721b5d63e7936baf, 0xf3a84c3bb7cdf024, 0x8cc6bcf387f8795d, 0x620ba46c27f3aa2c, 0x1d6554a417c62355, 0x9cd645fc4798b8de, 0xe3b8b53477ad31a7, 0xab69411fbfb21ca3, 0xd407b1d78f8795da, 0x55b4a08fdfd90e51, 0x2ada5047efec8728}; #undef crc32_POLY #undef crc64_POLY #undef BIT64 #undef BIT32 } } namespace dsn { namespace utils { uint32_t crc32_calc(const void *ptr, size_t size, uint32_t init_crc) { return dsn::utils::crc32::compute(ptr, size, init_crc); } uint32_t crc32_concat(uint32_t xy_init, uint32_t x_init, uint32_t x_final, size_t x_size, uint32_t y_init, uint32_t y_final, size_t y_size) { return dsn::utils::crc32::concatenate( 0, x_init, x_final, (uint64_t)x_size, y_init, y_final, (uint64_t)y_size); } uint64_t crc64_calc(const void *ptr, size_t size, uint64_t init_crc) { return dsn::utils::crc64::compute(ptr, size, init_crc); } uint64_t crc64_concat(uint32_t xy_init, uint64_t x_init, uint64_t x_final, size_t x_size, uint64_t y_init, uint64_t y_final, size_t y_size) { return ::dsn::utils::crc64::concatenate( 0, x_init, x_final, (uint64_t)x_size, y_init, y_final, (uint64_t)y_size); } } }
47.342105
100
0.659765
acelyc111
639ee49b13bd12ebaa335be234d65a7351ce96c6
5,965
cpp
C++
engine/screens/source/SkillsScreen.cpp
prolog/shadow-of-the-wyrm
a1312c3e9bb74473f73c4e7639e8bd537f10b488
[ "MIT" ]
60
2019-08-21T04:08:41.000Z
2022-03-10T13:48:04.000Z
engine/screens/source/SkillsScreen.cpp
prolog/shadow-of-the-wyrm
a1312c3e9bb74473f73c4e7639e8bd537f10b488
[ "MIT" ]
3
2021-03-18T15:11:14.000Z
2021-10-20T12:13:07.000Z
engine/screens/source/SkillsScreen.cpp
prolog/shadow-of-the-wyrm
a1312c3e9bb74473f73c4e7639e8bd537f10b488
[ "MIT" ]
8
2019-11-16T06:29:05.000Z
2022-01-23T17:33:43.000Z
#include "Conversion.hpp" #include "Game.hpp" #include "SkillsScreen.hpp" #include "OptionsComponent.hpp" #include "Prompt.hpp" #include "Setting.hpp" #include "TextComponent.hpp" #include "PromptTextKeys.hpp" #include "SkillTextKeys.hpp" using namespace std; SkillsScreen::SkillsScreen(DisplayPtr new_display, CreaturePtr new_creature, const SkillCategory sc, const SkillsSelectionType s_type) : Screen(new_display) , creature(new_creature) , category(sc) , sst(s_type) , skills_for_category({{SkillCategory::SKILL_CATEGORY_GENERAL, {SkillType::SKILL_GENERAL_ARCHERY, SkillType::SKILL_GENERAL_WEAVING}}, {SkillCategory::SKILL_CATEGORY_MELEE, {SkillType::SKILL_MELEE_AXES, SkillType::SKILL_MELEE_EXOTIC}}, {SkillCategory::SKILL_CATEGORY_RANGED, {SkillType::SKILL_RANGED_AXES, SkillType::SKILL_RANGED_EXOTIC}}, {SkillCategory::SKILL_CATEGORY_MAGIC, {SkillType::SKILL_MAGIC_ARCANE, SkillType::SKILL_MAGIC_CANTRIPS}}}) { initialize(); } void SkillsScreen::initialize() { screen_titles = { {SkillCategory::SKILL_CATEGORY_GENERAL, {make_pair(SkillsSelectionType::SKILLS_SELECTION_SELECT_SKILL, SkillTextKeys::SKILLS_GENERAL), make_pair(SkillsSelectionType::SKILLS_SELECTION_IMPROVE_SKILL, SkillTextKeys::SKILLS_IMPROVE_GENERAL)}}, {SkillCategory::SKILL_CATEGORY_MELEE, {make_pair(SkillsSelectionType::SKILLS_SELECTION_SELECT_SKILL, SkillTextKeys::SKILLS_WEAPON), make_pair(SkillsSelectionType::SKILLS_SELECTION_IMPROVE_SKILL, SkillTextKeys::SKILLS_IMPROVE_WEAPON)}}, {SkillCategory::SKILL_CATEGORY_RANGED, {make_pair(SkillsSelectionType::SKILLS_SELECTION_SELECT_SKILL, SkillTextKeys::SKILLS_RANGED_WEAPON), make_pair(SkillsSelectionType::SKILLS_SELECTION_IMPROVE_SKILL, SkillTextKeys::SKILLS_IMPROVE_RANGED_WEAPON)}}, {SkillCategory::SKILL_CATEGORY_MAGIC, {make_pair(SkillsSelectionType::SKILLS_SELECTION_SELECT_SKILL, SkillTextKeys::SKILLS_MAGIC), make_pair(SkillsSelectionType::SKILLS_SELECTION_IMPROVE_SKILL, SkillTextKeys::SKILLS_IMPROVE_MAGIC)}}}; vector<ScreenComponentPtr> sk_screen; auto s_it = screen_titles.find(category); if (s_it != screen_titles.end()) { title_text_sid = s_it->second[sst]; if (sst == SkillsSelectionType::SKILLS_SELECTION_IMPROVE_SKILL && creature != nullptr) { int skill_pts_remaining = creature->get_skill_points(); title_text_sid = SkillTextKeys::get_skill_improvement_message(title_text_sid, skill_pts_remaining); } } auto sty_it = skills_for_category.find(category); SkillType min = SkillType::SKILL_GENERAL_ARCHERY; SkillType max = SkillType::SKILL_GENERAL_WEAVING; std::map<char, SkillType> selection_map; bool selection_require_uppercase = Game::instance().get_settings_ref().get_setting_as_bool(Setting::SKILL_SELECTION_REQUIRE_CAPITALIZATION); if (sty_it != skills_for_category.end()) { pair<SkillType, SkillType> min_max = sty_it->second; min = min_max.first; max = min_max.second; } int cnt = 0; int current_id = 0; if (creature != nullptr) { for (int i = static_cast<int>(min); i <= static_cast<int>(max); i++) { OptionsComponentPtr options = std::make_shared<OptionsComponent>(); Option current_option; TextComponentPtr option_text_component = current_option.get_description(); SkillType st = static_cast<SkillType>(i); Skill* skill = creature->get_skills().get_skill(st); if (skill != nullptr && (skill->get_value() > 0 || skill->can_train_from_unlearned())) { string skill_desc = StringTable::get(skill->get_skill_name_sid()); ostringstream ss; ss << skill_desc << " (" << skill->get_value() << ")"; option_text_component->add_text(ss.str()); options->add_option_description(""); cnt++; if (can_add_component(cnt) == false) { current_id = 0; cnt = 1; screen_selection_to_skill_map.push_back(selection_map); selection_map.clear(); add_page(sk_screen); sk_screen.clear(); } // Set the ID after we've done a check on whether or not we can // add the component so that if a new page was added, and the // current id updated, we aren't setting the old value. current_option.set_id(current_id); current_option.set_external_id(to_string(i)); current_option.set_uppercase(selection_require_uppercase); options->add_option(current_option); add_options_component(sk_screen, options, cnt, current_id); // Add to the selection map after the option component has been added // so that if we've started a new page, the skill is added to the // correct place. // // Do both uppercase and lowercase. if (selection_require_uppercase) { selection_map['A' + current_id] = st; } else { selection_map['a' + current_id] = st; } current_id++; } } } screen_selection_to_skill_map.push_back(selection_map); add_page(sk_screen); // Set the prompt PromptPtr inv_prompt = std::make_unique<Prompt>(PromptLocation::PROMPT_LOCATION_LOWER_RIGHT); // Accept any input to the inventory manager will take care of sorting out // what's a valid command and what is not. inv_prompt->set_accept_any_input(true); inv_prompt->set_text_sid(PromptTextKeys::PROMPT_SKILLS); user_prompt = std::move(inv_prompt); line_increment = 1; } SkillType SkillsScreen::get_selected_skill(const char selection) const { SkillType st = SkillType::SKILL_UNDEFINED; const auto& selection_map = screen_selection_to_skill_map.at(get_cur_page_idx()); map<char, SkillType>::const_iterator selection_map_it = selection_map.find(selection); if (selection_map_it != selection_map.end()) { st = selection_map_it->second; } return st; }
38.733766
271
0.713495
prolog
63a4210799bd8d6f40449da376383e4f84bd4194
432
cpp
C++
src/uTensor/core/TensorMap.cpp
victorromeo/uTensor
1d8866e03469c220a57075473bd102b010a47832
[ "Apache-2.0" ]
1,047
2017-12-30T06:46:01.000Z
2022-03-30T05:03:20.000Z
src/uTensor/core/TensorMap.cpp
victorromeo/uTensor
1d8866e03469c220a57075473bd102b010a47832
[ "Apache-2.0" ]
115
2018-01-15T12:55:36.000Z
2021-11-20T19:33:20.000Z
src/uTensor/core/TensorMap.cpp
victorromeo/uTensor
1d8866e03469c220a57075473bd102b010a47832
[ "Apache-2.0" ]
171
2017-12-30T17:14:17.000Z
2022-03-23T12:45:32.000Z
#include "TensorMap.hpp" namespace uTensor { const uTensor::string not_found_string("NotFound"); Tensor not_found_tensor(nullptr); SimpleNamedTensor TensorMapInterface::not_found(not_found_string, not_found_tensor); bool compare_named_tensors(const SimpleNamedTensor& a, const SimpleNamedTensor& b) { return a.name < b.name; } } // namespace uTensor
27
66
0.659722
victorromeo
63a974f6d5ddfe16817972bce4142908cbd862ff
684
hpp
C++
include/eve/detail/function/iota.hpp
clayne/eve
dc268b5db474376e1c53f5a474f5bb42b7c4cb59
[ "MIT" ]
340
2020-09-16T21:12:48.000Z
2022-03-28T15:40:33.000Z
include/eve/detail/function/iota.hpp
clayne/eve
dc268b5db474376e1c53f5a474f5bb42b7c4cb59
[ "MIT" ]
383
2020-09-17T06:56:35.000Z
2022-03-13T15:58:53.000Z
include/eve/detail/function/iota.hpp
clayne/eve
dc268b5db474376e1c53f5a474f5bb42b7c4cb59
[ "MIT" ]
28
2021-02-27T23:11:23.000Z
2022-03-25T12:31:29.000Z
//================================================================================================== /* EVE - Expressive Vector Engine Copyright : EVE Contributors & Maintainers SPDX-License-Identifier: MIT */ //================================================================================================== #pragma once #include <eve/arch.hpp> #include <eve/detail/abi.hpp> #include <eve/concept/value.hpp> namespace eve::detail { template<typename T> EVE_FORCEINLINE constexpr auto linear_ramp(as<T> const &) noexcept { if constexpr( scalar_value<T> ) { return T(0); } else { return T([](auto i, auto ) { return i; } ); } } }
22.8
100
0.44883
clayne
63aa836274d91d000c85c4ee6c9a7173b7110b00
1,832
cpp
C++
src/gameworld/gameworld/effect/skilleffect/effecthurtinc.cpp
mage-game/metagame-xm-server
193b67389262803fe0eae742800b1e878b5b3087
[ "MIT" ]
3
2021-12-16T13:57:28.000Z
2022-03-26T07:50:08.000Z
src/gameworld/gameworld/effect/skilleffect/effecthurtinc.cpp
mage-game/metagame-xm-server
193b67389262803fe0eae742800b1e878b5b3087
[ "MIT" ]
null
null
null
src/gameworld/gameworld/effect/skilleffect/effecthurtinc.cpp
mage-game/metagame-xm-server
193b67389262803fe0eae742800b1e878b5b3087
[ "MIT" ]
1
2022-03-26T07:50:11.000Z
2022-03-26T07:50:11.000Z
#include "effecthurtinc.hpp" EffectIncHurt::EffectIncHurt() : m_effect_time(0), m_inc_percent_to_role(0), m_inc_percent_to_monster(0) { } EffectIncHurt::EffectIncHurt(ObjID deliverer, UInt16 skill, int effect_time, char product_level, char product_method) : EffectBase(deliverer, skill, product_method, product_level), m_effect_time(effect_time), m_inc_percent_to_role(0), m_inc_percent_to_monster(0) { m_merge_rule = EffectBase::MERGE_RULE_NOMERGE_2; } EffectIncHurt::~EffectIncHurt() { } bool EffectIncHurt::Update(unsigned long interval, Character *cha, bool *die) { m_effect_time -= (int)interval; return m_effect_time > 0; } void EffectIncHurt::SetIncPercent(int percent) { if (percent > 0) { m_inc_percent_to_role = percent; m_inc_percent_to_monster = percent; } } void EffectIncHurt::SetIncPercent(int percent_to_role, int percent_to_monster) { if (percent_to_role > 0) { m_inc_percent_to_role = percent_to_role; m_inc_percent_to_monster = percent_to_monster; } } int EffectIncHurt::GetIncPercent(Character *target) { if (NULL != target && Obj::OBJ_TYPE_MONSTER == target->GetObjType()) { return m_inc_percent_to_monster; } else { return m_inc_percent_to_role; } } void EffectIncHurt::GetEffectParam(short *count, long long param[EFFECT_INFO_PARAM_MAX]) { UNSTD_STATIC_CHECK(EFFECT_INFO_PARAM_MAX >= 3); param[0] = m_effect_time; param[1] = m_inc_percent_to_role; param[2] = m_inc_percent_to_monster; *count = 3; } bool EffectIncHurt::Serialize(TLVSerializer &s) const { return SerializeBase(s) && s.Push(m_effect_time) && s.Push(m_inc_percent_to_role) && s.Push(m_inc_percent_to_monster); } bool EffectIncHurt::Unserialize(TLVUnserializer &s) { return UnserializeBase(s) && s.Pop(&m_effect_time) && s.Pop(&m_inc_percent_to_role) && s.Pop(&m_inc_percent_to_monster); }
23.487179
121
0.76583
mage-game
63ad29d2ee1449c72db677003213e9f5e95137f9
684
cpp
C++
test/throw/main.cpp
6923403/C
d365021759e6d9078254b4b7b6455e0408e4b691
[ "MIT" ]
1
2020-10-01T14:52:45.000Z
2020-10-01T14:52:45.000Z
test/throw/main.cpp
6923403/C
d365021759e6d9078254b4b7b6455e0408e4b691
[ "MIT" ]
3
2020-06-19T01:24:51.000Z
2020-07-16T14:00:30.000Z
test/throw/main.cpp
6923403/C
d365021759e6d9078254b4b7b6455e0408e4b691
[ "MIT" ]
null
null
null
#include <iostream> #include <string> using namespace std; class Sales_item { friend istream& operator>>(istream &, Sales_item &); public: Sales_item() = default; int isbn() { return bookNo; } private: int bookNo; }; istream &operator >>(istream &in, Sales_item &s) { double price; in >> s.bookNo; } void test1() { Sales_item item1, item2; cin >> item1 >> item2; if(item1.isbn() == item2.isbn()) { cout << "======" << endl; } else { cerr << "Data must refer to same isbn" << endl; return -1; } } int main(int argc, char **argv) { test1(); }
14.869565
60
0.511696
6923403
63ae9da6e245da243f3329b10098605095f3db33
2,924
cpp
C++
cpp/metaspore/dense_tensor_partition.cpp
meta-soul/MetaSpore
e6fbc12c6a3139df76c87215b16f9dba65962ec7
[ "Apache-2.0" ]
32
2022-03-30T10:24:00.000Z
2022-03-31T16:19:15.000Z
cpp/metaspore/dense_tensor_partition.cpp
meta-soul/MetaSpore
e6fbc12c6a3139df76c87215b16f9dba65962ec7
[ "Apache-2.0" ]
null
null
null
cpp/metaspore/dense_tensor_partition.cpp
meta-soul/MetaSpore
e6fbc12c6a3139df76c87215b16f9dba65962ec7
[ "Apache-2.0" ]
3
2022-03-30T10:28:57.000Z
2022-03-30T11:37:39.000Z
// // Copyright 2022 DMetaSoul // // 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 <metaspore/debug.h> #include <metaspore/dense_tensor_partition.h> #include <metaspore/file_utils.h> #include <metaspore/io.h> #include <metaspore/tensor_utils.h> #include <string.h> namespace metaspore { void DenseTensorPartition::AllocateDataBlock(bool init) { size_t begin = 0; size_t end = 0; const int index = GetPartitionIndex(); GetMeta().CheckDenseTensorMeta(index); GetMeta().ComputePartitionShapes(index, begin, end, &partition_data_shape_, &partition_state_shape_); const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t data_size = item_size * TotalElements(GetPartitionDataShape()); data_.Reset(data_size); if (init) { DenseInitializer initializer = GetMeta().GetInitializer(); if (!initializer) memset(data_.data(), 0, data_size); else initializer(GetMeta().GetName(), data_, GetMeta()); } if (!GetPartitionStateShape().empty()) { const size_t state_size = item_size * TotalElements(GetPartitionStateShape()); state_.Reset(state_size); if (init) memset(state_.data(), 0, state_size); } } void DenseTensorPartition::HandlePush(SmartArray<uint8_t> in, bool is_value, bool is_state) { DenseUpdater updater = GetMeta().GetUpdater(); if (is_state) state_.CopyFrom(in); else if (!updater || is_value) data_.CopyFrom(in); else updater(GetMeta().GetName(), data_, in, state_, GetMeta()); } SmartArray<uint8_t> DenseTensorPartition::HandlePull(bool is_state) { return is_state ? state_ : data_; } void DenseTensorPartition::HandlePushMeta(const DenseTensorMeta &meta) { if (!meta.IsCompatible(meta_)) { std::string serr; serr.append("Incompatible meta detected, can not update initializer and updater"); serr.append(" of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } meta_.SetInitializerByData(meta.GetInitializerAsData()); meta_.SetUpdaterByData(meta.GetUpdaterAsData()); } const DenseTensorMeta &DenseTensorPartition::HandlePullMeta() { return meta_; } } // namespace metaspore
35.228916
93
0.685021
meta-soul
63b5456b7e18ed31a2746f75fc4a5591ee10080f
1,833
cpp
C++
MSCL/source/mscl/MicroStrain/MIP/Commands/GetDeviceInfo.cpp
offworld-projects/MSCL
8388e97c92165e16c26c554aadf1e204ebcf93cf
[ "BSL-1.0", "OpenSSL", "MIT" ]
53
2015-08-28T02:41:41.000Z
2022-03-03T07:50:53.000Z
MSCL/source/mscl/MicroStrain/MIP/Commands/GetDeviceInfo.cpp
offworld-projects/MSCL
8388e97c92165e16c26c554aadf1e204ebcf93cf
[ "BSL-1.0", "OpenSSL", "MIT" ]
209
2015-09-30T19:36:11.000Z
2022-03-04T21:52:20.000Z
MSCL/source/mscl/MicroStrain/MIP/Commands/GetDeviceInfo.cpp
offworld-projects/MSCL
8388e97c92165e16c26c554aadf1e204ebcf93cf
[ "BSL-1.0", "OpenSSL", "MIT" ]
55
2015-09-03T14:40:01.000Z
2022-02-04T02:02:01.000Z
/******************************************************************************* Copyright(c) 2015-2021 Parker Hannifin Corp. All rights reserved. MIT Licensed. See the included LICENSE.txt for a copy of the full MIT License. *******************************************************************************/ #include "stdafx.h" #include "GetDeviceInfo.h" #include "MIP_Commands.h" #include "mscl/Utils.h" #include "mscl/MicroStrain/MIP/MipDataField.h" #include "mscl/MicroStrain/MIP/Packets/MipPacketBuilder.h" namespace mscl { ByteStream GetDeviceInfo::buildCommand() { static const uint8 DESC_SET = 0x01; static const uint8 FIELD_DESC = 0x03; //create the field to add to the packet MipDataField field(Utils::make_uint16(DESC_SET, FIELD_DESC)); //create a packet builder with with field MipPacketBuilder builder(DESC_SET, field); //build the packet and return the ByteStream result return builder.buildPacket(); } GetDeviceInfo::Response::Response(std::weak_ptr<ResponseCollector> collector): GenericMipCommand::Response(MipTypes::CMD_GET_DEVICE_INFO, collector, true, true, "Get Device Info") { } bool GetDeviceInfo::Response::match_data(const MipDataField& field) { static const uint8 FIELD_DATA_LEN = 82; //verify the field data size is correct if(field.fieldData().size() != FIELD_DATA_LEN) { return false; } //call match from the super class as well return GenericMipCommand::Response::match_data(field); } MipDeviceInfo GetDeviceInfo::Response::parseResponse(const GenericMipCmdResponse& response) const { MipDeviceInfo result; MIP_Commands::parseData_GetDeviceInfo(response, result); return result; } }
32.732143
108
0.629023
offworld-projects
63c0be814da62e4c04ee99599a46e5f60cac9ce2
1,701
hpp
C++
src/cpp-utility/perf/PerfCounter.hpp
toschmidt/cpp-utility
d58f3a0af32700b742a96143dfee97144dc7c8ce
[ "MIT" ]
1
2021-03-26T19:08:59.000Z
2021-03-26T19:08:59.000Z
src/cpp-utility/perf/PerfCounter.hpp
toschmidt/cpp-utility
d58f3a0af32700b742a96143dfee97144dc7c8ce
[ "MIT" ]
null
null
null
src/cpp-utility/perf/PerfCounter.hpp
toschmidt/cpp-utility
d58f3a0af32700b742a96143dfee97144dc7c8ce
[ "MIT" ]
null
null
null
#pragma once #include <cpp-utility/compiler/CompilerHints.hpp> #include <cstring> #include <linux/perf_event.h> #include <sys/ioctl.h> #include <syscall.h> #include <unistd.h> namespace utility::perf { using PerfConfig = std::pair<uint64_t, uint64_t>; class PerfCounter { private: struct alignas(32) read_format { uint64_t value{}; uint64_t time_enabled{}; uint64_t time_running{}; }; perf_event_attr pe{}; int fd; read_format prev; read_format data; public: explicit PerfCounter(PerfConfig config) : fd(0) { memset(&pe, 0, sizeof(perf_event_attr)); pe.type = config.first; pe.size = sizeof(perf_event_attr); pe.config = config.second; pe.disabled = true; pe.inherit = 1; pe.inherit_stat = 0; pe.exclude_kernel = false; pe.exclude_hv = false; pe.read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING; fd = syscall(__NR_perf_event_open, &pe, 0, -1, -1, 0); // NOLINT } forceinline void start() { ioctl(fd, PERF_EVENT_IOC_RESET, 0); ioctl(fd, PERF_EVENT_IOC_ENABLE, 0); read(fd, &prev, sizeof(uint64_t) * 3); } forceinline void stop() { read(fd, &data, sizeof(uint64_t) * 3); ioctl(fd, PERF_EVENT_IOC_DISABLE, 0); } forceinline double get() const { return static_cast<double>(data.value - prev.value) * (static_cast<double>(data.time_enabled - prev.time_enabled) / static_cast<double>(data.time_running - prev.time_running)); } }; } // namespace utility::perf
27.435484
90
0.607878
toschmidt
63c45fa8fb0774d276b527ae33646d95bae1f4a1
2,918
cpp
C++
src/mame/drivers/vt_unknown.cpp
Robbbert/messui
49b756e2140d8831bc81335298ee8c5471045e79
[ "BSD-3-Clause" ]
26
2015-03-31T06:25:51.000Z
2021-12-14T09:29:04.000Z
src/mame/drivers/vt_unknown.cpp
Robbbert/messui
49b756e2140d8831bc81335298ee8c5471045e79
[ "BSD-3-Clause" ]
null
null
null
src/mame/drivers/vt_unknown.cpp
Robbbert/messui
49b756e2140d8831bc81335298ee8c5471045e79
[ "BSD-3-Clause" ]
10
2015-03-27T05:45:51.000Z
2022-02-04T06:57:36.000Z
// license:BSD-3-Clause // copyright-holders:David Haywood // unknown platform capable of running high resolution NES games (VT268?) // is the dump good? can't locate any code, some 0x80000 blocks have what might be vectors at the end, but non-standard? #include "emu.h" #include "cpu/m6502/m6502.h" #include "screen.h" #include "emupal.h" #include "speaker.h" class vt_unknown_state : public driver_device { public: vt_unknown_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_palette(*this, "palette"), m_screen(*this, "screen"), m_gfxdecode(*this, "gfxdecode") { } void vt_unknown(machine_config &config); private: virtual void machine_start() override; virtual void machine_reset() override; uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); void vt_unknown_map(address_map &map); required_device<cpu_device> m_maincpu; required_device<palette_device> m_palette; required_device<screen_device> m_screen; required_device<gfxdecode_device> m_gfxdecode; }; uint32_t vt_unknown_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { return 0; } void vt_unknown_state::machine_start() { } void vt_unknown_state::machine_reset() { } void vt_unknown_state::vt_unknown_map(address_map &map) { map(0x000000, 0xffff).rom().region("maincpu", 0); } static INPUT_PORTS_START( vt_unknown ) INPUT_PORTS_END static const gfx_layout test_layout = { 8,8, RGN_FRAC(1,1), 8, { 0 }, { STEP8(0,1) }, { STEP8(0,8*1) }, 8 * 1 * 8 }; static GFXDECODE_START( gfx_test ) GFXDECODE_ENTRY( "maincpu", 0, test_layout, 0x0, 1 ) GFXDECODE_END void vt_unknown_state::vt_unknown(machine_config &config) { M6502(config, m_maincpu, 8000000); // unknown, assumed to be a 6502 based CPU as it has NES games, but could be emulating them (like the S+Core units, assuming this isn't one) m_maincpu->set_addrmap(AS_PROGRAM, &vt_unknown_state::vt_unknown_map); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0)); m_screen->set_refresh_hz(60); m_screen->set_size(300, 262); m_screen->set_visarea(0, 256-1, 0, 240-1); m_screen->set_screen_update(FUNC(vt_unknown_state::screen_update)); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x200); GFXDECODE(config, m_gfxdecode, m_palette, gfx_test); } ROM_START( dgun2572 ) ROM_REGION( 0x2000000, "maincpu", 0 ) // extra pins on subboard not marked, is this a good dump? ROM_LOAD( "dreamgearwgun.bin", 0x00000, 0x2000000, CRC(92b55c75) SHA1(c7b2319e304a4bf480b5dcd4f24af2e6ba834d0d) ) ROM_END CONS( 201?, dgun2572, 0, 0, vt_unknown, vt_unknown, vt_unknown_state, empty_init, "dreamGEAR", "My Arcade Wireless Video Game Station 200-in-1 (DGUN-2572)", MACHINE_NOT_WORKING | MACHINE_NO_SOUND )
28.057692
212
0.754969
Robbbert
63c644f7528d19adcb36891b9e9eb0be17cf9726
806
cpp
C++
tests/omphost/host_bug_libomp.cpp
ye-luo/openmp-target
f042e9d255b521e07ca32fe08799e736d4b1c70c
[ "BSD-3-Clause" ]
5
2020-02-14T03:32:58.000Z
2021-06-21T18:13:02.000Z
tests/omphost/host_bug_libomp.cpp
ye-luo/openmp-target
f042e9d255b521e07ca32fe08799e736d4b1c70c
[ "BSD-3-Clause" ]
1
2020-02-24T01:48:06.000Z
2020-02-24T01:48:57.000Z
tests/omphost/host_bug_libomp.cpp
ye-luo/openmp-target
f042e9d255b521e07ca32fe08799e736d4b1c70c
[ "BSD-3-Clause" ]
4
2020-05-20T16:04:10.000Z
2021-06-22T20:06:39.000Z
#include <iostream> #ifdef _OPENMP #include <omp.h> #else int omp_get_thread_num() { return 1; } #endif int main() { const int size = 4; int wrong_counts = 0; #pragma omp parallel reduction(+:wrong_counts) { int A[size]; for(int i = 0; i < size; i++) A[i] = 0; #pragma omp target teams distribute map(tofrom: A[:size]) for(int i = 0; i < size; i++) { A[i] = i; } #pragma omp critical { std::cout << "tid = " << omp_get_thread_num() << std::endl; for(int i = 0; i < size; i++) { if (A[i] != i) wrong_counts++; std::cout << " " << A[i]; } std::cout << std::endl; } } if (wrong_counts) std::cout << "Wrong!" << std::endl; else std::cout << "Right!" << std::endl; return wrong_counts; }
19.190476
65
0.514888
ye-luo
63c7133a66a1680e54953472443ad5aebcc1a164
3,784
cpp
C++
test/function/scalar/cospi.cpp
yaeldarmon/boost.simd
561316cc54bdc6353ca78f3b6d7e9120acd11144
[ "BSL-1.0" ]
null
null
null
test/function/scalar/cospi.cpp
yaeldarmon/boost.simd
561316cc54bdc6353ca78f3b6d7e9120acd11144
[ "BSL-1.0" ]
null
null
null
test/function/scalar/cospi.cpp
yaeldarmon/boost.simd
561316cc54bdc6353ca78f3b6d7e9120acd11144
[ "BSL-1.0" ]
null
null
null
//================================================================================================== /*! Copyright 2015 NumScale SAS Copyright 2015 J.T. Lapreste Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ //================================================================================================== #include <boost/simd/function/scalar/cospi.hpp> #include <boost/simd/function/fast.hpp> #include <simd_test.hpp> #include <boost/simd/constant/inf.hpp> #include <boost/simd/constant/minf.hpp> #include <boost/simd/constant/nan.hpp> #include <boost/simd/constant/one.hpp> #include <boost/simd/constant/mone.hpp> #include <boost/simd/constant/zero.hpp> #include <boost/simd/constant/mzero.hpp> #include <boost/simd/constant/quarter.hpp> #include <boost/simd/constant/sqrt_2.hpp> #include <boost/simd/constant/sqrt_2o_2.hpp> #include <boost/dispatch/meta/as_floating.hpp> STF_CASE_TPL (" cospi", STF_IEEE_TYPES) { namespace bs = boost::simd; namespace bd = boost::dispatch; using bs::cospi; using r_t = decltype(cospi(T())); // return type conformity test STF_TYPE_IS(r_t, T); // specific values tests #ifndef BOOST_SIMD_NO_INVALIDS STF_ULP_EQUAL(cospi(bs::Inf<T>()), bs::Nan<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::Minf<T>()), bs::Nan<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::Nan<T>()), bs::Nan<r_t>(), 0.5); #endif STF_ULP_EQUAL(cospi(-bs::Quarter<T>()), bs::Sqrt_2o_2<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::Half<T>()), bs::Zero<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::Mhalf<T>()), bs::Zero<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::One<T>()), bs::Mone<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::Quarter<T>()), bs::Sqrt_2o_2<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::Zero<T>()), bs::One<r_t>(), 0.5); } STF_CASE_TPL (" cospi fast", STF_IEEE_TYPES) { namespace bs = boost::simd; namespace bd = boost::dispatch; using bs::cospi; using r_t = decltype(cospi(T())); // return type conformity test STF_TYPE_IS(r_t, T); // specific values tests #ifndef BOOST_SIMD_NO_INVALIDS STF_ULP_EQUAL(bs::fast_(cospi)(bs::Inf<T>()), bs::Nan<r_t>(), 0.5); STF_ULP_EQUAL(bs::fast_(cospi)(bs::Minf<T>()), bs::Nan<r_t>(), 0.5); STF_ULP_EQUAL(bs::fast_(cospi)(bs::Nan<T>()), bs::Nan<r_t>(), 0.5); #endif STF_ULP_EQUAL(bs::fast_(cospi)(-bs::Quarter<T>()), bs::Sqrt_2o_2<r_t>(), 0.5); STF_ULP_EQUAL(bs::fast_(cospi)(bs::Half<T>()), bs::Nan<r_t>(), 0.5); STF_ULP_EQUAL(bs::fast_(cospi)(bs::Mhalf<T>()), bs::Nan<r_t>(), 0.5); STF_ULP_EQUAL(bs::fast_(cospi)(bs::One<T>()), bs::Nan<r_t>(), 0.5); STF_ULP_EQUAL(bs::fast_(cospi)(bs::Quarter<T>()), bs::Sqrt_2o_2<r_t>(), 0.5); STF_ULP_EQUAL(bs::fast_(cospi)(bs::Zero<T>()), bs::One<r_t>(), 0.5); } STF_CASE_TPL (" cospi unsigned", STF_UNSIGNED_INTEGRAL_TYPES) { namespace bs = boost::simd; namespace bd = boost::dispatch; using bs::cospi; using r_t = decltype(cospi(T())); using result_t = bd::as_floating_t<T>; // return type conformity test STF_TYPE_IS(r_t, result_t); // specific values tests STF_ULP_EQUAL(cospi(bs::One<T>()), bs::Mone<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::Zero<T>()), bs::One<r_t>(), 0.5); } // end of test for unsigned_int_ STF_CASE_TPL (" cospi signed", STF_SIGNED_INTEGRAL_TYPES) { namespace bs = boost::simd; namespace bd = boost::dispatch; using bs::cospi; using r_t = decltype(cospi(T())); using result_t = bd::as_floating_t<T>; // return type conformity test STF_TYPE_IS(r_t, result_t); // specific values tests STF_ULP_EQUAL(cospi(bs::Mone<T>()), bs::Mone<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::One<T>()), bs::Mone<r_t>(), 0.5); STF_ULP_EQUAL(cospi(bs::Zero<T>()), bs::One<r_t>(), 0.5); } // end of test for signed_int_
34.4
100
0.634514
yaeldarmon