text
stringlengths 5
1.04M
|
|---|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/ssm/model/GetMaintenanceWindowExecutionTaskInvocationResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::SSM::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
GetMaintenanceWindowExecutionTaskInvocationResult::GetMaintenanceWindowExecutionTaskInvocationResult() :
m_taskType(MaintenanceWindowTaskType::NOT_SET),
m_status(MaintenanceWindowExecutionStatus::NOT_SET)
{
}
GetMaintenanceWindowExecutionTaskInvocationResult::GetMaintenanceWindowExecutionTaskInvocationResult(const Aws::AmazonWebServiceResult<JsonValue>& result) :
m_taskType(MaintenanceWindowTaskType::NOT_SET),
m_status(MaintenanceWindowExecutionStatus::NOT_SET)
{
*this = result;
}
GetMaintenanceWindowExecutionTaskInvocationResult& GetMaintenanceWindowExecutionTaskInvocationResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
JsonView jsonValue = result.GetPayload().View();
if(jsonValue.ValueExists("WindowExecutionId"))
{
m_windowExecutionId = jsonValue.GetString("WindowExecutionId");
}
if(jsonValue.ValueExists("TaskExecutionId"))
{
m_taskExecutionId = jsonValue.GetString("TaskExecutionId");
}
if(jsonValue.ValueExists("InvocationId"))
{
m_invocationId = jsonValue.GetString("InvocationId");
}
if(jsonValue.ValueExists("ExecutionId"))
{
m_executionId = jsonValue.GetString("ExecutionId");
}
if(jsonValue.ValueExists("TaskType"))
{
m_taskType = MaintenanceWindowTaskTypeMapper::GetMaintenanceWindowTaskTypeForName(jsonValue.GetString("TaskType"));
}
if(jsonValue.ValueExists("Parameters"))
{
m_parameters = jsonValue.GetString("Parameters");
}
if(jsonValue.ValueExists("Status"))
{
m_status = MaintenanceWindowExecutionStatusMapper::GetMaintenanceWindowExecutionStatusForName(jsonValue.GetString("Status"));
}
if(jsonValue.ValueExists("StatusDetails"))
{
m_statusDetails = jsonValue.GetString("StatusDetails");
}
if(jsonValue.ValueExists("StartTime"))
{
m_startTime = jsonValue.GetDouble("StartTime");
}
if(jsonValue.ValueExists("EndTime"))
{
m_endTime = jsonValue.GetDouble("EndTime");
}
if(jsonValue.ValueExists("OwnerInformation"))
{
m_ownerInformation = jsonValue.GetString("OwnerInformation");
}
if(jsonValue.ValueExists("WindowTargetId"))
{
m_windowTargetId = jsonValue.GetString("WindowTargetId");
}
return *this;
}
|
/*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Vodafone Group Services Ltd 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 "XMLParserThreadConstants.h"
XMLParserThreadConstants::sortDistType
XMLParserThreadConstants::stringToSortDistType( const char* str ) {
if ( strcmp( str, "radius" ) == 0 ) {
return RADIUS;
} else if ( strcmp( str, "route" ) == 0 ) {
return ROUTE;
} else {
return RADIUS;
}
}
|
#pragma once
#include <fstream>
#include <iostream>
#include <boost/static_assert.hpp>
#include <regex>
// own includes ------------------------------------------------------------
#include "enum/enum.hpp"
#include "spectral_basis.hpp"
#include "spectral_basis_factory_base.hpp"
#include "spectral_elem.hpp"
#include "spectral_elem_accessor.hpp"
#include "spectral_function.hpp"
namespace boltzmann {
namespace local_ {
template <typename BASIS>
struct CMP
{
/**
* @brief lexicographical ordering for basis elements
*
*
* @return
*/
template <typename E>
bool operator()(const E& e1, const E& e2) const
{
auto id1 = e1.get_id();
auto id2 = e2.get_id();
if (id1 < id2)
return true;
else
return false;
}
};
} // end namespace local_
// ----------------------------------------------------------------------
class SpectralBasisFactoryComplex : public SpectralBasisFactoryBase<XiRC, LaguerreRR>
{
public:
/// definition of element ordering, TODO: define this at a global place
/**
*
*
* @param basis
* @param K
* @param L
* @param beta
* @param sorted sort basis functions by `l`, the angular index
*/
static void create(basis_type& basis, int K, int L, double beta, bool sorted = false);
/**
*
*
* @param basis
* @param K
* @param L
* @param beta
* @param sorted sort basis functions by `l`, the angular index
*/
static void create_test(basis_type& basis, int K, int L, double beta, bool sorted = false);
static void write_basis_descriptor(const basis_type& basis,
std::string fname = "spectral_basis.desc");
/**
* @brief read basis_descriptor file
*
* @param basis
* @param descriptor_file
*/
static void create(basis_type& basis, std::string descriptor_file);
};
// ----------------------------------------------------------------------
void
SpectralBasisFactoryComplex::create(basis_type& basis, int K, int L, double beta, bool sorted)
{
for (int l = -L; l < L; ++l) {
for (int k = 0; k < K; ++k) {
if (k % 2 == std::abs(l) % 2) {
fa_type xir(l);
fr_type phi(1. / beta, k);
basis.add_elem(xir, phi);
}
}
}
/// sort basis functions by l-index
// if (sorted) {
// basis.sort(local_::CMP<basis_type>());
// }
basis.finalize();
}
// ----------------------------------------------------------------------
void
SpectralBasisFactoryComplex::create_test(basis_type& basis, int K, int L, double beta, bool sorted)
{
for (int l = -L; l < L; ++l) {
for (int k = 0; k < K; ++k) {
if (k % 2 == std::abs(l) % 2) {
fa_type xir(l);
double fw = 1 / beta;
/// momentum conservation
if (k == 1 && l == 1) fw = 0;
/// mass and energy conservation
if ((k == 0 || k == 2) && l == 0) fw = 0;
fr_type phi(fw, k);
basis.add_elem(xir, phi);
}
}
}
// /// sort basis functions by l-index
// if(sorted) {
// basis.sort(local_::CMP<basis_type>());
// }
basis.finalize();
}
// ----------------------------------------------------------------------
void
SpectralBasisFactoryComplex::write_basis_descriptor(const basis_type& basis, std::string fname)
{
typename elem_t::Acc::template get<fa_type> xir_getter;
typename elem_t::Acc::template get<fr_type> rr_getter;
std::ofstream fout(fname);
for (auto it = basis.begin(); it != basis.end(); ++it) {
fout << xir_getter(*it).get_id() << "\t" << rr_getter(*it).get_id() << std::endl;
}
fout.close();
}
// ----------------------------------------------------------------------
void
SpectralBasisFactoryComplex::create(basis_type& basis, std::string descriptor_file)
{
std::ifstream ifile;
ifile.open(descriptor_file);
std::string line;
std::regex basisf_regex(
"exp_ii_([-]?[0-9]+)[[:space:]]*[(]beta_([0-9.]+),[[:space:]]*k_([0-9]+)[)]");
// new descriptor
std::regex basisf_regex_new(
"exp_ii_([-]?[0-9.]+)[[:space:]]*[(]fw_([0-9.]+),[[:space:]]*k_([0-9]+)[)]");
std::smatch basisf_match;
while (std::getline(ifile, line)) {
std::regex_search(line, basisf_match, basisf_regex);
if (basisf_match.size() > 0) {
auto l_match = basisf_match[1];
auto beta_match = basisf_match[2];
auto k_match = basisf_match[3];
int l = atoi(l_match.str().c_str());
int k = atoi(k_match.str().c_str());
double beta = atof(beta_match.str().c_str());
fr_type phi(1. / beta, k);
fa_type xir(l);
basis.add_elem(xir, phi);
}
// try to match new descriptor
std::regex_search(line, basisf_match, basisf_regex_new);
if (basisf_match.size() > 0) {
// angular frequency
auto l_match = basisf_match[1];
int l = atoi(l_match.str().c_str());
// exponential weight
auto fw_match = basisf_match[2];
double fw = atof(fw_match.str().c_str());
// laguerre poly index
auto k_match = basisf_match[3];
int k = atoi(k_match.str().c_str());
fr_type phi(fw, k);
fa_type xir(l);
basis.add_elem(xir, phi);
}
}
basis.finalize();
ifile.close();
}
} // end namespace boltzmann
|
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
*
* Distributable under the terms of either the Apache License (Version 2.0) or
* the GNU Lesser General Public License, as specified in the COPYING file.
------------------------------------------------------------------------------*/
#include "CLucene/StdHeader.h"
#include "DateField.h"
#include "CLucene/util/Misc.h"
CL_NS_USE(util)
CL_NS_DEF(document)
DateField::~DateField(){
}
TCHAR* DateField::timeToString(const int64_t time) {
TCHAR* buf = _CL_NEWARRAY(TCHAR,DATEFIELD_DATE_LEN + 1);
timeToString(time,buf);
return buf;
}
void DateField::timeToString(const int64_t time, TCHAR* buf) {
CND_PRECONDITION (buf, "buf == NULL");
*buf = '\0';
if (time < 0)
_CLTHROWA (CL_ERR_IllegalArgument,"time too early"); //todo: make richer error
if (time > DATEFIELD_DATE_MAX)
_CLTHROWA (CL_ERR_IllegalArgument, "time too late (past DATEFIELD_DATE_MAX"); //todo: make richer error
_i64tot(time, buf, 36);
int32_t bufLen = _tcslen(buf);
CND_PRECONDITION (bufLen <= DATEFIELD_DATE_LEN, "timeToString length is greater than 9");
/* Supply leading zeroes if necessary. */
if (bufLen < DATEFIELD_DATE_LEN) {
const int32_t nMissingZeroes = DATEFIELD_DATE_LEN - bufLen;
/* Move buffer contents forward to make room for leading zeroes. */
for (int32_t i = DATEFIELD_DATE_LEN - 1; i >= nMissingZeroes; i--)
buf[i] = buf[i - nMissingZeroes];
/* Insert leading zeroes. */
{// MSVC6 scoping fix
for (int32_t i = 0; i < nMissingZeroes; i++)
buf[i] = '0';
}
buf[DATEFIELD_DATE_LEN] = 0;
}
CND_PRECONDITION (_tcslen(buf) == DATEFIELD_DATE_LEN, "timeToString return is not equal to DATEFIELD_DATE_LEN");
}
int64_t DateField::stringToTime(const TCHAR* time) {
TCHAR* end;
return _tcstoi64(time, &end, 36);
}
CL_NS_END
|
#include "envoy/service/auth/v3/external_auth.pb.h"
#include "common/network/address_impl.h"
#include "common/protobuf/protobuf.h"
#include "extensions/filters/common/ext_authz/check_request_utils.h"
#include "extensions/filters/common/ext_authz/ext_authz.h"
#include "test/mocks/http/mocks.h"
#include "test/mocks/network/mocks.h"
#include "test/mocks/ssl/mocks.h"
#include "test/mocks/stream_info/mocks.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
using testing::Return;
using testing::ReturnPointee;
using testing::ReturnRef;
namespace Envoy {
namespace Extensions {
namespace Filters {
namespace Common {
namespace ExtAuthz {
namespace {
class CheckRequestUtilsTest : public testing::Test {
public:
CheckRequestUtilsTest() {
addr_ = std::make_shared<Network::Address::Ipv4Instance>("1.2.3.4", 1111);
protocol_ = Envoy::Http::Protocol::Http10;
buffer_ = CheckRequestUtilsTest::newTestBuffer(8192);
ssl_ = std::make_shared<NiceMock<Envoy::Ssl::MockConnectionInfo>>();
};
void expectBasicHttp() {
EXPECT_CALL(callbacks_, connection()).Times(2).WillRepeatedly(Return(&connection_));
connection_.stream_info_.downstream_address_provider_->setRemoteAddress(addr_);
connection_.stream_info_.downstream_address_provider_->setLocalAddress(addr_);
EXPECT_CALL(Const(connection_), ssl()).Times(2).WillRepeatedly(Return(ssl_));
EXPECT_CALL(callbacks_, streamId()).WillOnce(Return(0));
EXPECT_CALL(callbacks_, decodingBuffer()).WillOnce(Return(buffer_.get()));
EXPECT_CALL(callbacks_, streamInfo()).WillOnce(ReturnRef(req_info_));
EXPECT_CALL(req_info_, protocol()).Times(2).WillRepeatedly(ReturnPointee(&protocol_));
EXPECT_CALL(req_info_, startTime()).WillOnce(Return(SystemTime()));
}
void callHttpCheckAndValidateRequestAttributes(bool include_peer_certificate) {
Http::TestRequestHeaderMapImpl request_headers{{"x-envoy-downstream-service-cluster", "foo"},
{":path", "/bar"}};
envoy::service::auth::v3::CheckRequest request;
Protobuf::Map<std::string, std::string> context_extensions;
context_extensions["key"] = "value";
envoy::config::core::v3::Metadata metadata_context;
auto metadata_val = MessageUtil::keyValueStruct("foo", "bar");
(*metadata_context.mutable_filter_metadata())["meta.key"] = metadata_val;
CheckRequestUtils::createHttpCheck(
&callbacks_, request_headers, std::move(context_extensions), std::move(metadata_context),
request, /*max_request_bytes=*/0, /*pack_as_bytes=*/false, include_peer_certificate);
EXPECT_EQ("source", request.attributes().source().principal());
EXPECT_EQ("destination", request.attributes().destination().principal());
EXPECT_EQ("foo", request.attributes().source().service());
EXPECT_EQ("value", request.attributes().context_extensions().at("key"));
EXPECT_EQ("bar", request.attributes()
.metadata_context()
.filter_metadata()
.at("meta.key")
.fields()
.at("foo")
.string_value());
if (include_peer_certificate) {
EXPECT_EQ(cert_data_, request.attributes().source().certificate());
} else {
EXPECT_EQ(0, request.attributes().source().certificate().size());
}
}
static Buffer::InstancePtr newTestBuffer(uint64_t size) {
auto buffer = std::make_unique<Buffer::OwnedImpl>();
while (buffer->length() < size) {
auto new_buffer =
Buffer::OwnedImpl("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.");
buffer->add(new_buffer);
}
return buffer;
}
Network::Address::InstanceConstSharedPtr addr_;
absl::optional<Http::Protocol> protocol_;
CheckRequestUtils check_request_generator_;
NiceMock<Envoy::Http::MockStreamDecoderFilterCallbacks> callbacks_;
NiceMock<Envoy::Network::MockReadFilterCallbacks> net_callbacks_;
NiceMock<Envoy::Network::MockConnection> connection_;
std::shared_ptr<NiceMock<Envoy::Ssl::MockConnectionInfo>> ssl_;
NiceMock<Envoy::StreamInfo::MockStreamInfo> req_info_;
Buffer::InstancePtr buffer_;
const std::string cert_data_{"cert-data"};
};
// Verify that createTcpCheck's dependencies are invoked when it's called.
// Verify that the source certificate is not set by default.
TEST_F(CheckRequestUtilsTest, BasicTcp) {
envoy::service::auth::v3::CheckRequest request;
EXPECT_CALL(net_callbacks_, connection()).Times(2).WillRepeatedly(ReturnRef(connection_));
connection_.stream_info_.downstream_address_provider_->setRemoteAddress(addr_);
connection_.stream_info_.downstream_address_provider_->setLocalAddress(addr_);
EXPECT_CALL(Const(connection_), ssl()).Times(2).WillRepeatedly(Return(ssl_));
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
CheckRequestUtils::createTcpCheck(&net_callbacks_, request, false);
EXPECT_EQ(request.attributes().source().certificate().size(), 0);
}
// Verify that createTcpCheck's dependencies are invoked when it's called.
// Verify that createTcpCheck populates the source certificate correctly.
TEST_F(CheckRequestUtilsTest, TcpPeerCertificate) {
envoy::service::auth::v3::CheckRequest request;
EXPECT_CALL(net_callbacks_, connection()).Times(2).WillRepeatedly(ReturnRef(connection_));
connection_.stream_info_.downstream_address_provider_->setRemoteAddress(addr_);
connection_.stream_info_.downstream_address_provider_->setLocalAddress(addr_);
EXPECT_CALL(Const(connection_), ssl()).Times(2).WillRepeatedly(Return(ssl_));
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
EXPECT_CALL(*ssl_, urlEncodedPemEncodedPeerCertificate()).WillOnce(ReturnRef(cert_data_));
CheckRequestUtils::createTcpCheck(&net_callbacks_, request, true);
EXPECT_EQ(cert_data_, request.attributes().source().certificate());
}
// Verify that createHttpCheck's dependencies are invoked when it's called.
// Verify that check request object has no request data.
// Verify that a client supplied EnvoyAuthPartialBody will not affect the
// CheckRequest call.
TEST_F(CheckRequestUtilsTest, BasicHttp) {
const uint64_t size = 0;
envoy::service::auth::v3::CheckRequest request_;
// A client supplied EnvoyAuthPartialBody header should be ignored.
Http::TestRequestHeaderMapImpl request_headers{{Headers::get().EnvoyAuthPartialBody.get(), "1"}};
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
expectBasicHttp();
CheckRequestUtils::createHttpCheck(&callbacks_, request_headers,
Protobuf::Map<std::string, std::string>(),
envoy::config::core::v3::Metadata(), request_, size,
/*pack_as_bytes=*/false, /*include_peer_certificate=*/false);
ASSERT_EQ(size, request_.attributes().request().http().body().size());
EXPECT_EQ(buffer_->toString().substr(0, size), request_.attributes().request().http().body());
EXPECT_EQ(request_.attributes().request().http().headers().end(),
request_.attributes().request().http().headers().find(
Headers::get().EnvoyAuthPartialBody.get()));
EXPECT_TRUE(request_.attributes().request().has_time());
}
// Verify that check request object has only a portion of the request data.
TEST_F(CheckRequestUtilsTest, BasicHttpWithPartialBody) {
const uint64_t size = 4049;
Http::TestRequestHeaderMapImpl headers_;
envoy::service::auth::v3::CheckRequest request_;
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
expectBasicHttp();
CheckRequestUtils::createHttpCheck(&callbacks_, headers_,
Protobuf::Map<std::string, std::string>(),
envoy::config::core::v3::Metadata(), request_, size,
/*pack_as_bytes=*/false, /*include_peer_certificate=*/false);
ASSERT_EQ(size, request_.attributes().request().http().body().size());
EXPECT_EQ(buffer_->toString().substr(0, size), request_.attributes().request().http().body());
EXPECT_EQ("true", request_.attributes().request().http().headers().at(
Headers::get().EnvoyAuthPartialBody.get()));
}
// Verify that check request object has all the request data.
TEST_F(CheckRequestUtilsTest, BasicHttpWithFullBody) {
Http::TestRequestHeaderMapImpl headers_;
envoy::service::auth::v3::CheckRequest request_;
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
expectBasicHttp();
CheckRequestUtils::createHttpCheck(
&callbacks_, headers_, Protobuf::Map<std::string, std::string>(),
envoy::config::core::v3::Metadata(), request_, buffer_->length(), /*pack_as_bytes=*/false,
/*include_peer_certificate=*/false);
ASSERT_EQ(buffer_->length(), request_.attributes().request().http().body().size());
EXPECT_EQ(buffer_->toString().substr(0, buffer_->length()),
request_.attributes().request().http().body());
EXPECT_EQ("false", request_.attributes().request().http().headers().at(
Headers::get().EnvoyAuthPartialBody.get()));
}
// Verify that check request object has all the request data and packed as bytes instead of UTF-8
// string.
TEST_F(CheckRequestUtilsTest, BasicHttpWithFullBodyPackAsBytes) {
Http::TestRequestHeaderMapImpl headers_;
envoy::service::auth::v3::CheckRequest request_;
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
// Fill the buffer with non UTF-8 data.
uint8_t raw[2] = {0xc0, 0xc0};
Buffer::OwnedImpl raw_buffer(raw, 2);
buffer_->drain(buffer_->length());
buffer_->add(raw_buffer);
expectBasicHttp();
// Setting pack_as_bytes as false and a string field with invalid UTF-8 data makes
// calling request_.SerializeToString() below to print an error message to stderr. Interestingly,
// request_.SerializeToString() still returns "true" when it is failed to serialize the data.
CheckRequestUtils::createHttpCheck(
&callbacks_, headers_, Protobuf::Map<std::string, std::string>(),
envoy::config::core::v3::Metadata(), request_, buffer_->length(), /*pack_as_bytes=*/true,
/*include_peer_certificate=*/false);
// TODO(dio): Find a way to test this without using function from testing::internal namespace.
testing::internal::CaptureStderr();
std::string out;
ASSERT_TRUE(request_.SerializeToString(&out));
ASSERT_EQ("", testing::internal::GetCapturedStderr());
// Non UTF-8 data sets raw_body field, instead of body field.
ASSERT_EQ(buffer_->length(), request_.attributes().request().http().raw_body().size());
ASSERT_EQ(0, request_.attributes().request().http().body().size());
EXPECT_EQ(buffer_->toString().substr(0, buffer_->length()),
request_.attributes().request().http().raw_body());
EXPECT_EQ("false", request_.attributes().request().http().headers().at(
Headers::get().EnvoyAuthPartialBody.get()));
}
// Verify that createHttpCheck extract the proper attributes from the http request into CheckRequest
// proto object.
// Verify that the source certificate is not set by default.
TEST_F(CheckRequestUtilsTest, CheckAttrContextPeer) {
Http::TestRequestHeaderMapImpl request_headers{{"x-envoy-downstream-service-cluster", "foo"},
{":path", "/bar"}};
envoy::service::auth::v3::CheckRequest request;
EXPECT_CALL(callbacks_, connection()).WillRepeatedly(Return(&connection_));
connection_.stream_info_.downstream_address_provider_->setRemoteAddress(addr_);
connection_.stream_info_.downstream_address_provider_->setLocalAddress(addr_);
EXPECT_CALL(Const(connection_), ssl()).WillRepeatedly(Return(ssl_));
EXPECT_CALL(callbacks_, streamId()).WillRepeatedly(Return(0));
EXPECT_CALL(callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_));
EXPECT_CALL(callbacks_, decodingBuffer());
EXPECT_CALL(req_info_, protocol()).WillRepeatedly(ReturnPointee(&protocol_));
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
callHttpCheckAndValidateRequestAttributes(false);
}
// Verify that createHttpCheck extract the attributes from the HTTP request into CheckRequest
// proto object and URI SAN is used as principal if present.
TEST_F(CheckRequestUtilsTest, CheckAttrContextPeerUriSans) {
expectBasicHttp();
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
callHttpCheckAndValidateRequestAttributes(false);
}
// Verify that createHttpCheck extract the attributes from the HTTP request into CheckRequest
// proto object and DNS SAN is used as principal if URI SAN is absent.
TEST_F(CheckRequestUtilsTest, CheckAttrContextPeerDnsSans) {
expectBasicHttp();
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{}));
EXPECT_CALL(*ssl_, dnsSansPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate()).WillOnce(Return(std::vector<std::string>{}));
EXPECT_CALL(*ssl_, dnsSansLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
Protobuf::Map<std::string, std::string> context_extensions;
context_extensions["key"] = "value";
callHttpCheckAndValidateRequestAttributes(false);
}
// Verify that createHttpCheck extract the attributes from the HTTP request into CheckRequest
// proto object and Subject is used as principal if both URI SAN and DNS SAN are absent.
TEST_F(CheckRequestUtilsTest, CheckAttrContextSubject) {
expectBasicHttp();
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{}));
EXPECT_CALL(*ssl_, dnsSansPeerCertificate()).WillOnce(Return(std::vector<std::string>{}));
std::string subject_peer = "source";
EXPECT_CALL(*ssl_, subjectPeerCertificate()).WillOnce(ReturnRef(subject_peer));
EXPECT_CALL(*ssl_, uriSanLocalCertificate()).WillOnce(Return(std::vector<std::string>{}));
EXPECT_CALL(*ssl_, dnsSansLocalCertificate()).WillOnce(Return(std::vector<std::string>{}));
std::string subject_local = "destination";
EXPECT_CALL(*ssl_, subjectLocalCertificate()).WillOnce(ReturnRef(subject_local));
callHttpCheckAndValidateRequestAttributes(false);
}
// Verify that the source certificate is populated correctly.
TEST_F(CheckRequestUtilsTest, CheckAttrContextPeerCertificate) {
expectBasicHttp();
EXPECT_CALL(*ssl_, uriSanPeerCertificate()).WillOnce(Return(std::vector<std::string>{"source"}));
EXPECT_CALL(*ssl_, uriSanLocalCertificate())
.WillOnce(Return(std::vector<std::string>{"destination"}));
EXPECT_CALL(*ssl_, urlEncodedPemEncodedPeerCertificate()).WillOnce(ReturnRef(cert_data_));
callHttpCheckAndValidateRequestAttributes(true);
}
} // namespace
} // namespace ExtAuthz
} // namespace Common
} // namespace Filters
} // namespace Extensions
} // namespace Envoy
|
/*
* Copyright 2017-2019 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 <gtest/gtest.h>
#include "Alerts/Alarm.h"
namespace alexaClientSDK {
namespace capabilityAgents {
namespace alerts {
namespace test {
static const std::string ALARM_DEFAULT_DATA = "alarm default data";
static const std::string ALARM_SHORT_DATA = "alarm short data";
class AlarmAlertTest : public ::testing::Test {
public:
AlarmAlertTest();
static std::unique_ptr<std::istream> alarmDefaultFactory() {
return std::unique_ptr<std::stringstream>(new std::stringstream(ALARM_DEFAULT_DATA));
}
static std::unique_ptr<std::istream> alarmShortFactory() {
return std::unique_ptr<std::stringstream>(new std::stringstream(ALARM_SHORT_DATA));
}
std::shared_ptr<Alarm> m_alarm;
};
AlarmAlertTest::AlarmAlertTest() : m_alarm{std::make_shared<Alarm>(alarmDefaultFactory, alarmShortFactory)} {
}
TEST_F(AlarmAlertTest, test_defaultAudio) {
std::ostringstream oss;
oss << m_alarm->getDefaultAudioFactory()()->rdbuf();
ASSERT_EQ(ALARM_DEFAULT_DATA, oss.str());
}
TEST_F(AlarmAlertTest, test_shortAudio) {
std::ostringstream oss;
oss << m_alarm->getShortAudioFactory()()->rdbuf();
ASSERT_EQ(ALARM_SHORT_DATA, oss.str());
}
TEST_F(AlarmAlertTest, test_getTypeName) {
ASSERT_EQ(m_alarm->getTypeName(), Alarm::TYPE_NAME);
}
} // namespace test
} // namespace alerts
} // namespace capabilityAgents
} // namespace alexaClientSDK
|
/**
* @file testPoseWithNode.cpp
* @brief Unit test for PoseWithNode and calculations
* @author Yun Chang
*/
#include <CppUnitLite/TestHarness.h>
#include <limits>
#include <random>
#include "KimeraRPGO/utils/geometry_utils.h"
using KimeraRPGO::PoseWithNode;
/* ************************************************************************* */
TEST(PoseWithNode, Inverse) {
// Test the inverse operator for PoseWithNode struct
PoseWithNode<gtsam::Pose3> A, B;
// Create linearization points
gtsam::Pose3 poseA(gtsam::Rot3(), gtsam::Point3(0, 0, 0));
A.pose = poseA;
A.node = 6;
B = A.inverse();
EXPECT(gtsam::assert_equal(B.pose, A.pose.inverse()));
EXPECT(6 == A.node);
}
/* ************************************************************************* */
TEST(PoseWithNode, Compose) {
// Test the compose operator for PoseWithNode struct
PoseWithNode<gtsam::Pose3> A, AB, B, BC, C, CD, D;
A.pose = gtsam::Pose3(gtsam::Rot3(), gtsam::Point3(1, 1, 1)); // start
A.node = 1;
// First test a translation only
gtsam::Pose3 poseAB(gtsam::Rot3(), gtsam::Point3(1, 1, 1));
AB.pose = poseAB;
AB.node = 1;
B = A.compose(AB);
EXPECT(gtsam::assert_equal(A.pose.compose(AB.pose), B.pose));
EXPECT(2 == B.node);
// Then rotation only
gtsam::Pose3 poseBC(gtsam::Rot3(0, 0, 0, 1), gtsam::Point3());
BC.pose = poseBC;
BC.node = 1;
C = B.compose(BC);
EXPECT(gtsam::assert_equal(B.pose.compose(BC.pose), C.pose));
EXPECT(3 == C.node);
}
/* ************************************************************************* */
TEST(PoseWithNode, Between) {
// Test the between operator for the PoseWithNode struct
PoseWithNode<gtsam::Pose3> A, B, C;
A.pose = gtsam::Pose3();
A.node = 1;
C.pose = gtsam::Pose3(gtsam::Rot3(0, 0, 1, 0), gtsam::Point3(1, 0, 0));
C.node = 5;
B = A.between(C);
gtsam::Pose3 B_pose =
gtsam::Pose3(gtsam::Rot3(0, 0, 1, 0), gtsam::Point3(1, 0, 0));
EXPECT(gtsam::assert_equal(B_pose, B.pose));
EXPECT(4 == B.node);
}
/* ************************************************************************* */
TEST(PoseWithNode, Norm) {
// Test the between operator for the PoseWithNode struct
PoseWithNode<gtsam::Pose3> A, B, C;
A.pose = gtsam::Pose3();
A.node = 1;
EXPECT(0 == A.avg_rot_norm());
EXPECT(0 == A.avg_trans_norm());
B.pose = gtsam::Pose3(gtsam::Rot3(1, 0, 0, 0), gtsam::Point3(1, 0, 0));
B.node = 5;
EXPECT(0.2 == B.avg_trans_norm());
C.pose = gtsam::Pose3(gtsam::Rot3(0, 0, 1, 0), gtsam::Point3(0, 0, 0));
C.node = 5;
EXPECT_DOUBLES_EQUAL(3.1415927 / 5, C.avg_rot_norm(), 1e-6);
}
/* ************************************************************************* */
int main() {
TestResult tr;
return TestRegistry::runAllTests(tr);
}
/* ************************************************************************* */
|
/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
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 PHOENIX_CORE_ACTOR_HPP
#define PHOENIX_CORE_ACTOR_HPP
#if !defined(BOOST_RESULT_OF_NUM_ARGS)
# define BOOST_RESULT_OF_NUM_ARGS PHOENIX_ACTOR_LIMIT
#else
# if (BOOST_RESULT_OF_NUM_ARGS < PHOENIX_ACTOR_LIMIT)
# error "BOOST_RESULT_OF_NUM_ARGS < PHOENIX_ACTOR_LIMIT"
# endif
#endif
#include <boost/spirit/home/phoenix/core/limits.hpp>
#include <boost/spirit/home/phoenix/core/basic_environment.hpp>
#include <boost/mpl/min.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/result_of.hpp>
namespace boost { namespace phoenix
{
// phoenix::void_ is the same as fusion::void_
typedef fusion::void_ void_;
namespace detail
{
// Forward declarations. These will come in when we get to the
// operator module, yet, the actor's assignment operator and index
// operator are required to be members.
template <typename T0, typename T1>
struct make_assign_composite;
template <typename T0, typename T1>
struct make_index_composite;
template <typename BaseT0, typename BaseT1>
struct comma_result;
// error no arguments supplied
struct error_expecting_arguments
{
template <typename T>
error_expecting_arguments(T const&) {}
};
}
template <typename Eval, typename Env>
struct eval_result
{
typedef typename Eval::template result<Env>::type type;
};
template <typename Eval>
struct actor : Eval
{
typedef actor<Eval> self_type;
typedef Eval eval_type;
template <class Sig> struct result {};
actor()
: Eval() {}
actor(Eval const& base)
: Eval(base) {}
template <typename T0>
explicit actor(T0 const& _0)
: Eval(_0) {}
template <typename T0, typename T1>
actor(T0 const& _0, T1 const& _1)
: Eval(_0, _1) {}
typedef typename
mpl::eval_if<
typename Eval::no_nullary // avoid calling eval_result when this is true
, mpl::identity<detail::error_expecting_arguments>
, eval_result<eval_type, basic_environment<> >
>::type
nullary_result;
nullary_result
operator()() const
{
return eval_type::eval(basic_environment<>());
}
template <class F, class A0>
struct result<F(A0)>
: eval_result<
eval_type
, basic_environment<
typename remove_reference<typename add_const<A0>::type>::type
>
>
{};
template <typename T0>
typename result<actor(T0&)>::type
operator()(T0& _0) const
{
return eval_type::eval(basic_environment<T0>(_0));
}
template <class F, class A0, class A1>
struct result<F(A0,A1)>
: eval_result<
eval_type
, basic_environment<
typename remove_reference<typename add_const<A0>::type>::type
, typename remove_reference<typename add_const<A1>::type>::type
>
>
{};
template <typename T0, typename T1>
typename result<actor(T0&,T1&)>::type
operator()(T0& _0, T1& _1) const
{
return eval_type::eval(basic_environment<T0, T1>(_0, _1));
}
template <typename T1>
typename detail::make_assign_composite<self_type, T1>::type
operator=(T1 const& a1) const;
template <typename T1>
typename detail::make_index_composite<self_type, T1>::type
operator[](T1 const& a1) const;
// Bring in the rest of the constructors and function call operators
#include <boost/spirit/home/phoenix/core/detail/actor.hpp>
};
// Forward declaration: The intent to overload the comma must be
// stated early on to avoid the subtle problem that arises when
// the header file where the comma operator overload is defined,
// is not included by the client and the client attempts to use
// the comma anyway.
namespace detail
{
template <typename BaseT0, typename BaseT1>
struct comma_result;
}
template <typename BaseT0, typename BaseT1>
typename detail::comma_result<BaseT0, BaseT1>::type
operator,(actor<BaseT0> const& a0, actor<BaseT1> const& a1);
}}
namespace boost
{
template <typename Eval>
struct result_of<phoenix::actor<Eval>()>
{
typedef typename phoenix::actor<Eval>::nullary_result type;
};
template <typename Eval>
struct result_of<phoenix::actor<Eval> const()>
: result_of<phoenix::actor<Eval>()>
{};
}
#endif
|
/*
* The MIT License (MIT)
*
* Copyright (c) 2012, 2013 <dhbaird@gmail.com>
*
* 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.
*/
/*
* IXWebSocketTransport.cpp
* Author: Benjamin Sergeant
* Copyright (c) 2017-2019 Machine Zone, Inc. All rights reserved.
*/
//
// Adapted from https://github.com/dhbaird/easywsclient
//
#include "IXWebSocketTransport.h"
#include "IXSocketFactory.h"
#include "IXSocketTLSOptions.h"
#include "IXUrlParser.h"
#include "IXUtf8Validator.h"
#include "IXWebSocketHandshake.h"
#include "IXWebSocketHttpHeaders.h"
#include <chrono>
#include <cstdarg>
#include <cstdlib>
#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <thread>
#include <vector>
namespace ix
{
const std::string WebSocketTransport::kPingMessage("ixwebsocket::heartbeat");
const int WebSocketTransport::kDefaultPingIntervalSecs(-1);
const bool WebSocketTransport::kDefaultEnablePong(true);
const int WebSocketTransport::kClosingMaximumWaitingDelayInMs(300);
constexpr size_t WebSocketTransport::kChunkSize;
WebSocketTransport::WebSocketTransport()
: _useMask(true)
, _blockingSend(false)
, _receivedMessageCompressed(false)
, _readyState(ReadyState::CLOSED)
, _closeCode(WebSocketCloseConstants::kInternalErrorCode)
, _closeReason(WebSocketCloseConstants::kInternalErrorMessage)
, _closeWireSize(0)
, _closeRemote(false)
, _enablePerMessageDeflate(false)
, _requestInitCancellation(false)
, _closingTimePoint(std::chrono::steady_clock::now())
, _enablePong(kDefaultEnablePong)
, _pingIntervalSecs(kDefaultPingIntervalSecs)
, _pongReceived(false)
, _pingCount(0)
, _lastSendPingTimePoint(std::chrono::steady_clock::now())
{
_readbuf.resize(kChunkSize);
}
WebSocketTransport::~WebSocketTransport()
{
;
}
void WebSocketTransport::configure(
const WebSocketPerMessageDeflateOptions& perMessageDeflateOptions,
const SocketTLSOptions& socketTLSOptions,
bool enablePong,
int pingIntervalSecs)
{
_perMessageDeflateOptions = perMessageDeflateOptions;
_enablePerMessageDeflate = _perMessageDeflateOptions.enabled();
_socketTLSOptions = socketTLSOptions;
_enablePong = enablePong;
_pingIntervalSecs = pingIntervalSecs;
}
// Client
WebSocketInitResult WebSocketTransport::connectToUrl(const std::string& url,
const WebSocketHttpHeaders& headers,
int timeoutSecs)
{
std::lock_guard<std::mutex> lock(_socketMutex);
std::string protocol, host, path, query;
int port;
if (!UrlParser::parse(url, protocol, host, path, query, port))
{
std::stringstream ss;
ss << "Could not parse url: '" << url << "'";
return WebSocketInitResult(false, 0, ss.str());
}
std::string errorMsg;
bool tls = protocol == "wss";
_socket = createSocket(tls, -1, errorMsg, _socketTLSOptions);
_perMessageDeflate = std::make_unique<WebSocketPerMessageDeflate>();
if (!_socket)
{
return WebSocketInitResult(false, 0, errorMsg);
}
WebSocketHandshake webSocketHandshake(_requestInitCancellation,
_socket,
_perMessageDeflate,
_perMessageDeflateOptions,
_enablePerMessageDeflate);
auto result =
webSocketHandshake.clientHandshake(url, headers, host, path, port, timeoutSecs);
if (result.success)
{
setReadyState(ReadyState::OPEN);
}
return result;
}
// Server
WebSocketInitResult WebSocketTransport::connectToSocket(std::unique_ptr<Socket> socket,
int timeoutSecs)
{
std::lock_guard<std::mutex> lock(_socketMutex);
// Server should not mask the data it sends to the client
_useMask = false;
_blockingSend = true;
_socket = std::move(socket);
_perMessageDeflate = std::make_unique<WebSocketPerMessageDeflate>();
WebSocketHandshake webSocketHandshake(_requestInitCancellation,
_socket,
_perMessageDeflate,
_perMessageDeflateOptions,
_enablePerMessageDeflate);
auto result = webSocketHandshake.serverHandshake(timeoutSecs);
if (result.success)
{
setReadyState(ReadyState::OPEN);
}
return result;
}
WebSocketTransport::ReadyState WebSocketTransport::getReadyState() const
{
return _readyState;
}
void WebSocketTransport::setReadyState(ReadyState readyState)
{
// No state change, return
if (_readyState == readyState) return;
if (readyState == ReadyState::CLOSED)
{
std::lock_guard<std::mutex> lock(_closeDataMutex);
_onCloseCallback(_closeCode, _closeReason, _closeWireSize, _closeRemote);
_closeCode = WebSocketCloseConstants::kInternalErrorCode;
_closeReason = WebSocketCloseConstants::kInternalErrorMessage;
_closeWireSize = 0;
_closeRemote = false;
}
else if (readyState == ReadyState::OPEN)
{
initTimePointsAfterConnect();
_pongReceived = false;
}
_readyState = readyState;
}
void WebSocketTransport::setOnCloseCallback(const OnCloseCallback& onCloseCallback)
{
_onCloseCallback = onCloseCallback;
}
void WebSocketTransport::initTimePointsAfterConnect()
{
{
std::lock_guard<std::mutex> lock(_lastSendPingTimePointMutex);
_lastSendPingTimePoint = std::chrono::steady_clock::now();
}
}
// Only consider send PING time points for that computation.
bool WebSocketTransport::pingIntervalExceeded()
{
if (_pingIntervalSecs <= 0) return false;
std::lock_guard<std::mutex> lock(_lastSendPingTimePointMutex);
auto now = std::chrono::steady_clock::now();
return now - _lastSendPingTimePoint > std::chrono::seconds(_pingIntervalSecs);
}
WebSocketSendInfo WebSocketTransport::sendHeartBeat()
{
_pongReceived = false;
std::stringstream ss;
ss << kPingMessage << "::" << _pingIntervalSecs << "s"
<< "::" << _pingCount++;
return sendPing(ss.str());
}
bool WebSocketTransport::closingDelayExceeded()
{
std::lock_guard<std::mutex> lock(_closingTimePointMutex);
auto now = std::chrono::steady_clock::now();
return now - _closingTimePoint > std::chrono::milliseconds(kClosingMaximumWaitingDelayInMs);
}
WebSocketTransport::PollResult WebSocketTransport::poll()
{
if (_readyState == ReadyState::OPEN)
{
if (pingIntervalExceeded())
{
if (!_pongReceived)
{
// ping response (PONG) exceeds the maximum delay, close the connection
close(WebSocketCloseConstants::kInternalErrorCode,
WebSocketCloseConstants::kPingTimeoutMessage);
}
else
{
sendHeartBeat();
}
}
}
// No timeout if state is not OPEN, otherwise computed
// pingIntervalOrTimeoutGCD (equals to -1 if no ping and no ping timeout are set)
int lastingTimeoutDelayInMs = (_readyState != ReadyState::OPEN) ? 0 : _pingIntervalSecs;
if (_pingIntervalSecs > 0)
{
// compute lasting delay to wait for next ping / timeout, if at least one set
auto now = std::chrono::steady_clock::now();
lastingTimeoutDelayInMs = (int) std::chrono::duration_cast<std::chrono::milliseconds>(
now - _lastSendPingTimePoint)
.count();
}
#ifdef _WIN32
// Windows does not have select interrupt capabilities, so wait with a small timeout
if (lastingTimeoutDelayInMs <= 0)
{
lastingTimeoutDelayInMs = 20;
}
#endif
// If we are requesting a cancellation, pass in a positive and small timeout
// to never poll forever without a timeout.
if (_requestInitCancellation)
{
lastingTimeoutDelayInMs = 100;
}
// poll the socket
PollResultType pollResult = _socket->isReadyToRead(lastingTimeoutDelayInMs);
// Make sure we send all the buffered data
// there can be a lot of it for large messages.
if (pollResult == PollResultType::SendRequest)
{
if (!flushSendBuffer())
{
return PollResult::CannotFlushSendBuffer;
}
}
else if (pollResult == PollResultType::ReadyForRead)
{
if (!receiveFromSocket())
{
return PollResult::AbnormalClose;
}
}
else if (pollResult == PollResultType::Error)
{
closeSocket();
}
else if (pollResult == PollResultType::CloseRequest)
{
closeSocket();
}
if (_readyState == ReadyState::CLOSING && closingDelayExceeded())
{
_rxbuf.clear();
// close code and reason were set when calling close()
closeSocket();
setReadyState(ReadyState::CLOSED);
}
return PollResult::Succeeded;
}
bool WebSocketTransport::isSendBufferEmpty() const
{
std::lock_guard<std::mutex> lock(_txbufMutex);
return _txbuf.empty();
}
void WebSocketTransport::appendToSendBuffer(const std::vector<uint8_t>& header,
std::string::const_iterator begin,
std::string::const_iterator end,
uint64_t message_size,
uint8_t masking_key[4])
{
std::lock_guard<std::mutex> lock(_txbufMutex);
_txbuf.insert(_txbuf.end(), header.begin(), header.end());
_txbuf.insert(_txbuf.end(), begin, end);
if (_useMask)
{
for (size_t i = 0; i != (size_t) message_size; ++i)
{
*(_txbuf.end() - (size_t) message_size + i) ^= masking_key[i & 0x3];
}
}
}
void WebSocketTransport::unmaskReceiveBuffer(const wsheader_type& ws)
{
if (ws.mask)
{
for (size_t j = 0; j != ws.N; ++j)
{
_rxbuf[j + ws.header_size] ^= ws.masking_key[j & 0x3];
}
}
}
//
// http://tools.ietf.org/html/rfc6455#section-5.2 Base Framing Protocol
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-------+-+-------------+-------------------------------+
// |F|R|R|R| opcode|M| Payload len | Extended payload length |
// |I|S|S|S| (4) |A| (7) | (16/64) |
// |N|V|V|V| |S| | (if payload len==126/127) |
// | |1|2|3| |K| | |
// +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
// | Extended payload length continued, if payload len == 127 |
// + - - - - - - - - - - - - - - - +-------------------------------+
// | |Masking-key, if MASK set to 1 |
// +-------------------------------+-------------------------------+
// | Masking-key (continued) | Payload Data |
// +-------------------------------- - - - - - - - - - - - - - - - +
// : Payload Data continued ... :
// + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
// | Payload Data continued ... |
// +---------------------------------------------------------------+
//
void WebSocketTransport::dispatch(WebSocketTransport::PollResult pollResult,
const OnMessageCallback& onMessageCallback)
{
while (true)
{
wsheader_type ws;
if (_rxbuf.size() < 2) break; /* Need at least 2 */
const uint8_t* data = (uint8_t*) &_rxbuf[0]; // peek, but don't consume
ws.fin = (data[0] & 0x80) == 0x80;
ws.rsv1 = (data[0] & 0x40) == 0x40;
ws.rsv2 = (data[0] & 0x20) == 0x20;
ws.rsv3 = (data[0] & 0x10) == 0x10;
ws.opcode = (wsheader_type::opcode_type)(data[0] & 0x0f);
ws.mask = (data[1] & 0x80) == 0x80;
ws.N0 = (data[1] & 0x7f);
ws.header_size =
2 + (ws.N0 == 126 ? 2 : 0) + (ws.N0 == 127 ? 8 : 0) + (ws.mask ? 4 : 0);
if (_rxbuf.size() < ws.header_size) break; /* Need: ws.header_size - _rxbuf.size() */
if ((ws.rsv1 && !_enablePerMessageDeflate) || ws.rsv2 || ws.rsv3)
{
close(WebSocketCloseConstants::kProtocolErrorCode,
WebSocketCloseConstants::kProtocolErrorReservedBitUsed,
_rxbuf.size());
return;
}
//
// Calculate payload length:
// 0-125 mean the payload is that long.
// 126 means that the following two bytes indicate the length,
// 127 means the next 8 bytes indicate the length.
//
int i = 0;
if (ws.N0 < 126)
{
ws.N = ws.N0;
i = 2;
}
else if (ws.N0 == 126)
{
ws.N = 0;
ws.N |= ((uint64_t) data[2]) << 8;
ws.N |= ((uint64_t) data[3]) << 0;
i = 4;
}
else if (ws.N0 == 127)
{
ws.N = 0;
ws.N |= ((uint64_t) data[2]) << 56;
ws.N |= ((uint64_t) data[3]) << 48;
ws.N |= ((uint64_t) data[4]) << 40;
ws.N |= ((uint64_t) data[5]) << 32;
ws.N |= ((uint64_t) data[6]) << 24;
ws.N |= ((uint64_t) data[7]) << 16;
ws.N |= ((uint64_t) data[8]) << 8;
ws.N |= ((uint64_t) data[9]) << 0;
i = 10;
}
else
{
// invalid payload length according to the spec. bail out
return;
}
if (ws.mask)
{
ws.masking_key[0] = ((uint8_t) data[i + 0]) << 0;
ws.masking_key[1] = ((uint8_t) data[i + 1]) << 0;
ws.masking_key[2] = ((uint8_t) data[i + 2]) << 0;
ws.masking_key[3] = ((uint8_t) data[i + 3]) << 0;
}
else
{
ws.masking_key[0] = 0;
ws.masking_key[1] = 0;
ws.masking_key[2] = 0;
ws.masking_key[3] = 0;
}
// Prevent integer overflow in the next conditional
const uint64_t maxFrameSize(1ULL << 63);
if (ws.N > maxFrameSize)
{
return;
}
if (_rxbuf.size() < ws.header_size + ws.N)
{
return; /* Need: ws.header_size+ws.N - _rxbuf.size() */
}
if (!ws.fin && (ws.opcode == wsheader_type::PING || ws.opcode == wsheader_type::PONG ||
ws.opcode == wsheader_type::CLOSE))
{
// Control messages should not be fragmented
close(WebSocketCloseConstants::kProtocolErrorCode,
WebSocketCloseConstants::kProtocolErrorCodeControlMessageFragmented);
return;
}
unmaskReceiveBuffer(ws);
std::string frameData(_rxbuf.begin() + ws.header_size,
_rxbuf.begin() + ws.header_size + (size_t) ws.N);
// We got a whole message, now do something with it:
if (ws.opcode == wsheader_type::TEXT_FRAME ||
ws.opcode == wsheader_type::BINARY_FRAME ||
ws.opcode == wsheader_type::CONTINUATION)
{
if (ws.opcode != wsheader_type::CONTINUATION)
{
_fragmentedMessageKind = (ws.opcode == wsheader_type::TEXT_FRAME)
? MessageKind::MSG_TEXT
: MessageKind::MSG_BINARY;
_receivedMessageCompressed = _enablePerMessageDeflate && ws.rsv1;
// Continuation message needs to follow a non-fin TEXT or BINARY message
if (!_chunks.empty())
{
close(WebSocketCloseConstants::kProtocolErrorCode,
WebSocketCloseConstants::kProtocolErrorCodeDataOpcodeOutOfSequence);
}
}
else if (_chunks.empty())
{
// Continuation message need to follow a non-fin TEXT or BINARY message
close(
WebSocketCloseConstants::kProtocolErrorCode,
WebSocketCloseConstants::kProtocolErrorCodeContinuationOpCodeOutOfSequence);
}
//
// Usual case. Small unfragmented messages
//
if (ws.fin && _chunks.empty())
{
emitMessage(_fragmentedMessageKind,
frameData,
_receivedMessageCompressed,
onMessageCallback);
_receivedMessageCompressed = false;
}
else
{
//
// Add intermediary message to our chunk list.
// We use a chunk list instead of a big buffer because resizing
// large buffer can be very costly when we need to re-allocate
// the internal buffer which is slow and can let the internal OS
// receive buffer fill out.
//
_chunks.emplace_back(frameData);
if (ws.fin)
{
emitMessage(_fragmentedMessageKind,
getMergedChunks(),
_receivedMessageCompressed,
onMessageCallback);
_chunks.clear();
_receivedMessageCompressed = false;
}
else
{
emitMessage(MessageKind::FRAGMENT, std::string(), false, onMessageCallback);
}
}
}
else if (ws.opcode == wsheader_type::PING)
{
// too large
if (frameData.size() > 125)
{
// Unexpected frame type
close(WebSocketCloseConstants::kProtocolErrorCode,
WebSocketCloseConstants::kProtocolErrorPingPayloadOversized);
return;
}
if (_enablePong)
{
// Reply back right away
bool compress = false;
sendData(wsheader_type::PONG, frameData, compress);
}
emitMessage(MessageKind::PING, frameData, false, onMessageCallback);
}
else if (ws.opcode == wsheader_type::PONG)
{
_pongReceived = true;
emitMessage(MessageKind::PONG, frameData, false, onMessageCallback);
}
else if (ws.opcode == wsheader_type::CLOSE)
{
std::string reason;
uint16_t code = 0;
if (ws.N >= 2)
{
// Extract the close code first, available as the first 2 bytes
code |= ((uint64_t) _rxbuf[ws.header_size]) << 8;
code |= ((uint64_t) _rxbuf[ws.header_size + 1]) << 0;
// Get the reason.
if (ws.N > 2)
{
reason = frameData.substr(2, frameData.size());
}
// Validate that the reason is proper utf-8. Autobahn 7.5.1
if (!validateUtf8(reason))
{
code = WebSocketCloseConstants::kInvalidFramePayloadData;
reason = WebSocketCloseConstants::kInvalidFramePayloadDataMessage;
}
//
// Validate close codes. Autobahn 7.9.*
// 1014, 1015 are debattable. The firefox MSDN has a description for them.
// Full list of status code and status range is defined in the dedicated
// RFC section at https://tools.ietf.org/html/rfc6455#page-45
//
if (code < 1000 || code == 1004 || code == 1006 || (code > 1013 && code < 3000))
{
// build up an error message containing the bad error code
std::stringstream ss;
ss << WebSocketCloseConstants::kInvalidCloseCodeMessage << ": " << code;
reason = ss.str();
code = WebSocketCloseConstants::kProtocolErrorCode;
}
}
else
{
// no close code received
code = WebSocketCloseConstants::kNoStatusCodeErrorCode;
reason = WebSocketCloseConstants::kNoStatusCodeErrorMessage;
}
// We receive a CLOSE frame from remote and are NOT the ones who triggered the close
if (_readyState != ReadyState::CLOSING)
{
// send back the CLOSE frame
sendCloseFrame(code, reason);
wakeUpFromPoll(Socket::kCloseRequest);
bool remote = true;
closeSocketAndSwitchToClosedState(code, reason, _rxbuf.size(), remote);
}
else
{
// we got the CLOSE frame answer from our close, so we can close the connection
// if the code/reason are the same
bool identicalReason;
{
std::lock_guard<std::mutex> lock(_closeDataMutex);
identicalReason = _closeCode == code && _closeReason == reason;
}
if (identicalReason)
{
bool remote = false;
closeSocketAndSwitchToClosedState(code, reason, _rxbuf.size(), remote);
}
}
}
else
{
// Unexpected frame type
close(WebSocketCloseConstants::kProtocolErrorCode,
WebSocketCloseConstants::kProtocolErrorMessage,
_rxbuf.size());
}
// Erase the message that has been processed from the input/read buffer
_rxbuf.erase(_rxbuf.begin(), _rxbuf.begin() + ws.header_size + (size_t) ws.N);
}
// if an abnormal closure was raised in poll, and nothing else triggered a CLOSED state in
// the received and processed data then close the connection
if (pollResult != PollResult::Succeeded)
{
_rxbuf.clear();
// if we previously closed the connection (CLOSING state), then set state to CLOSED
// (code/reason were set before)
if (_readyState == ReadyState::CLOSING)
{
closeSocket();
setReadyState(ReadyState::CLOSED);
}
// if we weren't closing, then close using abnormal close code and message
else if (_readyState != ReadyState::CLOSED)
{
closeSocketAndSwitchToClosedState(WebSocketCloseConstants::kAbnormalCloseCode,
WebSocketCloseConstants::kAbnormalCloseMessage,
0,
false);
}
}
}
std::string WebSocketTransport::getMergedChunks() const
{
size_t length = 0;
for (auto&& chunk : _chunks)
{
length += chunk.size();
}
std::string msg;
msg.reserve(length);
for (auto&& chunk : _chunks)
{
msg += chunk;
}
return msg;
}
void WebSocketTransport::emitMessage(MessageKind messageKind,
const std::string& message,
bool compressedMessage,
const OnMessageCallback& onMessageCallback)
{
size_t wireSize = message.size();
// When the RSV1 bit is 1 it means the message is compressed
if (compressedMessage && messageKind != MessageKind::FRAGMENT)
{
bool success = _perMessageDeflate->decompress(message, _decompressedMessage);
if (messageKind == MessageKind::MSG_TEXT && !validateUtf8(_decompressedMessage))
{
close(WebSocketCloseConstants::kInvalidFramePayloadData,
WebSocketCloseConstants::kInvalidFramePayloadDataMessage);
}
else
{
onMessageCallback(_decompressedMessage, wireSize, !success, messageKind);
}
}
else
{
if (messageKind == MessageKind::MSG_TEXT && !validateUtf8(message))
{
close(WebSocketCloseConstants::kInvalidFramePayloadData,
WebSocketCloseConstants::kInvalidFramePayloadDataMessage);
}
else
{
onMessageCallback(message, wireSize, false, messageKind);
}
}
}
unsigned WebSocketTransport::getRandomUnsigned()
{
auto now = std::chrono::system_clock::now();
auto seconds =
std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
return static_cast<unsigned>(seconds);
}
WebSocketSendInfo WebSocketTransport::sendData(wsheader_type::opcode_type type,
const std::string& message,
bool compress,
const OnProgressCallback& onProgressCallback)
{
if (_readyState != ReadyState::OPEN && _readyState != ReadyState::CLOSING)
{
return WebSocketSendInfo(false);
}
size_t payloadSize = message.size();
size_t wireSize = message.size();
bool compressionError = false;
std::string::const_iterator message_begin = message.begin();
std::string::const_iterator message_end = message.end();
if (compress)
{
if (!_perMessageDeflate->compress(message, _compressedMessage))
{
bool success = false;
compressionError = true;
payloadSize = 0;
wireSize = 0;
return WebSocketSendInfo(success, compressionError, payloadSize, wireSize);
}
compressionError = false;
wireSize = _compressedMessage.size();
message_begin = _compressedMessage.begin();
message_end = _compressedMessage.end();
}
{
std::lock_guard<std::mutex> lock(_txbufMutex);
_txbuf.reserve(wireSize);
}
bool success = true;
// Common case for most message. No fragmentation required.
if (wireSize < kChunkSize)
{
success = sendFragment(type, true, message_begin, message_end, compress);
}
else
{
//
// Large messages need to be fragmented
//
// Rules:
// First message needs to specify a proper type (BINARY or TEXT)
// Intermediary and last messages need to be of type CONTINUATION
// Last message must set the fin byte.
//
auto steps = wireSize / kChunkSize;
std::string::const_iterator begin = message_begin;
std::string::const_iterator end = message_end;
for (uint64_t i = 0; i < steps; ++i)
{
bool firstStep = i == 0;
bool lastStep = (i + 1) == steps;
bool fin = lastStep;
end = begin + kChunkSize;
if (lastStep)
{
end = message_end;
}
auto opcodeType = type;
if (!firstStep)
{
opcodeType = wsheader_type::CONTINUATION;
}
// Send message
if (!sendFragment(opcodeType, fin, begin, end, compress))
{
return WebSocketSendInfo(false);
}
if (onProgressCallback && !onProgressCallback((int) i, (int) steps))
{
break;
}
begin += kChunkSize;
}
}
// Request to flush the send buffer on the background thread if it isn't empty
if (!isSendBufferEmpty())
{
wakeUpFromPoll(Socket::kSendRequest);
// FIXME: we should have a timeout when sending large messages: see #131
if (_blockingSend && !flushSendBuffer())
{
success = false;
}
}
return WebSocketSendInfo(success, compressionError, payloadSize, wireSize);
}
bool WebSocketTransport::sendFragment(wsheader_type::opcode_type type,
bool fin,
std::string::const_iterator message_begin,
std::string::const_iterator message_end,
bool compress)
{
uint64_t message_size = static_cast<uint64_t>(message_end - message_begin);
unsigned x = getRandomUnsigned();
uint8_t masking_key[4] = {};
masking_key[0] = (x >> 24);
masking_key[1] = (x >> 16) & 0xff;
masking_key[2] = (x >> 8) & 0xff;
masking_key[3] = (x) &0xff;
std::vector<uint8_t> header;
header.assign(2 + (message_size >= 126 ? 2 : 0) + (message_size >= 65536 ? 6 : 0) +
(_useMask ? 4 : 0),
0);
header[0] = type;
// The fin bit indicate that this is the last fragment. Fin is French for end.
if (fin)
{
header[0] |= 0x80;
}
// The rsv1 bit indicate that the frame is compressed
// continuation opcodes should not set it. Autobahn 12.2.10 and others 12.X
if (compress && type != wsheader_type::CONTINUATION)
{
header[0] |= 0x40;
}
if (message_size < 126)
{
header[1] = (message_size & 0xff) | (_useMask ? 0x80 : 0);
if (_useMask)
{
header[2] = masking_key[0];
header[3] = masking_key[1];
header[4] = masking_key[2];
header[5] = masking_key[3];
}
}
else if (message_size < 65536)
{
header[1] = 126 | (_useMask ? 0x80 : 0);
header[2] = (message_size >> 8) & 0xff;
header[3] = (message_size >> 0) & 0xff;
if (_useMask)
{
header[4] = masking_key[0];
header[5] = masking_key[1];
header[6] = masking_key[2];
header[7] = masking_key[3];
}
}
else
{ // TODO: run coverage testing here
header[1] = 127 | (_useMask ? 0x80 : 0);
header[2] = (message_size >> 56) & 0xff;
header[3] = (message_size >> 48) & 0xff;
header[4] = (message_size >> 40) & 0xff;
header[5] = (message_size >> 32) & 0xff;
header[6] = (message_size >> 24) & 0xff;
header[7] = (message_size >> 16) & 0xff;
header[8] = (message_size >> 8) & 0xff;
header[9] = (message_size >> 0) & 0xff;
if (_useMask)
{
header[10] = masking_key[0];
header[11] = masking_key[1];
header[12] = masking_key[2];
header[13] = masking_key[3];
}
}
// _txbuf will keep growing until it can be transmitted over the socket:
appendToSendBuffer(header, message_begin, message_end, message_size, masking_key);
// Now actually send this data
return sendOnSocket();
}
WebSocketSendInfo WebSocketTransport::sendPing(const std::string& message)
{
bool compress = false;
WebSocketSendInfo info = sendData(wsheader_type::PING, message, compress);
if (info.success)
{
std::lock_guard<std::mutex> lck(_lastSendPingTimePointMutex);
_lastSendPingTimePoint = std::chrono::steady_clock::now();
}
return info;
}
WebSocketSendInfo WebSocketTransport::sendBinary(const std::string& message,
const OnProgressCallback& onProgressCallback)
{
return sendData(
wsheader_type::BINARY_FRAME, message, _enablePerMessageDeflate, onProgressCallback);
}
WebSocketSendInfo WebSocketTransport::sendText(const std::string& message,
const OnProgressCallback& onProgressCallback)
{
return sendData(
wsheader_type::TEXT_FRAME, message, _enablePerMessageDeflate, onProgressCallback);
}
bool WebSocketTransport::sendOnSocket()
{
std::lock_guard<std::mutex> lock(_txbufMutex);
while (_txbuf.size())
{
ssize_t ret = 0;
{
std::lock_guard<std::mutex> lock(_socketMutex);
ret = _socket->send((char*) &_txbuf[0], _txbuf.size());
}
if (ret < 0 && Socket::isWaitNeeded())
{
break;
}
else if (ret <= 0)
{
closeSocket();
setReadyState(ReadyState::CLOSED);
return false;
}
else
{
_txbuf.erase(_txbuf.begin(), _txbuf.begin() + ret);
}
}
return true;
}
bool WebSocketTransport::receiveFromSocket()
{
while (true)
{
ssize_t ret = _socket->recv((char*) &_readbuf[0], _readbuf.size());
if (ret < 0 && Socket::isWaitNeeded())
{
break;
}
else if (ret <= 0)
{
// if there are received data pending to be processed, then delay the abnormal
// closure to after dispatch (other close code/reason could be read from the
// buffer)
closeSocket();
return false;
}
else
{
_rxbuf.insert(_rxbuf.end(), _readbuf.begin(), _readbuf.begin() + ret);
}
}
return true;
}
void WebSocketTransport::sendCloseFrame(uint16_t code, const std::string& reason)
{
bool compress = false;
// if a status is set/was read
if (code != WebSocketCloseConstants::kNoStatusCodeErrorCode)
{
// See list of close events here:
// https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
std::string closure {(char) (code >> 8), (char) (code & 0xff)};
// copy reason after code
closure.append(reason);
sendData(wsheader_type::CLOSE, closure, compress);
}
else
{
// no close code/reason set
sendData(wsheader_type::CLOSE, "", compress);
}
}
void WebSocketTransport::closeSocket()
{
std::lock_guard<std::mutex> lock(_socketMutex);
_socket->close();
}
bool WebSocketTransport::wakeUpFromPoll(uint64_t wakeUpCode)
{
std::lock_guard<std::mutex> lock(_socketMutex);
return _socket->wakeUpFromPoll(wakeUpCode);
}
void WebSocketTransport::closeSocketAndSwitchToClosedState(uint16_t code,
const std::string& reason,
size_t closeWireSize,
bool remote)
{
closeSocket();
{
std::lock_guard<std::mutex> lock(_closeDataMutex);
_closeCode = code;
_closeReason = reason;
_closeWireSize = closeWireSize;
_closeRemote = remote;
}
setReadyState(ReadyState::CLOSED);
_requestInitCancellation = false;
}
void WebSocketTransport::close(uint16_t code,
const std::string& reason,
size_t closeWireSize,
bool remote)
{
_requestInitCancellation = true;
if (_readyState == ReadyState::CLOSING || _readyState == ReadyState::CLOSED) return;
if (closeWireSize == 0)
{
closeWireSize = reason.size();
}
{
std::lock_guard<std::mutex> lock(_closeDataMutex);
_closeCode = code;
_closeReason = reason;
_closeWireSize = closeWireSize;
_closeRemote = remote;
}
{
std::lock_guard<std::mutex> lock(_closingTimePointMutex);
_closingTimePoint = std::chrono::steady_clock::now();
}
setReadyState(ReadyState::CLOSING);
sendCloseFrame(code, reason);
// wake up the poll, but do not close yet
wakeUpFromPoll(Socket::kSendRequest);
}
size_t WebSocketTransport::bufferedAmount() const
{
std::lock_guard<std::mutex> lock(_txbufMutex);
return _txbuf.size();
}
bool WebSocketTransport::flushSendBuffer()
{
while (!isSendBufferEmpty() && !_requestInitCancellation)
{
// Wait with a 10ms timeout until the socket is ready to write.
// This way we are not busy looping
PollResultType result = _socket->isReadyToWrite(10);
if (result == PollResultType::Error)
{
closeSocket();
setReadyState(ReadyState::CLOSED);
return false;
}
else if (result == PollResultType::ReadyForWrite)
{
if (!sendOnSocket())
{
return false;
}
}
}
return true;
}
} // namespace ix
|
#include <task.hpp>
namespace core {
task_t::task_t( timestamp_t timestamp, address_t address ) noexcept
: m_timestamp( timestamp )
, m_address( address )
{
}
task_t::task_t( datagram_t && datagram ) noexcept( false )
: m_address( datagram.get_address() )
{
const auto & bytes = datagram.get_bytes();
if( k_msec_count_size != bytes.size() )
{
throw std::invalid_argument(
"broken datagram size, expected "
+ std::to_string( k_msec_count_size )
+ ", got " + std::to_string( bytes.size() )
);
}
using namespace std::chrono;
msec_count_t msec_since_epoch{ 0 };
std::memcpy( &msec_since_epoch, &bytes.front(), k_msec_count_size );
msec_since_epoch = be64toh( msec_since_epoch );
m_timestamp = timestamp_t{ timestamp_t::value_type{ milliseconds { msec_since_epoch } } };
}
std::ostream & operator <<( std::ostream & os, const task_t & task ) noexcept
{
os << "[" << task.m_timestamp << ", " << task.m_address << "]";
return os;
}
datagram_t task_t::to_datagram() const
{
bytes_t bytes;
bytes.resize( k_msec_count_size );
if( !m_timestamp )
{
throw std::invalid_argument( "timestamp is empty" );
}
using namespace std::chrono;
const auto since_epoch = time_point_cast< milliseconds >( *m_timestamp ).time_since_epoch();
auto msec_since_epoch = duration_cast< milliseconds >( since_epoch ).count();
msec_since_epoch = htobe64( msec_since_epoch );
std::memcpy( &bytes.front(), &msec_since_epoch, k_msec_count_size );
return { m_address, std::move( bytes ) };
}
}
|
// RUN: %clang_cc1 -no-opaque-pointers %s -triple i386-unknown-unknown -emit-llvm -o - | FileCheck %s
struct A {
virtual int operator-();
};
void f(A a, A *ap) {
// CHECK: call noundef i32 @_ZN1AngEv(%struct.A* {{[^,]*}} %a)
-a;
// CHECK: call noundef i32 %
-*ap;
}
|
#include "RfgUtil.h"
#include "Log.h"
#include "common/filesystem/Path.h"
#include "application/Config.h"
namespace RfgUtil
{
string CpuFilenameToGpuFilename(std::string_view cpuFilename)
{
//Todo: Support more extensions
string extension = Path::GetExtension(cpuFilename);
string filenameNoExt = Path::GetFileNameNoExtension(cpuFilename);
if (extension == ".cpeg_pc")
return filenameNoExt + ".gpeg_pc";
else if (extension == ".cvbm_pc")
return filenameNoExt + ".gvbm_pc";
else if (extension == ".csmesh_pc")
return filenameNoExt + ".gsmesh_pc";
else if (extension == ".ccmesh_pc")
return filenameNoExt + ".gcmesh_pc";
else if (extension == ".cchk_pc")
return filenameNoExt + ".gchk_pc";
else
{
LOG_ERROR("Unknown rfg file extension \"{}\"", extension);
return string(cpuFilename);
}
}
bool ValidateDataPath(std::string_view dataPath, std::string_view missingFileName, bool logResult)
{
//List of expected vpp_pc files
std::vector<string> expectedFiles =
{
"activities.vpp_pc",
"anims.vpp_pc",
"chunks.vpp_pc",
"cloth_sim.vpp_pc",
"decals.vpp_pc",
"dlc01_l0.vpp_pc",
"dlc01_l1.vpp_pc",
"dlc01_precache.vpp_pc",
"dlcp01_activities.vpp_pc",
"dlcp01_anims.vpp_pc",
"dlcp01_cloth_sim.vpp_pc",
"dlcp01_effects.vpp_pc",
"dlcp01_humans.vpp_pc",
"dlcp01_interface.vpp_pc",
"dlcp01_items.vpp_pc",
"dlcp01_misc.vpp_pc",
"dlcp01_missions.vpp_pc",
"dlcp01_personas_en_us.vpp_pc",
"dlcp01_vehicles_r.vpp_pc",
"dlcp01_voices_en_us.vpp_pc",
"dlcp02_interface.vpp_pc",
"dlcp02_misc.vpp_pc",
"dlcp03_interface.vpp_pc",
"dlcp03_misc.vpp_pc",
"effects.vpp_pc",
"effects_mp.vpp_pc",
"humans.vpp_pc",
"interface.vpp_pc",
"items.vpp_pc",
"items_mp.vpp_pc",
"misc.vpp_pc",
"missions.vpp_pc",
"mp_common.vpp_pc",
"mp_cornered.vpp_pc",
"mp_crashsite.vpp_pc",
"mp_crescent.vpp_pc",
"mp_crevice.vpp_pc",
"mp_deadzone.vpp_pc",
"mp_downfall.vpp_pc",
"mp_excavation.vpp_pc",
"mp_fallfactor.vpp_pc",
"mp_framework.vpp_pc",
"mp_garrison.vpp_pc",
"mp_gauntlet.vpp_pc",
"mp_overpass.vpp_pc",
"mp_pcx_assembly.vpp_pc",
"mp_pcx_crossover.vpp_pc",
"mp_pinnacle.vpp_pc",
"mp_quarantine.vpp_pc",
"mp_radial.vpp_pc",
"mp_rift.vpp_pc",
"mp_sandpit.vpp_pc",
"mp_settlement.vpp_pc",
"mp_warlords.vpp_pc",
"mp_wasteland.vpp_pc",
"mp_wreckage.vpp_pc",
"mpdlc_broadside.vpp_pc",
"mpdlc_division.vpp_pc",
"mpdlc_islands.vpp_pc",
"mpdlc_landbridge.vpp_pc",
"mpdlc_minibase.vpp_pc",
"mpdlc_overhang.vpp_pc",
"mpdlc_puncture.vpp_pc",
"mpdlc_ruins.vpp_pc",
"personas_de_de.vpp_pc",
"personas_en_us.vpp_pc",
"personas_es_es.vpp_pc",
"personas_fr_fr.vpp_pc",
"personas_it_it.vpp_pc",
"personas_ru_ru.vpp_pc",
"skybox.vpp_pc",
"sounds_r.vpp_pc",
"steam.vpp_pc",
//"table.vpp_pc", //Not checked since it's required to rename or delete this for misc.vpp_pc mods to work
"terr01_l0.vpp_pc",
"terr01_l1.vpp_pc",
"terr01_precache.vpp_pc",
"vehicles_r.vpp_pc",
"voices_de_de.vpp_pc",
"voices_en_us.vpp_pc",
"voices_es_es.vpp_pc",
"voices_fr_fr.vpp_pc",
"voices_it_it.vpp_pc",
"voices_ru_ru.vpp_pc",
"wc1.vpp_pc",
"wc10.vpp_pc",
"wc2.vpp_pc",
"wc3.vpp_pc",
"wc4.vpp_pc",
"wc5.vpp_pc",
"wc6.vpp_pc",
"wc7.vpp_pc",
"wc8.vpp_pc",
"wc9.vpp_pc",
"wcdlc1.vpp_pc",
"wcdlc2.vpp_pc",
"wcdlc3.vpp_pc",
"wcdlc4.vpp_pc",
"wcdlc5.vpp_pc",
"wcdlc6.vpp_pc",
"wcdlc7.vpp_pc",
"wcdlc8.vpp_pc",
"wcdlc9.vpp_pc",
"zonescript_dlc01.vpp_pc",
"zonescript_terr01.vpp_pc"
};
//Check if all expected files are in the data folder. Return false and set missing file string
for (auto& filename : expectedFiles)
{
if (!std::filesystem::exists(fmt::format("{}\\{}", dataPath, filename)))
{
if(logResult)
Log->warn("Current data path is invalid. Data path: \"{}\", first missing vpp: \"{}\"", dataPath, filename);
missingFileName = filename;
return false;
}
}
if(logResult)
Log->info("Current data path is valid. Data path: \"{}\"", dataPath);
return true;
}
//Todo: Add non re-mars-tered paths
//Non exhaustive list of common/expected install locations
const std::vector<string> CommonInstallLocations =
{
"A:/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"A:/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"A:/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"A:/Program Files (x86)/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"A:/Program Files (x86)/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"A:/Program Files (x86)/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"A:/Program Files/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"A:/Program Files/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"A:/Program Files/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"B:/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"B:/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"B:/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"B:/Program Files (x86)/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"B:/Program Files (x86)/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"B:/Program Files (x86)/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"B:/Program Files/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"B:/Program Files/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"B:/Program Files/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"C:/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"C:/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"C:/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"C:/Program Files (x86)/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"C:/Program Files (x86)/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"C:/Program Files (x86)/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"C:/Program Files/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"C:/Program Files/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"C:/Program Files/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"D:/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"D:/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"D:/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"D:/Program Files (x86)/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"D:/Program Files (x86)/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"D:/Program Files (x86)/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"D:/Program Files/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"D:/Program Files/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"D:/Program Files/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"E:/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"E:/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"E:/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"E:/Program Files (x86)/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"E:/Program Files (x86)/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"E:/Program Files (x86)/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"E:/Program Files/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"E:/Program Files/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"E:/Program Files/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"F:/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"F:/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"F:/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"F:/Program Files (x86)/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"F:/Program Files (x86)/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"F:/Program Files (x86)/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"F:/Program Files/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"F:/Program Files/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"F:/Program Files/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"G:/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"G:/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"G:/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"G:/Program Files (x86)/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"G:/Program Files (x86)/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"G:/Program Files (x86)/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
"G:/Program Files/Steam/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"G:/Program Files/SteamLibrary/steamapps/common/Red Faction Guerrilla Re-MARS-tered/data",
"G:/Program Files/GOG/Games/Red Faction Guerrilla Re-MARS-tered/data",
};
//Attempt to auto locate the data path from a list of common install locations. Will set the "Data path" config var if it's found.
bool AutoDetectDataPath(Config* config)
{
//Get data path config var
config->EnsureVariableExists("Data path", ConfigType::String);
auto dataPathVar = config->GetVariable("Data path");
dataPathVar->IsFolderPath = true;
dataPathVar->IsFilePath = false;
Log->info("Data path \"{}\" is invalid. Attempting to auto detect RFG install location.", std::get<string>(dataPathVar->Value));
//Loop through all common install locations
for (auto& path : CommonInstallLocations)
{
//If install location has all expected files set the data path to that
string missingFileName;
if (RfgUtil::ValidateDataPath(path, missingFileName, false))
{
Log->info("Auto detected RFG install location at \"{}\"", path);
dataPathVar->Value = path;
config->Save();
return true;
}
}
Log->warn("Failed to auto detect RFG install location.");
return false;
}
}
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sync/internal_api/public/test/sync_manager_factory_for_profile_sync_test.h"
#include "sync/internal_api/test/sync_manager_for_profile_sync_test.h"
namespace syncer {
SyncManagerFactoryForProfileSyncTest::SyncManagerFactoryForProfileSyncTest(
base::Closure init_callback)
: SyncManagerFactory(SyncManagerFactory::NORMAL),
init_callback_(init_callback) {
}
SyncManagerFactoryForProfileSyncTest::~SyncManagerFactoryForProfileSyncTest() {}
scoped_ptr<syncer::SyncManager>
SyncManagerFactoryForProfileSyncTest::CreateSyncManager(
const std::string& name) {
return scoped_ptr<syncer::SyncManager>(
new SyncManagerForProfileSyncTest(
name,
init_callback_));
}
} // namespace syncer
|
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
* written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************************************************************/
#include <gtest/gtest.h>
#include "ModelFixture.hpp"
#include "../CoilHeatingWaterBaseboard.hpp"
#include "../CoilHeatingWaterBaseboard_Impl.hpp"
#include "../ZoneHVACBaseboardConvectiveWater.hpp"
#include "../ZoneHVACBaseboardConvectiveWater_Impl.hpp"
#include "../ScheduleConstant.hpp"
#include "../ScheduleConstant_Impl.hpp"
#include "../ThermalZone.hpp"
#include "../ThermalZone_Impl.hpp"
using namespace openstudio;
using namespace openstudio::model;
TEST_F(ModelFixture,ZoneHVACBaseboardConvectiveWater_Test) {
Model model;
ScheduleConstant sched(model);
sched.setValue(1.0); // Always on
CoilHeatingWaterBaseboard HCBaseboard(model);
// test constructor
ZoneHVACBaseboardConvectiveWater zoneHVACBBConv(model,sched,HCBaseboard);
// test set and get availibility schedule
ScheduleConstant sched1(model);
sched1.setValue(1.0);
EXPECT_TRUE(zoneHVACBBConv.setAvailabilitySchedule(sched1));
EXPECT_EQ(zoneHVACBBConv.availabilitySchedule(),sched1);
// test if ZoneHVACBaseboardConvectiveWater has a hot water coil
CoilHeatingWaterBaseboard HCBaseboard1(model);
zoneHVACBBConv.setHeatingCoil(HCBaseboard1);
EXPECT_EQ(zoneHVACBBConv.heatingCoil(),HCBaseboard1);
// test add thermal zone
// check if it has a thermal zone, should return no thermal zone
EXPECT_FALSE(zoneHVACBBConv.thermalZone());
// add to a thermal zone, check to see that it should have a thermal zone
ThermalZone thermalZone1(model);
zoneHVACBBConv.addToThermalZone(thermalZone1);
boost::optional<ThermalZone> test_ThermalZone = zoneHVACBBConv.thermalZone();
EXPECT_EQ(*test_ThermalZone,thermalZone1);
//test remove a thermal zone
//check to see it should have a thermal zone
EXPECT_TRUE(zoneHVACBBConv.thermalZone());
// remove the thermal zone
zoneHVACBBConv.removeFromThermalZone();
// check to see if it doesn't have a thermal zone
EXPECT_FALSE(zoneHVACBBConv.thermalZone());
}
|
#include <gtest/gtest.h>
#include <boost/math/distributions.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <stan/math/prim/mat.hpp>
#include <test/unit/math/prim/mat/prob/vector_rng_test_helper.hpp>
#include <limits>
#include <vector>
class InvChiSquareTestRig : public VectorRealRNGTestRig {
public:
InvChiSquareTestRig()
: VectorRealRNGTestRig(10000, 10, {0.1, 1.0, 2.5, 4.0}, {1, 2, 3, 4},
{-2.7, -1.5, -0.5, 0.0}, {-3, -2, -1, 0}) {}
template <typename T1, typename T2, typename T3, typename T_rng>
auto generate_samples(const T1& nu, const T2&, const T3&, T_rng& rng) const {
return stan::math::inv_chi_square_rng(nu, rng);
}
std::vector<double> generate_quantiles(double nu, double, double) const {
std::vector<double> quantiles;
double K = stan::math::round(2 * std::pow(N_, 0.4));
boost::math::inverse_chi_squared_distribution<> dist(nu);
for (int i = 1; i < K; ++i) {
double frac = i / K;
quantiles.push_back(quantile(dist, frac));
}
quantiles.push_back(std::numeric_limits<double>::max());
return quantiles;
}
};
TEST(ProbDistributionsInvChiSquare, errorCheck) {
check_dist_throws_all_types(InvChiSquareTestRig());
}
TEST(ProbDistributionsInvChiSquare, distributionTest) {
check_quantiles_real(InvChiSquareTestRig());
}
|
/* Copyright (c) 2017, United States Government, as represented by the
* Administrator of the National Aeronautics and Space Administration.
*
* All rights reserved.
*
* The Astrobee platform is 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 <mapper/mapper_nodelet.h>
#include <string>
#include <vector>
#include <algorithm>
namespace mapper {
// Thread for fading memory of the octomap
void MapperNodelet::FadeTask(ros::TimerEvent const& event) {
mutexes_.octomap.lock();
if (globals_.octomap.memory_time_ > 0)
globals_.octomap.FadeMemory(fading_memory_update_rate_);
mutexes_.octomap.unlock();
}
// Thread for constantly updating the tfTree values
void MapperNodelet::HazTfTask(ros::TimerEvent const& event) {
mutexes_.tf.lock();
try {
globals_.tf_cam2world = buffer_.lookupTransform(FRAME_NAME_WORLD,
GetTransform(FRAME_NAME_HAZ_CAM), ros::Time(0));
} catch (tf2::TransformException &ex) {}
mutexes_.tf.unlock();
}
// Thread for constantly updating the tfTree values
void MapperNodelet::PerchTfTask(ros::TimerEvent const& event) {
mutexes_.tf.lock();
try {
globals_.tf_perch2world = buffer_.lookupTransform(FRAME_NAME_WORLD,
GetTransform(FRAME_NAME_PERCH_CAM), ros::Time(0));
} catch (tf2::TransformException &ex) {}
mutexes_.tf.unlock();
}
// Thread for updating the tfTree values
void MapperNodelet::BodyTfTask(ros::TimerEvent const& event) {
mutexes_.tf.lock();
try {
globals_.tf_body2world = buffer_.lookupTransform(FRAME_NAME_WORLD,
GetTransform(FRAME_NAME_BODY), ros::Time(0));
} catch (tf2::TransformException &ex) {}
mutexes_.tf.unlock();
}
// Sentinel
void MapperNodelet::CollisionCheckTask() {
ROS_DEBUG("collisionCheck Thread started!");
// visualization markers
visualization_msgs::MarkerArray traj_markers, samples_markers;
visualization_msgs::MarkerArray compressed_samples_markers, collision_markers;
// pcl variables
int cloudsize;
std::mutex mtx;
std::unique_lock<std::mutex> lck(mtx);
while (!killed_) {
// Wait until there is a new trajectory or a new update on the map
semaphores_.collision_check.wait(lck);
if (killed_)
return;
// Get time for when this task started
ros::Time time_now = ros::Time::now();
// Copy trajectory into local point cloud
pcl::PointCloud<pcl::PointXYZ> point_cloud_traj;
std::vector<octomap::point3d> colliding_nodes;
traj_markers.markers.clear();
collision_markers.markers.clear();
samples_markers.markers.clear();
compressed_samples_markers.markers.clear();
mutexes_.sampled_traj.lock();
point_cloud_traj = globals_.sampled_traj.point_cloud_traj_;
std::vector<double> time = globals_.sampled_traj.time_;
// Send visualization markers
globals_.sampled_traj.TrajVisMarkers(&traj_markers);
globals_.sampled_traj.SamplesVisMarkers(&samples_markers);
globals_.sampled_traj.CompressedVisMarkers(&compressed_samples_markers);
path_marker_pub_.publish(traj_markers);
path_marker_pub_.publish(samples_markers);
path_marker_pub_.publish(compressed_samples_markers);
mutexes_.sampled_traj.unlock();
// Stop execution if there are no points in the trajectory structure
cloudsize = point_cloud_traj.size();
if (cloudsize <= 0) {
visualization_functions::DrawCollidingNodes(colliding_nodes, "world", 0.0, &collision_markers);
path_marker_pub_.publish(traj_markers);
path_marker_pub_.publish(collision_markers);
continue;
}
// Stop execution if the current time is beyond the final time of the trajectory
if (time_now.toSec() > time.back()) {
mutexes_.sampled_traj.lock();
globals_.sampled_traj.ClearObject();
globals_.sampled_traj.TrajVisMarkers(&traj_markers);
mutexes_.sampled_traj.unlock();
visualization_functions::DrawCollidingNodes(colliding_nodes, "world", 0.0, &collision_markers);
path_marker_pub_.publish(traj_markers);
path_marker_pub_.publish(collision_markers);
continue;
}
// Check if trajectory collides with points in the point-cloud
mutexes_.octomap.lock();
double res = globals_.octomap.tree_inflated_.getResolution();
globals_.octomap.FindCollidingNodesInflated(point_cloud_traj, &colliding_nodes);
mutexes_.octomap.unlock();
if (colliding_nodes.size() > 0) {
// Sort collision time (use kdtree for nearest neighbor)
std::vector<geometry_msgs::PointStamped> sorted_collisions;
mutexes_.sampled_traj.lock();
globals_.sampled_traj.SortCollisions(colliding_nodes, &sorted_collisions);
mutexes_.sampled_traj.unlock();
double collision_time = (sorted_collisions[0].header.stamp - ros::Time::now()).toSec();
// uint lastCollisionIdx = sorted_collisions.back().header.seq;
if (collision_time > 0) {
ROS_WARN("Imminent collision within %.3f seconds!", collision_time);
// Publish the message
ff_msgs::Hazard info;
info.header.stamp = ros::Time::now();
info.header.frame_id = GetPlatform();
info.type = ff_msgs::Hazard::TYPE_OBSTACLE;
info.hazard = sorted_collisions[0];
hazard_pub_.publish(info);
// Unlock resources
mutexes_.sampled_traj.lock();
globals_.sampled_traj.ClearObject();
mutexes_.sampled_traj.unlock();
}
}
// Draw colliding markers (delete if none)
visualization_functions::DrawCollidingNodes(colliding_nodes, "world", 1.01*res, &collision_markers);
path_marker_pub_.publish(traj_markers);
path_marker_pub_.publish(collision_markers);
ros::Duration solver_time = ros::Time::now() - time_now;
}
ROS_DEBUG("Exiting collisionCheck Thread...");
}
void MapperNodelet::OctomappingTask() {
ROS_DEBUG("OctomappingTask Thread started!");
geometry_msgs::TransformStamped tf_cam2world;
pcl::PointCloud< pcl::PointXYZ > pcl_world;
std::mutex mtx;
std::unique_lock<std::mutex> lck(mtx);
while (!killed_) {
// Take care of the special case where the notify_one was sent during the
// processing of the previous point cloud. The signal that this happened
// is a non-empty point cloud queue. In this case we pass straight through.
if (globals_.pcl_queue.empty())
semaphores_.pcl.wait(lck);
if (killed_)
return;
mutexes_.point_cloud.lock();
// Get time for when this task started
const ros::Time t0 = ros::Time::now();
// Get Point Cloud
pcl::PointCloud<pcl::PointXYZ> point_cloud =
globals_.pcl_queue.front().cloud;
const geometry_msgs::TransformStamped tf_cam2world =
globals_.pcl_queue.front().tf_cam2world;
// Remove data from queue
globals_.pcl_queue.pop();
mutexes_.point_cloud.unlock();
// Check if a tf message has been received already. If not, return
if (tf_cam2world.header.stamp.toSec() == 0)
continue;
// Transform pcl into world frame
Eigen::Affine3d transform = Eigen::Affine3d::Identity();
transform.translation() << tf_cam2world.transform.translation.x,
tf_cam2world.transform.translation.y,
tf_cam2world.transform.translation.z;
transform.rotate(Eigen::Quaterniond(
tf_cam2world.transform.rotation.w,
tf_cam2world.transform.rotation.x,
tf_cam2world.transform.rotation.y,
tf_cam2world.transform.rotation.z));
pcl::transformPointCloud(point_cloud, pcl_world, transform);
// Save into octomap
algebra_3d::FrustumPlanes world_frustum;
mutexes_.octomap.lock();
globals_.octomap.cam_frustum_.TransformFrustum(transform, &world_frustum);
globals_.octomap.PclToRayOctomap(pcl_world, tf_cam2world, world_frustum);
globals_.octomap.tree_.prune(); // prune the tree before visualizing
globals_.octomap.tree_inflated_.prune();
// globals_.octomap.tree.writeBinary("simple_tree.bt");
mutexes_.octomap.unlock();
// Publish visualization markers iff at least one node is subscribed to it
bool pub_obstacles, pub_free, pub_obstacles_inflated, pub_free_inflated;
pub_obstacles = (obstacle_marker_pub_.getNumSubscribers() > 0) || (obstacle_cloud_pub_.getNumSubscribers() > 0);
pub_free = (free_space_marker_pub_.getNumSubscribers() > 0) || (free_space_cloud_pub_.getNumSubscribers() > 0);
pub_obstacles_inflated = (inflated_obstacle_marker_pub_.getNumSubscribers() > 0)
|| (inflated_obstacle_cloud_pub_.getNumSubscribers() > 0);
pub_free_inflated = (inflated_free_space_marker_pub_.getNumSubscribers() > 0)
|| (inflated_free_space_cloud_pub_.getNumSubscribers() > 0);
if (pub_obstacles || pub_free) {
visualization_msgs::MarkerArray obstacle_markers, free_markers;
sensor_msgs::PointCloud2 obstacle_cloud, free_cloud;
mutexes_.octomap.lock();
globals_.octomap.TreeVisMarkers(&obstacle_markers, &free_markers,
&obstacle_cloud, &free_cloud);
mutexes_.octomap.unlock();
if (pub_obstacles) {
obstacle_marker_pub_.publish(obstacle_markers);
obstacle_cloud_pub_.publish(obstacle_cloud);
}
if (pub_free) {
free_space_marker_pub_.publish(free_markers);
free_space_cloud_pub_.publish(free_cloud);
}
}
if (pub_obstacles_inflated || pub_free_inflated) {
visualization_msgs::MarkerArray inflated_obstacle_markers, inflated_free_markers;
sensor_msgs::PointCloud2 inflated_obstacle_cloud, inflated_free_cloud;
mutexes_.octomap.lock();
globals_.octomap.InflatedVisMarkers(&inflated_obstacle_markers, &inflated_free_markers,
&inflated_obstacle_cloud, &inflated_free_cloud);
mutexes_.octomap.unlock();
if (pub_obstacles_inflated) {
inflated_obstacle_marker_pub_.publish(inflated_obstacle_markers);
inflated_obstacle_cloud_pub_.publish(inflated_obstacle_cloud);
}
if (pub_free_inflated) {
inflated_free_space_marker_pub_.publish(inflated_free_markers);
inflated_free_space_cloud_pub_.publish(inflated_free_cloud);
}
}
if (cam_frustum_pub_.getNumSubscribers() > 0) {
visualization_msgs::Marker frustum_markers;
mutexes_.octomap.lock();
globals_.octomap.cam_frustum_.VisualizeFrustum(point_cloud.header.frame_id, &frustum_markers);
mutexes_.octomap.unlock();
cam_frustum_pub_.publish(frustum_markers);
}
// Notify the collision checker to check for collision
semaphores_.collision_check.notify_one();
ros::Duration map_time = ros::Time::now() - t0;
}
ROS_DEBUG("Exiting OctomappingTask Thread...");
}
} // namespace mapper
|
#pragma once
#include <ork/kernel/string/string.h>
////////////////////////////////////////////////////////////////////////////////
namespace ork::reflect::serdes {
////////////////////////////////////////////////////////////////////////////////
using ulong_t = unsigned long int;
using uint_t = unsigned int;
template <typename T> //
inline void decode_key(std::string keystr, T& key_out) {
OrkAssert(false);
}
template <> //
inline void decode_key(std::string keystr, int& key_out) {
key_out = atoi(keystr.c_str());
}
template <> //
inline void decode_key(std::string keystr, std::string& key_out) {
key_out = keystr;
}
template <typename T> //
inline void decode_value(var_t val_inp, T& val_out) {
val_out = val_inp.get<T>();
}
template <> //
inline void decode_value(var_t val_inp, int& val_out) {
val_out = int(val_inp.get<double>());
}
template <> //
inline void decode_value(var_t val_inp, uint_t& val_out) {
val_out = uint_t(val_inp.get<double>());
}
template <> //
inline void decode_value(var_t val_inp, ulong_t& val_out) {
val_out = ulong_t(val_inp.get<double>());
}
template <> //
inline void decode_value(var_t val_inp, float& val_out) {
val_out = float(val_inp.get<double>());
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
template <typename T> //
inline void encode_key(std::string& keystr_out, const T& key_inp) {
OrkAssert(false);
}
template <> //
inline void encode_key(std::string& keystr_out, const int& key_inp) {
keystr_out = FormatString("%d", key_inp);
}
template <> //
inline void encode_key(std::string& keystr_out, const std::string& key_inp) {
keystr_out = key_inp;
}
////////////////////////////////////////////////////////////////////////////////
} // namespace ork::reflect::serdes
|
/*=========================================================================
Program: Visualization Toolkit
Module: TestTextBoundingBox.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <iostream>
#include <vtkVersion.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkNew.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkTextRenderer.h>
#include <vtkPolyData.h>
#include <vtkSphereSource.h>
#include <vtkTextActor.h>
#include <vtkTextProperty.h>
int TestTextBoundingBox(int, char *[])
{
// Create a renderer
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground ( 1, 1, 1 ); // Set background color to white
// Create a render window
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer ( renderer );
// Create an interactor
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow ( renderWindow );
const char* first = "no descenders";
// Setup the text and add it to the renderer
vtkSmartPointer<vtkTextActor> textActor =
vtkSmartPointer<vtkTextActor>::New();
textActor->SetInput (first);
textActor->GetTextProperty()->SetFontSize ( 24 );
textActor->GetTextProperty()->SetColor ( 1.0, 0.0, 0.0 );
renderer->AddActor2D ( textActor );
// get the bounding box
double bbox[4];
textActor->GetBoundingBox(renderer, bbox);
// get the bounding box a different way
vtkNew<vtkTextRenderer> tren;
int tbox[4];
tren->GetBoundingBox(textActor->GetTextProperty(),
std::string(first), tbox, renderWindow->GetDPI());
// get the bounding box for a string with descenders
// it should have the same height
const char* second = "a couple of good descenders";
int tbox2[4];
tren->GetBoundingBox(textActor->GetTextProperty(),
std::string(second), tbox2, renderWindow->GetDPI());
if (tbox[2] != tbox2[2] || tbox[3] != tbox2[3])
{
std::cout << "vtkTextRenderer height (" << first << "):\n"
<< tbox[2] << ", " << tbox[3] << std::endl;
std::cout << "vtkTextRenderer height (" << second << "):\n"
<< tbox2[2] << ", " << tbox2[3] << std::endl;
return EXIT_FAILURE;
}
if (bbox[0] == tbox[0] && bbox[1] == tbox[1] &&
bbox[2] == tbox[2] && bbox[3] == tbox[3])
return EXIT_SUCCESS;
else
{
std::cout << "vtkTextActor GetBoundingBox:\n"
<< bbox[0] << ", " << bbox[1] << ", "
<< bbox[2] << ", " << bbox[3] << std::endl;
std::cout << "vtkTextRenderer GetBoundingBox:\n"
<< tbox[0] << ", " << tbox[1] << ", "
<< tbox[2] << ", " << tbox[3] << std::endl;
return EXIT_FAILURE;
}
}
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <miner.h>
#include <amount.h>
#include <chain.h>
#include <chainparams.h>
#include <coins.h>
#include <consensus/consensus.h>
#include <consensus/tx_verify.h>
#include <consensus/merkle.h>
#include <consensus/validation.h>
#include <hash.h>
#include <net.h>
#include <policy/feerate.h>
#include <policy/policy.h>
#include <pow.h>
#include <primitives/transaction.h>
#include <script/standard.h>
#include <timedata.h>
#include <util.h>
#include <utilmoneystr.h>
#include <validationinterface.h>
#include <shutdown.h>
// #include "validation.h"
// #include "txmempool.h"
// #include "init.h"
#include <algorithm>
#include <queue>
#include <utility>
#include <boost/thread.hpp>
//////////////////////////////////////////////////////////////////////////////
//
// PaycheckCashMiner
//
//
// Unconfirmed transactions in the memory pool often depend on other
// transactions in the memory pool. When we select transactions from the
// pool, we select by highest fee rate of a transaction combined with all
// its ancestors.
uint64_t nLastBlockTx = 0;
uint64_t nLastBlockWeight = 0;
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
{
int64_t nOldTime = pblock->nTime;
int64_t nNewTime = std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime());
if (nOldTime < nNewTime)
pblock->nTime = nNewTime;
// Updating time can change work required on testnet:
if (consensusParams.fPowAllowMinDifficultyBlocks)
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
return nNewTime - nOldTime;
}
BlockAssembler::Options::Options()
{
blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
}
BlockAssembler::BlockAssembler(const CChainParams& params, const Options& options) : chainparams(params)
{
blockMinFeeRate = options.blockMinFeeRate;
// Limit weight to between 4K and MAX_BLOCK_WEIGHT-4K for sanity:
nBlockMaxWeight = std::max<size_t>(4000, std::min<size_t>(MAX_BLOCK_WEIGHT - 4000, options.nBlockMaxWeight));
}
static BlockAssembler::Options DefaultOptions()
{
// Block resource limits
// If -blockmaxweight is not given, limit to DEFAULT_BLOCK_MAX_WEIGHT
BlockAssembler::Options options;
options.nBlockMaxWeight = gArgs.GetArg("-blockmaxweight", DEFAULT_BLOCK_MAX_WEIGHT);
if (gArgs.IsArgSet("-blockmintxfee")) {
CAmount n = 0;
ParseMoney(gArgs.GetArg("-blockmintxfee", ""), n);
options.blockMinFeeRate = CFeeRate(n);
} else {
options.blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
}
return options;
}
BlockAssembler::BlockAssembler(const CChainParams& params) : BlockAssembler(params, DefaultOptions()) {}
void BlockAssembler::resetBlock()
{
inBlock.clear();
// Reserve space for coinbase tx
nBlockWeight = 4000;
nBlockSigOpsCost = 400;
fIncludeWitness = false;
// These counters do not include coinbase tx
nBlockTx = 0;
nFees = 0;
}
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, bool fMineWitnessTx)
{
int64_t nTimeStart = GetTimeMicros();
resetBlock();
pblocktemplate.reset(new CBlockTemplate());
if (!pblocktemplate.get())
return nullptr;
pblock = &pblocktemplate->block; // pointer for convenience
// Add dummy coinbase tx as first transaction
pblock->vtx.emplace_back();
pblocktemplate->vTxFees.push_back(-1); // updated at end
pblocktemplate->vTxSigOpsCost.push_back(-1); // updated at end
LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = chainActive.Tip();
assert(pindexPrev != nullptr);
nHeight = pindexPrev->nHeight + 1;
pblock->nVersion = ComputeBlockVersion(pindexPrev, chainparams.GetConsensus());
// -regtest only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios
if (chainparams.MineBlocksOnDemand())
pblock->nVersion = gArgs.GetArg("-blockversion", pblock->nVersion);
pblock->nTime = GetAdjustedTime();
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) ? nMedianTimePast : pblock->GetBlockTime();
// Decide whether to include witness transactions
// This is only needed in case the witness softfork activation is reverted
// (which would require a very deep reorganization).
// Note that the mempool would accept transactions with witness data before
// IsWitnessEnabled, but we would only ever mine blocks after IsWitnessEnabled
// unless there is a massive block reorganization with the witness softfork
// not activated.
// TODO: replace this with a call to main to assess validity of a mempool
// transaction (which in most cases can be a no-op).
fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus()) && fMineWitnessTx;
int nPackagesSelected = 0;
int nDescendantsUpdated = 0;
addPackageTxs(nPackagesSelected, nDescendantsUpdated);
int64_t nTime1 = GetTimeMicros();
nLastBlockTx = nBlockTx;
nLastBlockWeight = nBlockWeight;
// Create coinbase transaction.
CMutableTransaction coinbaseTx;
coinbaseTx.vin.resize(1);
coinbaseTx.vin[0].prevout.SetNull();
coinbaseTx.vout.resize(1);
coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;
coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());
if (fork_conforksus.active) {
coinbaseTx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(FORK_HASH_UINT256.begin(), FORK_HASH_UINT256.end()) << nHeight << OP_0;
} else {
coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
}
pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());
pblocktemplate->vTxFees[0] = -nFees;
// LogPrintf("CreateNewBlock(): block weight: %u txs: %u fees: %ld sigops %d\n", GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost);
// Fill in header
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
pblock->nNonce = 0;
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
CValidationState state;
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));
}
int64_t nTime2 = GetTimeMicros();
LogPrint(BCLog::BENCH, "CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)\n", 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated, 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart));
return std::move(pblocktemplate);
}
void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet)
{
for (CTxMemPool::setEntries::iterator iit = testSet.begin(); iit != testSet.end();) {
// Only test txs not already in the block
if (inBlock.count(*iit)) {
testSet.erase(iit++);
} else {
iit++;
}
}
}
bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost) const
{
// TODO: switch to weight-based accounting for packages instead of vsize-based accounting.
if (nBlockWeight + WITNESS_SCALE_FACTOR * packageSize >= nBlockMaxWeight)
return false;
if (nBlockSigOpsCost + packageSigOpsCost >= (uint64_t)MAX_BLOCK_SIGOPS_COST)
return false;
return true;
}
// Perform transaction-level checks before adding to block:
// - transaction finality (locktime)
// - premature witness (in case segwit transactions are added to mempool before
// segwit activation)
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
{
for (CTxMemPool::txiter it : package) {
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
return false;
if (!fIncludeWitness && it->GetTx().HasWitness())
return false;
}
return true;
}
void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
{
pblock->vtx.emplace_back(iter->GetSharedTx());
pblocktemplate->vTxFees.push_back(iter->GetFee());
pblocktemplate->vTxSigOpsCost.push_back(iter->GetSigOpCost());
nBlockWeight += iter->GetTxWeight();
++nBlockTx;
nBlockSigOpsCost += iter->GetSigOpCost();
nFees += iter->GetFee();
inBlock.insert(iter);
bool fPrintPriority = gArgs.GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);
if (fPrintPriority) {
LogPrintf("fee %s txid %s\n",
CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(),
iter->GetTx().GetHash().ToString());
}
}
int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded,
indexed_modified_transaction_set& mapModifiedTx)
{
int nDescendantsUpdated = 0;
for (CTxMemPool::txiter it : alreadyAdded) {
CTxMemPool::setEntries descendants;
mempool.CalculateDescendants(it, descendants);
// Insert all descendants (not yet in block) into the modified set
for (CTxMemPool::txiter desc : descendants) {
if (alreadyAdded.count(desc))
continue;
++nDescendantsUpdated;
modtxiter mit = mapModifiedTx.find(desc);
if (mit == mapModifiedTx.end()) {
CTxMemPoolModifiedEntry modEntry(desc);
modEntry.nSizeWithAncestors -= it->GetTxSize();
modEntry.nModFeesWithAncestors -= it->GetModifiedFee();
modEntry.nSigOpCostWithAncestors -= it->GetSigOpCost();
mapModifiedTx.insert(modEntry);
} else {
mapModifiedTx.modify(mit, update_for_parent_inclusion(it));
}
}
}
return nDescendantsUpdated;
}
// Skip entries in mapTx that are already in a block or are present
// in mapModifiedTx (which implies that the mapTx ancestor state is
// stale due to ancestor inclusion in the block)
// Also skip transactions that we've already failed to add. This can happen if
// we consider a transaction in mapModifiedTx and it fails: we can then
// potentially consider it again while walking mapTx. It's currently
// guaranteed to fail again, but as a belt-and-suspenders check we put it in
// failedTx and avoid re-evaluation, since the re-evaluation would be using
// cached size/sigops/fee values that are not actually correct.
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx)
{
assert(it != mempool.mapTx.end());
return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it);
}
void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries)
{
// Sort package by ancestor count
// If a transaction A depends on transaction B, then A's ancestor count
// must be greater than B's. So this is sufficient to validly order the
// transactions for block inclusion.
sortedEntries.clear();
sortedEntries.insert(sortedEntries.begin(), package.begin(), package.end());
std::sort(sortedEntries.begin(), sortedEntries.end(), CompareTxIterByAncestorCount());
}
// This transaction selection algorithm orders the mempool based
// on feerate of a transaction including all unconfirmed ancestors.
// Since we don't remove transactions from the mempool as we select them
// for block inclusion, we need an alternate method of updating the feerate
// of a transaction with its not-yet-selected ancestors as we go.
// This is accomplished by walking the in-mempool descendants of selected
// transactions and storing a temporary modified state in mapModifiedTxs.
// Each time through the loop, we compare the best transaction in
// mapModifiedTxs with the next transaction in the mempool to decide what
// transaction package to work on next.
void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated)
{
// mapModifiedTx will store sorted packages after they are modified
// because some of their txs are already in the block
indexed_modified_transaction_set mapModifiedTx;
// Keep track of entries that failed inclusion, to avoid duplicate work
CTxMemPool::setEntries failedTx;
// Start by adding all descendants of previously added txs to mapModifiedTx
// and modifying them for their already included ancestors
UpdatePackagesForAdded(inBlock, mapModifiedTx);
CTxMemPool::indexed_transaction_set::index<ancestor_score>::type::iterator mi = mempool.mapTx.get<ancestor_score>().begin();
CTxMemPool::txiter iter;
// Limit the number of attempts to add transactions to the block when it is
// close to full; this is just a simple heuristic to finish quickly if the
// mempool has a lot of entries.
const int64_t MAX_CONSECUTIVE_FAILURES = 1000;
int64_t nConsecutiveFailed = 0;
while (mi != mempool.mapTx.get<ancestor_score>().end() || !mapModifiedTx.empty()) {
// First try to find a new transaction in mapTx to evaluate.
if (mi != mempool.mapTx.get<ancestor_score>().end() &&
SkipMapTxEntry(mempool.mapTx.project<0>(mi), mapModifiedTx, failedTx)) {
++mi;
continue;
}
// Now that mi is not stale, determine which transaction to evaluate:
// the next entry from mapTx, or the best from mapModifiedTx?
bool fUsingModified = false;
modtxscoreiter modit = mapModifiedTx.get<ancestor_score>().begin();
if (mi == mempool.mapTx.get<ancestor_score>().end()) {
// We're out of entries in mapTx; use the entry from mapModifiedTx
iter = modit->iter;
fUsingModified = true;
} else {
// Try to compare the mapTx entry to the mapModifiedTx entry
iter = mempool.mapTx.project<0>(mi);
if (modit != mapModifiedTx.get<ancestor_score>().end() &&
CompareTxMemPoolEntryByAncestorFee()(*modit, CTxMemPoolModifiedEntry(iter))) {
// The best entry in mapModifiedTx has higher score
// than the one from mapTx.
// Switch which transaction (package) to consider
iter = modit->iter;
fUsingModified = true;
} else {
// Either no entry in mapModifiedTx, or it's worse than mapTx.
// Increment mi for the next loop iteration.
++mi;
}
}
// We skip mapTx entries that are inBlock, and mapModifiedTx shouldn't
// contain anything that is inBlock.
assert(!inBlock.count(iter));
uint64_t packageSize = iter->GetSizeWithAncestors();
CAmount packageFees = iter->GetModFeesWithAncestors();
int64_t packageSigOpsCost = iter->GetSigOpCostWithAncestors();
if (fUsingModified) {
packageSize = modit->nSizeWithAncestors;
packageFees = modit->nModFeesWithAncestors;
packageSigOpsCost = modit->nSigOpCostWithAncestors;
}
if (packageFees < blockMinFeeRate.GetFee(packageSize)) {
// Everything else we might consider has a lower fee rate
return;
}
if (!TestPackage(packageSize, packageSigOpsCost)) {
if (fUsingModified) {
// Since we always look at the best entry in mapModifiedTx,
// we must erase failed entries so that we can consider the
// next best entry on the next loop iteration
mapModifiedTx.get<ancestor_score>().erase(modit);
failedTx.insert(iter);
}
++nConsecutiveFailed;
if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight >
nBlockMaxWeight - 4000) {
// Give up if we're close to full and haven't succeeded in a while
break;
}
continue;
}
CTxMemPool::setEntries ancestors;
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
std::string dummy;
mempool.CalculateMemPoolAncestors(*iter, ancestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false);
onlyUnconfirmed(ancestors);
ancestors.insert(iter);
// Test if all tx's are Final
if (!TestPackageTransactions(ancestors)) {
if (fUsingModified) {
mapModifiedTx.get<ancestor_score>().erase(modit);
failedTx.insert(iter);
}
continue;
}
// This transaction will make it in; reset the failed counter.
nConsecutiveFailed = 0;
// Package can be added. Sort the entries in a valid order.
std::vector<CTxMemPool::txiter> sortedEntries;
SortForBlock(ancestors, sortedEntries);
for (size_t i = 0; i < sortedEntries.size(); ++i) {
AddToBlock(sortedEntries[i]);
// Erase from the modified set, if present
mapModifiedTx.erase(sortedEntries[i]);
}
++nPackagesSelected;
// Update transactions that depend on each of these
nDescendantsUpdated += UpdatePackagesForAdded(ancestors, mapModifiedTx);
}
}
void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
{
// Update nExtraNonce
static uint256 hashPrevBlock;
if (hashPrevBlock != pblock->hashPrevBlock) {
nExtraNonce = 0;
hashPrevBlock = pblock->hashPrevBlock;
}
++nExtraNonce;
unsigned int nHeight = pindexPrev->nHeight + 1; // Height first in coinbase required for block.version=2
CMutableTransaction txCoinbase(*pblock->vtx[0]);
if (fork_conforksus.active) {
txCoinbase.vin[0].scriptSig = (CScript() << std::vector<unsigned char>(FORK_HASH_UINT256.begin(), FORK_HASH_UINT256.end()) << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;
} else {
txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;
}
assert(txCoinbase.vin[0].scriptSig.size() <= 132);
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
}
//////////////////////////////////////////////////////////////////////////////
//
// Internal miner
//
//
// ScanHash scans nonces looking for a hash with at least some zero bits.
// The nonce is usually preserved between calls, but periodically or if the
// nonce is 0xffff0000 or above, the block is rebuilt and nNonce starts over at
// zero.
//
bool static ScanHash(const CBlockHeader* pblock, uint32_t& nNonce, uint256* phash)
{
// Write the first 76 bytes of the block header to a double-SHA256 state.
CHash256 hasher;
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << *pblock;
assert(ss.size() == 80);
hasher.Write((unsigned char*)&ss[0], 76);
while (true) {
nNonce++;
// Write the last 4 bytes of the block header (the nonce) to a copy of
// the double-SHA256 state, and compute the result.
CHash256(hasher).Write((unsigned char*)&nNonce, 4).Finalize((unsigned char*)phash);
// Return the nonce if the hash has at least some zero bits,
// caller will check if it has enough to reach the target
if (((uint16_t*)phash)[15] == 0)
return true;
// If nothing found after trying for a while, return -1
if ((nNonce & 0xfff) == 0)
return false;
}
}
static bool ProcessBlockFound(const std::shared_ptr<const CBlock> pblock, const CChainParams& chainparams)
{
LogPrintf("%s\n", pblock->ToString());
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0]->vout[0].nValue));
// Found a solution
{
LOCK(cs_main);
if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
return error("PaycheckCashMiner: generated block is stale");
}
// // Inform about the new block
GetMainSignals().BlockFound(pblock->GetHash());
// Process this block the same as if we had received it from another node
CValidationState state;
if (!ProcessNewBlock(chainparams, pblock, true, NULL))
return error("PaycheckCashMiner: ProcessNewBlock, block not accepted");
return true;
}
void static PaycheckCashMiner(const CChainParams& chainparams)
{
LogPrintf("PaycheckCashMiner started\n");
// SetThreadPriority(THREAD_PRIORITY_LOWEST);
RenameThread("paycheckcash-miner");
unsigned int nExtraNonce = 0;
std::shared_ptr<CReserveScript> coinbaseScript;
GetMainSignals().ScriptForMining(coinbaseScript);
try {
// Throw an error if no script was provided. This can happen
// due to some internal error but also if the keypool is empty.
// In the latter case, already the pointer is NULL.
if (!coinbaseScript || coinbaseScript->reserveScript.empty())
throw std::runtime_error("No coinbase script available (mining requires a wallet)");
const auto& vNodes = g_connman->GetNodeVectorHaphazardly();
while (true) {
// Busy-wait for the network to come online so we don't waste time mining
// on an obsolete chain. In regtest mode we expect to fly solo.
if (chainparams.MiningRequiresPeers()) {
do {
if (vNodes.size() > 0 && !IsInitialBlockDownload()) break;
MilliSleep(1000);
} while (true);
}
//
// Create new block
//
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
CBlockIndex* pindexPrev = chainActive.Tip();
auto pblocktemplate(BlockAssembler(Params()).CreateNewBlock(coinbaseScript->reserveScript));
if (!pblocktemplate.get()) {
LogPrintf("Error in PaycheckCashMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n");
return;
}
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(pblocktemplate->block);
IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce);
// LogPrintf("Running PaycheckCashMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
// ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
//
// Search
//
int64_t nStart = GetTime();
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
uint256 hash;
uint32_t nNonce = 0;
while (true) {
// Check if something found
if (ScanHash(pblock.get(), nNonce, &hash)) {
if (UintToArith256(hash) <= hashTarget) {
// Found a solution
pblock->nNonce = nNonce;
assert(hash == pblock->GetHash());
// SetThreadPriority(THREAD_PRIORITY_NORMAL);
LogPrintf("PaycheckCashMiner:\n");
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex(), hashTarget.GetHex());
ProcessBlockFound(pblock, chainparams);
// SetThreadPriority(THREAD_PRIORITY_LOWEST);
coinbaseScript->KeepScript();
// In regression test mode, stop mining after a block is found.
if (chainparams.MineBlocksOnDemand())
throw boost::thread_interrupted();
break;
}
}
// Check for stop or if block needs to be rebuilt
boost::this_thread::interruption_point();
if (ShutdownRequested()) return;
// Regtest mode doesn't require peers
if (chainparams.MiningRequiresPeers() && !vNodes.size())
break;
if (nNonce >= 0xffff0000)
break;
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
break;
if (pindexPrev != chainActive.Tip())
break;
// Update nTime every few seconds
if (UpdateTime(pblock.get(), chainparams.GetConsensus(), pindexPrev) < 0)
break; // Recreate the block if the clock has run backwards,
// so that we can use the correct time.
if (chainparams.GetConsensus().fPowAllowMinDifficultyBlocks) {
// Changing pblock->nTime can change work required on testnet:
hashTarget.SetCompact(pblock->nBits);
}
}
}
} catch (const boost::thread_interrupted&) {
LogPrintf("PaycheckCashMiner terminated\n");
throw;
} catch (const std::runtime_error& e) {
LogPrintf("PaycheckCashMiner runtime error: %s\n", e.what());
return;
}
}
void GeneratePaycheckCashs(bool fGenerate, int nThreads, const CChainParams& chainparams)
{
static boost::thread_group* minerThreads = NULL;
if (nThreads < 0)
nThreads = GetNumCores();
if (minerThreads != NULL) {
minerThreads->interrupt_all();
delete minerThreads;
minerThreads = NULL;
}
if (nThreads == 0 || !fGenerate)
return;
if (Params().MiningRequiresPeers() && fPruneMode) {
throw std::runtime_error("Cannot mine peer-dependent blocks on a pruned node");
}
minerThreads = new boost::thread_group();
for (int i = 0; i < nThreads; i++)
minerThreads->create_thread(boost::bind(&PaycheckCashMiner, boost::cref(chainparams)));
}
|
#include "window.h"
#include <stdexcept>
using namespace std;
void mouse(GLFWwindow *window, double xpos, double ypos);
unique_ptr<GLFWwindow, function<void(GLFWwindow*)>> Window::window
= unique_ptr<GLFWwindow, function<void(GLFWwindow*)>>(nullptr, glfwDestroyWindow);
pair<GLsizei, GLsizei> Window::dimension = {0,0};
GLfloat Window::currentTimer = 0.f;
GLfloat Window::lastTimer = 0.f;
GLfloat Window::deltaTimer = 0.f;
void Window::init(const string &title, int width, int height) {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,3 );
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwWindowHint(GLFW_SAMPLES, 4);
dimension = {width, height};
window.reset(glfwCreateWindow(dimension.first, dimension.second, title.c_str(), nullptr, nullptr));
if (!window)
throw new runtime_error("GLFW window failed to be created!");
glfwMakeContextCurrent(window.get());
glfwSetInputMode(window.get(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK)
throw new runtime_error("GLEW failed to initialize!");
glViewport(0,0, dimension.first, dimension.second);
glEnable(GL_MULTISAMPLE);
}
GLboolean Window::isClosed() {
return glfwWindowShouldClose(window.get());
}
void Window::update() {
glfwSwapBuffers(window.get());
currentTimer = static_cast<GLfloat>(glfwGetTime());
deltaTimer = currentTimer - lastTimer;
lastTimer = currentTimer;
if (getKey()(GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window.get(), GL_TRUE);
}
void Window::close() {
glfwTerminate();
}
void Window::clear() {
glClearColor(0.2f, 0.3f, 0.3f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
float Window::aspect() {
return static_cast<float>(dimension.first)/static_cast<float>(dimension.second);
}
void Window::startTimer() {
currentTimer = static_cast<GLfloat>(glfwGetTime());
}
GLfloat Window::deltaTime() {
return deltaTimer;
}
function<int(int)> Window::getKey() {
GLFWwindow *win = window.get();
return [win](int key){return glfwGetKey(win, key);};
}
function<void(double*,double*)> Window::getMousePosition() {
GLFWwindow *win = window.get();
return [win](double *xpos, double *ypos){return glfwGetCursorPos(win, xpos, ypos);};
}
function<int(int)> Window::getMouseButton() {
GLFWwindow *win = window.get();
return [win](int button){return glfwGetMouseButton(win, button);};
}
|
//q11369.cpp - 2011/11/11
//accepted at
//run time = 0.128 / 0.124c
#include <stdio.h>
void quicksort( int start, int end, int array[] )
{
if( start < end )
{
int piv = start;
int i;
int temp;
for( i = start+1 ; i < end ; i++ )
if( array[i] > array[start] )
{
piv++;
temp = array[i];
array[i] = array[piv];
array[piv] = temp;
}
temp = array[start];
array[start] = array[piv];
array[piv] = temp;
quicksort( start, piv, array );
quicksort( piv+1, end, array );
}
}
int main(){
#ifndef ONLINE_JUDGE
freopen("q11369.in", "r", stdin);
freopen("q11369.out", "w", stdout);
#endif
int caseNum, i, n, result;
int shoplist[20005];
scanf("%d", &caseNum);
while(caseNum--){
scanf("%d", &n);
for(i=0;i<n;++i)
scanf("%d", &shoplist[i]);
quicksort(0, n, shoplist);
result = 0;
for(i=2;i<n;i+=3)
result += shoplist[i];
printf("%d\n", result);
}
return 0;
}
|
// Copyright (c) 2009-2018 The Rain Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <core_io.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <script/script.h>
#include <script/sign.h>
#include <serialize.h>
#include <streams.h>
#include <univalue.h>
#include <util/strencodings.h>
#include <version.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <algorithm>
CScript ParseScript(const std::string& s)
{
CScript result;
static std::map<std::string, opcodetype> mapOpNames;
if (mapOpNames.empty())
{
for (unsigned int op = 0; op <= MAX_OPCODE; op++)
{
// Allow OP_RESERVED to get into mapOpNames
if (op < OP_NOP && op != OP_RESERVED)
continue;
const char* name = GetOpName(static_cast<opcodetype>(op));
if (strcmp(name, "OP_UNKNOWN") == 0)
continue;
std::string strName(name);
mapOpNames[strName] = static_cast<opcodetype>(op);
// Convenience: OP_ADD and just ADD are both recognized:
boost::algorithm::replace_first(strName, "OP_", "");
mapOpNames[strName] = static_cast<opcodetype>(op);
}
}
std::vector<std::string> words;
boost::algorithm::split(words, s, boost::algorithm::is_any_of(" \t\n"), boost::algorithm::token_compress_on);
for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w)
{
if (w->empty())
{
// Empty string, ignore. (boost::split given '' will return one word)
}
else if (std::all_of(w->begin(), w->end(), ::IsDigit) ||
(w->front() == '-' && w->size() > 1 && std::all_of(w->begin()+1, w->end(), ::IsDigit)))
{
// Number
int64_t n = atoi64(*w);
result << n;
}
else if (w->substr(0,2) == "0x" && w->size() > 2 && IsHex(std::string(w->begin()+2, w->end())))
{
// Raw hex data, inserted NOT pushed onto stack:
std::vector<unsigned char> raw = ParseHex(std::string(w->begin()+2, w->end()));
result.insert(result.end(), raw.begin(), raw.end());
}
else if (w->size() >= 2 && w->front() == '\'' && w->back() == '\'')
{
// Single-quoted string, pushed as data. NOTE: this is poor-man's
// parsing, spaces/tabs/newlines in single-quoted strings won't work.
std::vector<unsigned char> value(w->begin()+1, w->end()-1);
result << value;
}
else if (mapOpNames.count(*w))
{
// opcode, e.g. OP_ADD or ADD:
result << mapOpNames[*w];
}
else
{
throw std::runtime_error("script parse error");
}
}
return result;
}
// Check that all of the input and output scripts of a transaction contains valid opcodes
static bool CheckTxScriptsSanity(const CMutableTransaction& tx)
{
// Check input scripts for non-coinbase txs
if (!CTransaction(tx).IsCoinBase()) {
for (unsigned int i = 0; i < tx.vin.size(); i++) {
if (!tx.vin[i].scriptSig.HasValidOps() || tx.vin[i].scriptSig.size() > MAX_SCRIPT_SIZE) {
return false;
}
}
}
// Check output scripts
for (unsigned int i = 0; i < tx.vout.size(); i++) {
if (!tx.vout[i].scriptPubKey.HasValidOps() || tx.vout[i].scriptPubKey.size() > MAX_SCRIPT_SIZE) {
return false;
}
}
return true;
}
bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness, bool try_witness)
{
if (!IsHex(hex_tx)) {
return false;
}
std::vector<unsigned char> txData(ParseHex(hex_tx));
if (try_no_witness) {
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
try {
ssData >> tx;
if (ssData.eof() && (!try_witness || CheckTxScriptsSanity(tx))) {
return true;
}
} catch (const std::exception&) {
// Fall through.
}
}
if (try_witness) {
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
try {
ssData >> tx;
if (ssData.empty()) {
return true;
}
} catch (const std::exception&) {
// Fall through.
}
}
return false;
}
bool DecodeHexBlockHeader(CBlockHeader& header, const std::string& hex_header)
{
if (!IsHex(hex_header)) return false;
const std::vector<unsigned char> header_data{ParseHex(hex_header)};
CDataStream ser_header(header_data, SER_NETWORK, PROTOCOL_VERSION);
try {
ser_header >> header;
} catch (const std::exception&) {
return false;
}
return true;
}
bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk)
{
if (!IsHex(strHexBlk))
return false;
std::vector<unsigned char> blockData(ParseHex(strHexBlk));
CDataStream ssBlock(blockData, SER_NETWORK, PROTOCOL_VERSION);
try {
ssBlock >> block;
}
catch (const std::exception&) {
return false;
}
return true;
}
bool ParseHashStr(const std::string& strHex, uint256& result)
{
if ((strHex.size() != 64) || !IsHex(strHex))
return false;
result.SetHex(strHex);
return true;
}
std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName)
{
std::string strHex;
if (v.isStr())
strHex = v.getValStr();
if (!IsHex(strHex))
throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')");
return ParseHex(strHex);
}
int ParseSighashString(const UniValue& sighash)
{
int hash_type = SIGHASH_ALL;
if (!sighash.isNull()) {
static std::map<std::string, int> map_sighash_values = {
{std::string("ALL"), int(SIGHASH_ALL)},
{std::string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)},
{std::string("NONE"), int(SIGHASH_NONE)},
{std::string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)},
{std::string("SINGLE"), int(SIGHASH_SINGLE)},
{std::string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)},
};
std::string strHashType = sighash.get_str();
const auto& it = map_sighash_values.find(strHashType);
if (it != map_sighash_values.end()) {
hash_type = it->second;
} else {
throw std::runtime_error(strHashType + " is not a valid sighash parameter.");
}
}
return hash_type;
}
|
// ==++==
//
//
// Copyright (c) 2006 Microsoft Corporation. All rights reserved.
//
// The use and distribution terms for this software are contained in the file
// named license.txt, which can be found in the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by the
// terms of this license.
//
// You must not remove this notice, or any other, from this software.
//
//
// ==--==
#include "common.h"
#include <winwrap.h>
#include <excep.h> // For COMPlusThrow
#include <appdomain.hpp>
#include <assembly.hpp>
#include "nlstable.h" // Class declaration
/*=================================NLSTable==========================
**Action: Constructor for NLSTable. It caches the assembly from which we will read data table files.
**Returns: Create a new NLSTable instance.
**Arguments: pAssembly the Assembly that NLSTable will retrieve data table files from.
**Exceptions: None.
============================================================================*/
NLSTable::NLSTable(Assembly* pAssembly) {
CONTRACTL {
NOTHROW;
GC_NOTRIGGER;
MODE_COOPERATIVE;
SO_TOLERANT;
PRECONDITION(CheckPointer(pAssembly));
} CONTRACTL_END;
m_pAssembly = pAssembly;
}
/*=================================CreateSharedMemoryMapping==================================
**Action: Create a file mapping object which can be shared among different users under Windows NT/2000.
** Actually its just a memory mapped section of the swapfile.
**Returns: The file mapping handle. NULL if any error happens.
**Arguments:
** pMappingName the name of the file mapping object.
** iSize Size to use
**Exceptions:
**Note:
** This function creates a DACL which grants GENERIC_ALL access to members of the "Everyone" group.
** Then create a security descriptor using this DACL. Finally, use this SA to create the file mapping object.
** WARNING:
** This creates a shared file or shared paged memory section (if hFile == INVALID_HANDLE_VALUE) that is shared machine-wide
** Therefore for side-by-side to work, the mapping names must be unique per version!
** We utilize this feature for code pages in case it hasn't changed across versions we can still reuse the
** tables, but it seems suspicious for other applications (as commented in MapDataFile below)
==============================================================================*/
// static method
HANDLE NLSTable::CreateSharedMemoryMapping(const LPCWSTR pMappingName, const int iSize ) {
CONTRACTL {
THROWS;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(iSize > 0);
PRECONDITION(CheckPointer(pMappingName));
} CONTRACTL_END;
HANDLE hFileMap = NULL;
{
// In Windows 9x, security is not supported, so just pass NULL in security attribute.
hFileMap = WszCreateFileMapping(
INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, iSize, pMappingName);
}
// If still not allowed, try building one with no name
if (hFileMap == NULL)
{
hFileMap = WszCreateFileMapping(
INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, iSize, NULL);
}
return (hFileMap) ;
}
/*=================================OpenOrCreateMemoryMapping==================================
**Action: Opens an existing memory mapped object, or creates a new one (by calling above fn).
** Worst case just allocate some memory.
**Returns: The pointer to our memory. NULL if any error happens.
**Arguments:
** pMappingName the name of the file mapping object.
** iSize Size to use
**Exceptions:
**
**IMPORTANT:
** Memory mapped sections are cleared when set. We expect the caller to set the last int
** to a non-zero value, so we test this flag. If it is still zero when we open it, we
** assume that we've gotten a result in an unfinished state and allocate a new one instead
** of trying to use the one with the zeros.
**
**Note:
** This function creates a DACL which grants GENERIC_ALL access to members of the "Everyone" group.
** Then create a security descriptor using this DACL. Finally, use this SA to create the file mapping object.
** WARNING:
** This creates a shared file or shared paged memory section (if hFile == INVALID_HANDLE_VALUE) that is shared machine-wide
** Therefore for side-by-side to work, the mapping names must be unique per version!
** We utilize this feature for code pages in case it hasn't changed across versions we can still reuse the
** tables, but it seems suspicious for other applications (as commented in MapDataFile below)
==============================================================================*/
PBYTE NLSTable::OpenOrCreateMemoryMapping(const LPCWSTR pMappingName, const int iSize, HANDLE* mappedFile)
{
CONTRACTL
{
THROWS;
DISABLED(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(iSize % 4 == 0);
PRECONDITION(iSize > 0);
PRECONDITION(CheckPointer(pMappingName));
PRECONDITION(CheckPointer(mappedFile));
} CONTRACTL_END;
_ASSERTE(pMappingName != NULL); // Must have a string name.
_ASSERTE(iSize > 0); // Pointless to have <= 0 allocation
_ASSERTE(iSize % 4 == 0); // Need 4 byte alignment for flag check
LPVOID pResult = NULL;
// Try creating/opening it.
HANDLE hMap = NULL;
*mappedFile = hMap;
// Calls into OS a lot, should switch to preemp mode
GCX_PREEMP();
if (hMap == NULL) {
// If access is denied for global\namespace or the name is not opened in global namespace, try the local namespace.
// Also if we're rotor or win 9x.
hMap = WszOpenFileMapping(FILE_MAP_READ, TRUE, pMappingName);
}
if (hMap != NULL) {
// We got a section, map a view, READ ONLY!
pResult = MapViewOfFile( hMap, FILE_MAP_READ, 0, 0, 0);
// Anything found?
if (pResult != NULL)
{
// Make sure our result is allocated. We expect a non-0 flag to be set for last int of our section
int* pFlag = (int*)(((BYTE*)pResult) + iSize - 4);
if (*pFlag != 0)
{
*mappedFile = hMap;
// Found a valid already opened section!
return (PBYTE)pResult;
}
// Couldn't find it, unmap it.
UnmapViewOfFile(pResult);
pResult = NULL;
}
// We can't use this one, so close it
CloseHandle(hMap);
hMap = NULL;
}
// Didn't get a section, try to create one, NT/XP/.Net gets security permissions, 9X doesn't,
// but our helper fn takes care of that for us.
hMap = NLSTable::CreateSharedMemoryMapping(pMappingName, iSize);
// Were we successfull?
if (hMap != NULL)
{
// We have hMap, try to get our section
pResult = MapViewOfFile( hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
// Don't close hMap unless we aren't using it.
// That confuses the mapping stuff and we lose the name, it'll close when runtime shuts down.
if (pResult == NULL)
{
CloseHandle(hMap);
hMap = NULL;
}
// There is no need to zero out the mapCodePageCached field, since the initial contents of the pages in the file mapping object are zero.
*mappedFile = hMap;
}
return (PBYTE)pResult;
}
/*=================================GetResource==================================
**Action: Open the specified NLS+ data file from system assembly.
**Returns: Pointer to the interesting memory
**Arguments: The required NLS+ data file name (in ANSI)
**Exceptions: OutOfMemoryException if error happens in get the data file
** from system assembly.
==============================================================================*/
PBYTE NLSTable::GetResource(LPCSTR pFileName) {
CONTRACTL {
THROWS;
GC_TRIGGERS; // Assembly::GetResource() may trigger a GC.
MODE_COOPERATIVE;
PRECONDITION(CheckPointer(pFileName));
} CONTRACTL_END;
_ASSERTE(m_pAssembly != NULL);
DWORD cbResource;
PBYTE pbInMemoryResource = NULL;
//
// Get the base system assembly (mscorlib.dll to most of us);
//
// Get the resource, and associated file handle, from the assembly.
if (m_pAssembly->GetResource(pFileName,
&cbResource, &pbInMemoryResource,
NULL, NULL, NULL) == FALSE) {
COMPlusThrowOM();
}
_ASSERTE(pbInMemoryResource != NULL);
return (pbInMemoryResource);
}
/*=================================GetResource==================================
**Action: Open a NLS+ resource from system assembly.
**Returns: Pointer to the interesting memory
**Arguments: The required NLS+ data file name (in Unicode)
**Exceptions: OutOfMemoryException if buffer can not be allocated.
** ExecutionEngineException if error happens in calling OpenDataFile(LPCSTR)
==============================================================================*/
PBYTE NLSTable::GetResource(LPCWSTR pFileName)
{
CONTRACTL {
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
PRECONDITION(CheckPointer(pFileName));
} CONTRACTL_END;
PBYTE pbInMemoryResource = NULL;
// The following macro will delete pAnsiFileName when
// getting out of the scope of this function.
MAKE_ANSIPTR_FROMWIDE(pAnsiFileName, pFileName);
if (!pAnsiFileName)
{
COMPlusThrowOM();
}
pbInMemoryResource = GetResource((LPCSTR)pAnsiFileName);
_ASSERTE(pbInMemoryResource != NULL);
return (pbInMemoryResource);
}
|
// 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.
//
// This file defines the trace::agent_logger::LoggerApp class which implements
// the LoggerApp RPC interface.
#include "syzygy/trace/agent_logger/agent_logger_app.h"
#include "base/bind.h"
#include "base/environment.h"
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/files/file_util.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/scoped_handle.h"
#include "syzygy/common/rpc/helpers.h"
#include "syzygy/trace/agent_logger/agent_logger.h"
#include "syzygy/trace/agent_logger/agent_logger_rpc_impl.h"
#include "syzygy/trace/common/service_util.h"
#include "syzygy/trace/protocol/call_trace_defs.h"
#include "syzygy/trace/rpc/logger_rpc.h"
namespace trace {
namespace agent_logger {
namespace {
using ::common::rpc::GetInstanceString;
// The usage string for the logger app.
const char kUsageFormatStr[] =
"Usage: %ls [options] ACTION [-- command]\n"
" Supported actions:\n"
" start Run a new logger instance in the foreground (blocking). You\n"
" may optionally specify an external command which will be\n"
" run behind the logger. The logger will return once the\n"
" external command has terminated or the logger is externally\n"
" stopped. If no command is specified, Ctrl-C or an invocation\n"
" of the stop action will stop the logger.\n"
" spawn Run a new logger instance in the background (non-blocking).\n"
" stop Stop a separately running logger instance.\n"
"\n"
" Options:\n"
" --append Append to (instead of truncating) the output\n"
" file. This option is valid for the start and\n"
" spawn actions.\n"
" --instance-id=ID A unique (up to 16 character) ID to identify\n"
" the logger instance.\n"
" --minidump-dir=PATH The directory path in which minidumps, if any,\n"
" should be generated.\n"
" --output-file=PATH The file path to which logs should be written.\n"
" This may be stdout (the default), stderr or a\n"
" file path. This option is valid for the start\n"
" and spawn actions.\n"
" --unique-instance-id Automatically generate a unique ID for the\n"
" logger instance.\n";
// Names for kernel objects used to synchronize with a logger singleton.
const wchar_t kLoggerMutexRoot[] = L"syzygy-logger-mutex";
const wchar_t kLoggerStartEventRoot[] = L"syzygy-logger-started";
const wchar_t kLoggerStopEventRoot[] = L"syzygy-logger-stopped";
// A static location to which the current instance id can be saved. We
// persist it here so that OnConsoleCtrl can have access to the instance
// id when it is invoked on the signal handler thread.
wchar_t saved_instance_id[LoggerApp::kMaxInstanceIdLength + 1] = { 0 };
// Send a stop request via RPC to the logger instance given by @p instance_id.
bool SendStopRequest(const base::StringPiece16& instance_id) {
std::wstring protocol(kLoggerRpcProtocol);
std::wstring endpoint(GetInstanceString(kLoggerRpcEndpointRoot, instance_id));
LOG(INFO) << "Stopping logging service instance at '"
<< endpoint << "' via " << protocol << '.';
handle_t binding = NULL;
if (!::common::rpc::CreateRpcBinding(protocol, endpoint, &binding)) {
LOG(ERROR) << "Failed to connect to logging service.";
return false;
}
if (!::common::rpc::InvokeRpc(LoggerClient_Stop, binding).succeeded()) {
LOG(ERROR) << "Failed to stop logging service.";
return false;
}
LOG(INFO) << "Logging service shutdown has been requested.";
return true;
}
// Handler function to be called on exit signals (Ctrl-C, TERM, etc...).
BOOL WINAPI OnConsoleCtrl(DWORD ctrl_type) {
if (ctrl_type != CTRL_LOGOFF_EVENT) {
SendStopRequest(saved_instance_id);
return TRUE;
}
return FALSE;
}
// A helper function to signal an event. This is passable as a callback to
// a Logger instance to be called on logger start/stop.
bool SignalEvent(HANDLE event_handle, trace::common::Service* /* logger */) {
DCHECK_NE(INVALID_HANDLE_VALUE, event_handle);
if (!::SetEvent(event_handle))
return false;
return true;
}
// A helper function which sets the Syzygy RPC instance id environment variable
// then runs a given command line to completion.
bool RunApp(const base::CommandLine& command_line,
const std::wstring& instance_id,
HANDLE interruption_event,
int* exit_code) {
DCHECK(exit_code != NULL);
scoped_ptr<base::Environment> env(base::Environment::Create());
CHECK(env != NULL);
// Put |instance_id| as the first value.
std::string env_var;
env->GetVar(kSyzygyRpcInstanceIdEnvVar, &env_var);
env->SetVar(kSyzygyRpcInstanceIdEnvVar,
base::WideToUTF8(instance_id) + ";" + env_var);
LOG(INFO) << "Launching '" << command_line.GetProgram().value() << "'.";
VLOG(1) << "Command Line: " << command_line.GetCommandLineString();
*exit_code = 0;
// Launch a new process in the background.
base::LaunchOptions options;
options.start_hidden = false;
base::Process process = base::LaunchProcess(command_line, options);
if (!process.IsValid()) {
LOG(ERROR)
<< "Failed to launch '" << command_line.GetProgram().value() << "'.";
return false;
}
HANDLE objects[] = {process.Handle(), interruption_event};
DWORD num_objects = arraysize(objects);
switch (::WaitForMultipleObjects(num_objects, objects, FALSE, INFINITE)) {
case WAIT_OBJECT_0 + 0: {
// The client process has finished.
DWORD temp_exit_code;
::GetExitCodeProcess(process.Handle(), &temp_exit_code);
*exit_code = temp_exit_code;
process.Close();
return true;
}
case WAIT_OBJECT_0 + 1: {
// The logger has been shutdown. Kill the client process.
process.Terminate(1, true);
process.Close();
*exit_code = 1;
return true;
}
}
// If we get here then an error has occurred (since the timeout is infinite).
DWORD error = ::GetLastError();
LOG(ERROR) << "Error waiting for shutdown event " << ::common::LogWe(error)
<< ".";
return false;
}
} // namespace
// Keywords appearing on the command-line
const wchar_t LoggerApp::kSpawn[] = L"spawn";
const wchar_t LoggerApp::kStart[] = L"start";
const wchar_t LoggerApp::kStatus[] = L"status";
const wchar_t LoggerApp::kStop[] = L"stop";
const char LoggerApp::kInstanceId[] = "instance-id";
const char LoggerApp::kUniqueInstanceId[] = "unique-instance-id";
const char LoggerApp::kOutputFile[] = "output-file";
const char LoggerApp::kMiniDumpDir[] = "minidump-dir";
const char LoggerApp::kAppend[] = "append";
const wchar_t LoggerApp::kStdOut[] = L"stdout";
const wchar_t LoggerApp::kStdErr[] = L"stderr";
// A table mapping action keywords to their handler implementations.
const LoggerApp::ActionTableEntry LoggerApp::kActionTable[] = {
{ LoggerApp::kSpawn, &LoggerApp::Spawn },
{ LoggerApp::kStart, &LoggerApp::Start },
{ LoggerApp::kStatus, &LoggerApp::Status },
{ LoggerApp::kStop, &LoggerApp::Stop },
};
LoggerApp::LoggerApp()
: ::application::AppImplBase("AgentLogger"),
logger_command_line_(base::CommandLine::NO_PROGRAM),
action_handler_(NULL),
append_(false) {
}
LoggerApp::~LoggerApp() {
}
bool LoggerApp::ParseCommandLine(const base::CommandLine* command_line) {
DCHECK(command_line != NULL);
if (!trace::common::SplitCommandLine(
command_line,
&logger_command_line_,
&app_command_line_)) {
LOG(ERROR) << "Failed to split command_line into logger and app parts.";
return false;
}
// Save the command-line in case we need to spawn.
command_line = &logger_command_line_;
if (command_line->HasSwitch(kInstanceId) &&
command_line->HasSwitch(kUniqueInstanceId)) {
return Usage(command_line,
base::StringPrintf("--%s and --%s are mutually exclusive.",
kInstanceId,
kUniqueInstanceId));
}
// Parse the instance id.
instance_id_ = command_line->GetSwitchValueNative(kInstanceId);
if (instance_id_.length() > kMaxInstanceIdLength) {
return Usage(command_line,
base::StringPrintf("The instance id '%ls' is too long. "
"The max length is %d characters.",
instance_id_.c_str(),
kMaxInstanceIdLength));
}
// Save the output file parameter.
output_file_path_ = command_line->GetSwitchValuePath(kOutputFile);
// Save the minidump-dir parameter.
mini_dump_dir_ = command_line->GetSwitchValuePath(kMiniDumpDir);
if (mini_dump_dir_.empty()) {
CHECK(PathService::Get(base::DIR_CURRENT, &mini_dump_dir_));
} else {
mini_dump_dir_ = base::MakeAbsoluteFilePath(mini_dump_dir_);
if (mini_dump_dir_.empty())
return Usage(command_line, "The minidump-dir parameter is invalid.");
if (!base::DirectoryExists(mini_dump_dir_) &&
!base::CreateDirectory(mini_dump_dir_)) {
LOG(ERROR) << "Failed to create minidump-dir "
<< mini_dump_dir_.value();
}
}
// Make sure there's exactly one action.
if (command_line->GetArgs().size() != 1) {
return Usage(command_line,
"Exactly 1 action is expected on the command line.");
}
// Check for the append flag.
append_ = command_line->HasSwitch(kAppend);
// Parse the action.
action_ = command_line->GetArgs()[0];
const ActionTableEntry* entry = FindActionHandler(action_);
if (entry == NULL) {
return Usage(
command_line,
base::StringPrintf("Unrecognized action: %s.", action_.c_str()));
}
if (command_line->HasSwitch(kUniqueInstanceId)) {
DWORD process_id = ::GetCurrentProcessId();
DWORD timestamp = ::GetTickCount();
base::SStringPrintf(&instance_id_, L"%08x%08x", process_id, timestamp);
DCHECK_EQ(kMaxInstanceIdLength, instance_id_.length());
}
LOG(INFO) << "Using logger instance ID: '" << instance_id_ << "'.";
LOG(INFO) << "Writing minidumps to: " << mini_dump_dir_.value();
// Setup the action handler.
DCHECK(entry->handler != NULL);
action_handler_ = entry->handler;
return true;
}
int LoggerApp::Run() {
DCHECK(action_handler_ != NULL);
if (!(this->*action_handler_)())
return 1;
return 0;
}
// A helper function to find the handler method for a given action.
const LoggerApp::ActionTableEntry* LoggerApp::FindActionHandler(
const base::StringPiece16& action) {
for (size_t i = 0; i < arraysize(kActionTable); ++i) {
if (::_wcsicmp(kActionTable[i].action, action.data()) == 0)
return &kActionTable[i];
}
return NULL;
}
bool LoggerApp::Start() {
std::wstring logger_name(
GetInstanceString(kLoggerRpcEndpointRoot, instance_id_));
// Acquire the logger mutex.
base::win::ScopedHandle mutex;
std::wstring mutex_name(GetInstanceString(kLoggerMutexRoot, instance_id_));
if (!trace::common::AcquireMutex(mutex_name, &mutex))
return false;
// Setup the start event.
base::win::ScopedHandle start_event;
std::wstring start_event_name(
GetInstanceString(kLoggerStartEventRoot, instance_id_));
if (!trace::common::InitEvent(start_event_name, &start_event)) {
LOG(ERROR) << "Unable to init start event for '" << logger_name << "'.";
return false;
}
// Setup the stop event.
base::win::ScopedHandle stop_event;
std::wstring stop_event_name(
GetInstanceString(kLoggerStopEventRoot, instance_id_));
if (!trace::common::InitEvent(stop_event_name, &stop_event)) {
LOG(ERROR) << "Unable to init stop event for '" << logger_name << "'.";
return false;
}
// Setup an anonymous event to notify us if the logger has been
// asynchronously asked to shutdown.
base::win::ScopedHandle interrupt_event;
if (!trace::common::InitEvent(L"", &interrupt_event)) {
LOG(ERROR) << "Unable to init interrupt event for '" << logger_name << "'.";
return false;
}
// Get the log file output_file.
FILE* output_file = NULL;
bool must_close_output_file = false;
base::ScopedFILE auto_close;
if (!OpenOutputFile(&output_file, &must_close_output_file)) {
LOG(ERROR) << "Unable to open '" << output_file_path_.value() << "'.";
return false;
}
// Setup auto_close as appropriate.
if (must_close_output_file)
auto_close.reset(output_file);
// Initialize the logger instance.
AgentLogger logger;
logger.set_destination(output_file);
logger.set_minidump_dir(mini_dump_dir_);
logger.set_instance_id(instance_id_);
logger.set_started_callback(
base::Bind(&SignalEvent, start_event.Get()));
logger.set_stopped_callback(
base::Bind(&SignalEvent, stop_event.Get()));
logger.set_interrupted_callback(
base::Bind(&SignalEvent, interrupt_event.Get()));
// Save the instance_id for the Ctrl-C handler.
::wcsncpy_s(saved_instance_id,
arraysize(saved_instance_id),
instance_id_.c_str(),
_TRUNCATE);
// Register the handler for Ctrl-C.
if (!SetConsoleCtrlHandler(&OnConsoleCtrl, TRUE)) {
DWORD error = ::GetLastError();
LOG(ERROR) << "Failed to register shutdown handler: "
<< ::common::LogWe(error) << ".";
return false;
}
// Start the logger.
RpcLoggerInstanceManager instance_manager(&logger);
if (!logger.Start()) {
LOG(ERROR) << "Failed to start '" << logger_name << "'.";
return false;
}
bool error = false;
// Run the logger, either standalone or as the parent of some application.
trace::common::ScopedConsoleCtrlHandler ctrl_handler;
if (app_command_line_.get() != NULL) {
// We have a command to run, so launch that command and when it finishes
// stop the logger.
int exit_code = 0;
if (!RunApp(*app_command_line_, instance_id_, interrupt_event.Get(),
&exit_code) ||
exit_code != 0) {
error = true;
}
ignore_result(logger.Stop());
} else {
// There is no command to wait for, so just register the control handler
// (we stop the logger if this fails) and then let the logger run until
// the control handler stops it or someone externally stops it using the
// stop command.
if (!ctrl_handler.Init(&OnConsoleCtrl)) {
ignore_result(logger.Stop());
error = true;
}
}
// Run the logger to completion.
if (!logger.Join()) {
LOG(ERROR) << "Failed running to completion '" << logger_name << "'.";
error = true;
}
// And we're done.
return !error;
}
bool LoggerApp::Status() {
// TODO(rogerm): Implement me.
return false;
}
bool LoggerApp::Spawn() {
std::wstring logger_name(
GetInstanceString(kLoggerRpcEndpointRoot, instance_id_));
LOG(INFO) << "Launching background logging service '" << logger_name << "'.";
// Get the path to ourselves.
base::FilePath self_path;
PathService::Get(base::FILE_EXE, &self_path);
// Build a command line for starting a new instance of the logger.
base::CommandLine new_command_line(self_path);
new_command_line.AppendArg("start");
// Copy over any other switches.
base::CommandLine::SwitchMap::const_iterator it =
logger_command_line_.GetSwitches().begin();
for (; it != logger_command_line_.GetSwitches().end(); ++it)
new_command_line.AppendSwitchNative(it->first, it->second);
// Launch a new process in the background.
base::LaunchOptions options;
options.start_hidden = true;
base::Process process = base::LaunchProcess(new_command_line, options);
if (!process.IsValid()) {
LOG(ERROR) << "Failed to launch process.";
return false;
}
// Setup the start event.
base::win::ScopedHandle start_event;
std::wstring start_event_name(
GetInstanceString(kLoggerStartEventRoot, instance_id_));
if (!trace::common::InitEvent(start_event_name, &start_event)) {
LOG(ERROR) << "Unable to init start event for '" << logger_name << "'.";
return false;
}
// We wait on both the start event and the process, as if the process fails
// for any reason, it'll exit and its handle will become signaled.
HANDLE handles[] = {start_event.Get(), process.Handle()};
if (::WaitForMultipleObjects(arraysize(handles),
handles,
FALSE,
INFINITE) != WAIT_OBJECT_0) {
LOG(ERROR) << "The logger '" << logger_name << "' exited in error.";
return false;
}
LOG(INFO) << "Background logger '" << logger_name << "' is running.";
return true;
}
bool LoggerApp::Stop() {
std::wstring logger_name(
GetInstanceString(kLoggerRpcEndpointRoot, instance_id_));
// Setup the stop event.
base::win::ScopedHandle stop_event;
std::wstring stop_event_name(
GetInstanceString(kLoggerStopEventRoot, instance_id_));
if (!trace::common::InitEvent(stop_event_name, &stop_event)) {
LOG(ERROR) << "Unable to init stop event for '" << logger_name << "'.";
return false;
}
// Send the stop request.
if (!SendStopRequest(instance_id_))
return false;
// We wait on both the RPC event and the process, as if the process fails for
// any reason, it'll exit and its handle will become signaled.
if (::WaitForSingleObject(stop_event.Get(), INFINITE) != WAIT_OBJECT_0) {
LOG(ERROR) << "Timed out waiting for '" << logger_name << "' to stop.";
return false;
}
LOG(INFO) << "The logger instance has stopped.";
return true;
}
// Helper to resolve @p path to an open file. This will set @p must_close
// to true if @path denotes a newly opened file, and false if it denotes
// stderr or stdout.
bool LoggerApp::OpenOutputFile(FILE** output_file, bool* must_close) {
DCHECK(output_file != NULL);
DCHECK(must_close != NULL);
*output_file = NULL;
*must_close = false;
// Check for stdout.
if (output_file_path_.empty() ||
::_wcsnicmp(output_file_path_.value().c_str(),
kStdOut,
arraysize(kStdOut)) == 0) {
*output_file = stdout;
return true;
}
// Check for stderr.
if (::_wcsnicmp(output_file_path_.value().c_str(),
kStdErr,
arraysize(kStdErr)) == 0) {
*output_file = stderr;
return true;
}
// Setup the write mode.
const char* mode = "wb";
if (append_)
mode = "ab";
// Create a new file, which the caller is responsible for closing.
*output_file = base::OpenFile(output_file_path_, mode);
if (*output_file == NULL)
return false;
*must_close = true;
return true;
}
// Print the usage/help text, plus an optional @p message.
bool LoggerApp::Usage(const base::CommandLine* command_line,
const base::StringPiece& message) const {
if (!message.empty()) {
::fwrite(message.data(), 1, message.length(), err());
::fprintf(err(), "\n\n");
}
::fprintf(err(),
kUsageFormatStr,
command_line->GetProgram().BaseName().value().c_str());
return false;
}
} // namespace agent_logger
} // namespace trace
|
//
// HTTPRequestTest.cpp
//
// $Id: //poco/1.4/Net/testsuite/src/HTTPRequestTest.cpp#4 $
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "HTTPRequestTest.h"
#include "Poco/CppUnit/TestCaller.h"
#include "Poco/CppUnit/TestSuite.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/NetException.h"
#include <sstream>
using Poco::Net::HTTPRequest;
using Poco::Net::HTTPMessage;
using Poco::Net::MessageException;
using Poco::Net::NameValueCollection;
HTTPRequestTest::HTTPRequestTest(const std::string& name): CppUnit::TestCase(name)
{
}
HTTPRequestTest::~HTTPRequestTest()
{
}
void HTTPRequestTest::testWrite1()
{
HTTPRequest request;
std::ostringstream ostr;
request.write(ostr);
std::string s = ostr.str();
assert (s == "GET / HTTP/1.0\r\n\r\n");
}
void HTTPRequestTest::testWrite2()
{
HTTPRequest request(HTTPRequest::HTTP_HEAD, "/index.html", HTTPMessage::HTTP_1_1);
request.setHost("localhost", 80);
request.setKeepAlive(true);
request.set("User-Agent", "Poco");
std::ostringstream ostr;
request.write(ostr);
std::string s = ostr.str();
assert (s == "HEAD /index.html HTTP/1.1\r\nHost: localhost\r\nConnection: Keep-Alive\r\nUser-Agent: Poco\r\n\r\n");
}
void HTTPRequestTest::testWrite3()
{
HTTPRequest request(HTTPRequest::HTTP_POST, "/test.cgi", HTTPMessage::HTTP_1_1);
request.setHost("localhost", 8000);
request.setKeepAlive(false);
request.set("User-Agent", "Poco");
request.setContentLength(100);
request.setContentType("text/plain");
std::ostringstream ostr;
request.write(ostr);
std::string s = ostr.str();
assert (s == "POST /test.cgi HTTP/1.1\r\nHost: localhost:8000\r\nConnection: Close\r\nUser-Agent: Poco\r\nContent-Length: 100\r\nContent-Type: text/plain\r\n\r\n");
}
void HTTPRequestTest::testWrite4()
{
HTTPRequest request(HTTPRequest::HTTP_HEAD, "/index.html", HTTPMessage::HTTP_1_1);
request.setHost("fe80::1", 88);
request.setKeepAlive(true);
request.set("User-Agent", "Poco");
std::ostringstream ostr;
request.write(ostr);
std::string s = ostr.str();
assert (s == "HEAD /index.html HTTP/1.1\r\nHost: [fe80::1]:88\r\nConnection: Keep-Alive\r\nUser-Agent: Poco\r\n\r\n");
}
void HTTPRequestTest::testRead1()
{
std::string s("GET / HTTP/1.0\r\n\r\n");
std::istringstream istr(s);
HTTPRequest request;
request.read(istr);
assert (request.getMethod() == HTTPRequest::HTTP_GET);
assert (request.getURI() == "/");
assert (request.getVersion() == HTTPMessage::HTTP_1_0);
assert (request.empty());
assert (istr.get() == -1);
}
void HTTPRequestTest::testRead2()
{
std::string s("HEAD /index.html HTTP/1.1\r\nConnection: Keep-Alive\r\nHost: localhost\r\nUser-Agent: Poco\r\n\r\n");
std::istringstream istr(s);
HTTPRequest request;
request.read(istr);
assert (request.getMethod() == HTTPRequest::HTTP_HEAD);
assert (request.getURI() == "/index.html");
assert (request.getVersion() == HTTPMessage::HTTP_1_1);
assert (request.size() == 3);
assert (request["Connection"] == "Keep-Alive");
assert (request["Host"] == "localhost");
assert (request["User-Agent"] == "Poco");
assert (istr.get() == -1);
}
void HTTPRequestTest::testRead3()
{
std::string s("POST /test.cgi HTTP/1.1\r\nConnection: Close\r\nContent-Length: 100\r\nContent-Type: text/plain\r\nHost: localhost:8000\r\nUser-Agent: Poco\r\n\r\n");
std::istringstream istr(s);
HTTPRequest request;
request.read(istr);
assert (request.getMethod() == HTTPRequest::HTTP_POST);
assert (request.getURI() == "/test.cgi");
assert (request.getVersion() == HTTPMessage::HTTP_1_1);
assert (request.size() == 5);
assert (request["Connection"] == "Close");
assert (request["Host"] == "localhost:8000");
assert (request["User-Agent"] == "Poco");
assert (request.getContentType() == "text/plain");
assert (request.getContentLength() == 100);
assert (istr.get() == -1);
}
void HTTPRequestTest::testRead4()
{
std::string s("POST /test.cgi HTTP/1.1\r\nConnection: Close\r\nContent-Length: 100 \r\nContent-Type: text/plain\r\nHost: localhost:8000\r\nUser-Agent: Poco\r\n\r\n");
std::istringstream istr(s);
HTTPRequest request;
request.read(istr);
assert (request.getMethod() == HTTPRequest::HTTP_POST);
assert (request.getURI() == "/test.cgi");
assert (request.getVersion() == HTTPMessage::HTTP_1_1);
assert (request.size() == 5);
assert (request["Connection"] == "Close");
assert (request["Host"] == "localhost:8000");
assert (request["User-Agent"] == "Poco");
assert (request.getContentType() == "text/plain");
assert (request.getContentLength() == 100);
assert (istr.get() == -1);
}
void HTTPRequestTest::testInvalid1()
{
std::string s(256, 'x');
std::istringstream istr(s);
HTTPRequest request;
try
{
request.read(istr);
fail("inavalid request - must throw");
}
catch (MessageException&)
{
}
}
void HTTPRequestTest::testInvalid2()
{
std::string s("GET ");
s.append(8000, 'x');
s.append("HTTP/1.0");
std::istringstream istr(s);
HTTPRequest request;
try
{
request.read(istr);
fail("inavalid request - must throw");
}
catch (MessageException&)
{
}
}
void HTTPRequestTest::testInvalid3()
{
std::string s("GET / HTTP/1.10");
std::istringstream istr(s);
HTTPRequest request;
try
{
request.read(istr);
fail("inavalid request - must throw");
}
catch (MessageException&)
{
}
}
void HTTPRequestTest::testCookies()
{
HTTPRequest request1;
NameValueCollection cookies1;
cookies1.add("cookie1", "value1");
request1.setCookies(cookies1);
assert (request1["Cookie"] == "cookie1=value1");
HTTPRequest request2;
NameValueCollection cookies2;
cookies2.add("cookie2", "value2");
cookies2.add("cookie3", "value3");
request2.setCookies(cookies2);
assert (request2["Cookie"] == "cookie2=value2; cookie3=value3");
request1.setCookies(cookies2);
NameValueCollection cookies3;
request1.getCookies(cookies3);
assert (cookies3.size() == 3);
assert (cookies3["cookie1"] == "value1");
assert (cookies3["cookie2"] == "value2");
assert (cookies3["cookie3"] == "value3");
HTTPRequest request3;
request3.add("Cookie", "cookie1=value1");
request3.add("cookie", "cookie2=value2");
NameValueCollection cookies4;
request3.getCookies(cookies4);
assert (cookies4.size() == 2);
assert (cookies4["cookie1"] == "value1");
assert (cookies4["cookie2"] == "value2");
}
void HTTPRequestTest::setUp()
{
}
void HTTPRequestTest::tearDown()
{
}
CppUnit::Test* HTTPRequestTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HTTPRequestTest");
CppUnit_addTest(pSuite, HTTPRequestTest, testWrite1);
CppUnit_addTest(pSuite, HTTPRequestTest, testWrite2);
CppUnit_addTest(pSuite, HTTPRequestTest, testWrite3);
CppUnit_addTest(pSuite, HTTPRequestTest, testWrite4);
CppUnit_addTest(pSuite, HTTPRequestTest, testRead1);
CppUnit_addTest(pSuite, HTTPRequestTest, testRead2);
CppUnit_addTest(pSuite, HTTPRequestTest, testRead3);
CppUnit_addTest(pSuite, HTTPRequestTest, testRead4);
CppUnit_addTest(pSuite, HTTPRequestTest, testInvalid1);
CppUnit_addTest(pSuite, HTTPRequestTest, testInvalid2);
CppUnit_addTest(pSuite, HTTPRequestTest, testInvalid3);
CppUnit_addTest(pSuite, HTTPRequestTest, testCookies);
return pSuite;
}
|
#include "Gc.h"
#include "ChannelTableStruct.h"
#include "RollbackManager.h"
#include "HashTable.h"
unsigned long ___HashCodeInt(const int key)
{
return key;
}
bool ___EqualInt(const int a, const int b)
{
return a == b;
}
typedef SimpleHashTable<int, int, 1024, ___HashCodeInt, ___EqualInt> HashType;
using namespace SharedChannelTable;
struct GcSession
{
HashType hashTable;
};
static int CheckPid(int pid)
{
HANDLE processHandle = ::OpenProcess(SYNCHRONIZE, FALSE, pid);
if (processHandle == NULL)
{
return 0;
}
else
{
::CloseHandle(processHandle);
return 1;
}
}
static void RecordPid(int pid, HashType * hashTable)
{
if (hashTable->Find(pid) == 0)
{
hashTable->Insert(pid, ::CheckPid(pid));
}
}
void Gc(ChannelTableItem * item, GcSession * session)
{
int pidPlotter = 0;
int pidViewer = 0;
int type = -1;
while(1)
{
bool bDone = true;
SharedChannelTable::PreTableOperation(item);
pidPlotter = item->channelInfo.pidPlotter;
pidViewer = item->channelInfo.pidViewer;
type = item->channelInfo.type;
SharedChannelTable::PostTableOperation(item);
if (type == -1)
break;
RecordPid(pidPlotter, &session->hashTable);
RecordPid(pidViewer, &session->hashTable);
SharedChannelTable::PreTableOperation(item);
if (pidPlotter != item->channelInfo.pidPlotter || pidViewer != item->channelInfo.pidViewer)
{
bDone = false;
}
else
{
if (session->hashTable.Find(pidPlotter)->value == 0)
{
item->channelInfo.pidPlotter = 0;
}
if (session->hashTable.Find(pidViewer)->value == 0)
{
item->channelInfo.pidViewer = 0;
}
if (item->channelInfo.pidPlotter == 0 && item->channelInfo.pidViewer == 0 && item->channelRWInfo.readableSize == 0)
{
// reset rw
// gc mem
item->channelInfo.type = -1;
}
}
SharedChannelTable::PostTableOperation(item);
if (bDone)
break;
}
}
|
#include "claimtrie.h"
#include "coins.h"
#include "hash.h"
#include <boost/scoped_ptr.hpp>
#include <iostream>
#include <algorithm>
std::vector<unsigned char> heightToVch(int n)
{
std::vector<unsigned char> vchHeight;
vchHeight.resize(8);
vchHeight[0] = 0;
vchHeight[1] = 0;
vchHeight[2] = 0;
vchHeight[3] = 0;
vchHeight[4] = n >> 24;
vchHeight[5] = n >> 16;
vchHeight[6] = n >> 8;
vchHeight[7] = n;
return vchHeight;
}
uint256 getValueHash(COutPoint outPoint, int nHeightOfLastTakeover)
{
CHash256 txHasher;
txHasher.Write(outPoint.hash.begin(), outPoint.hash.size());
std::vector<unsigned char> vchtxHash(txHasher.OUTPUT_SIZE);
txHasher.Finalize(&(vchtxHash[0]));
CHash256 nOutHasher;
std::stringstream ss;
ss << outPoint.n;
std::string snOut = ss.str();
nOutHasher.Write((unsigned char*) snOut.data(), snOut.size());
std::vector<unsigned char> vchnOutHash(nOutHasher.OUTPUT_SIZE);
nOutHasher.Finalize(&(vchnOutHash[0]));
CHash256 takeoverHasher;
std::vector<unsigned char> vchTakeoverHeightToHash = heightToVch(nHeightOfLastTakeover);
takeoverHasher.Write(vchTakeoverHeightToHash.data(), vchTakeoverHeightToHash.size());
std::vector<unsigned char> vchTakeoverHash(takeoverHasher.OUTPUT_SIZE);
takeoverHasher.Finalize(&(vchTakeoverHash[0]));
CHash256 hasher;
hasher.Write(vchtxHash.data(), vchtxHash.size());
hasher.Write(vchnOutHash.data(), vchnOutHash.size());
hasher.Write(vchTakeoverHash.data(), vchTakeoverHash.size());
std::vector<unsigned char> vchHash(hasher.OUTPUT_SIZE);
hasher.Finalize(&(vchHash[0]));
uint256 valueHash(vchHash);
return valueHash;
}
bool CClaimTrieNode::insertClaim(CClaimValue claim)
{
LogPrintf("%s: Inserting %s:%d (amount: %d) into the claim trie\n", __func__, claim.outPoint.hash.ToString(), claim.outPoint.n, claim.nAmount);
claims.push_back(claim);
return true;
}
bool CClaimTrieNode::removeClaim(const COutPoint& outPoint, CClaimValue& claim)
{
LogPrintf("%s: Removing txid: %s, nOut: %d from the claim trie\n", __func__, outPoint.hash.ToString(), outPoint.n);
std::vector<CClaimValue>::iterator itClaims;
for (itClaims = claims.begin(); itClaims != claims.end(); ++itClaims)
{
if (itClaims->outPoint == outPoint)
{
std::swap(claim, *itClaims);
break;
}
}
if (itClaims != claims.end())
{
claims.erase(itClaims);
}
else
{
LogPrintf("CClaimTrieNode::%s() : asked to remove a claim that doesn't exist\n", __func__);
LogPrintf("CClaimTrieNode::%s() : claims that do exist:\n", __func__);
for (unsigned int i = 0; i < claims.size(); i++)
{
LogPrintf("\ttxhash: %s, nOut: %d:\n", claims[i].outPoint.hash.ToString(), claims[i].outPoint.n);
}
return false;
}
return true;
}
bool CClaimTrieNode::getBestClaim(CClaimValue& claim) const
{
if (claims.empty())
{
return false;
}
else
{
claim = claims.front();
return true;
}
}
bool CClaimTrieNode::haveClaim(const COutPoint& outPoint) const
{
for (std::vector<CClaimValue>::const_iterator itclaim = claims.begin(); itclaim != claims.end(); ++itclaim)
{
if (itclaim->outPoint == outPoint)
return true;
}
return false;
}
void CClaimTrieNode::reorderClaims(supportMapEntryType& supports)
{
std::vector<CClaimValue>::iterator itclaim;
for (itclaim = claims.begin(); itclaim != claims.end(); ++itclaim)
{
itclaim->nEffectiveAmount = itclaim->nAmount;
}
for (supportMapEntryType::iterator itsupport = supports.begin(); itsupport != supports.end(); ++itsupport)
{
for (itclaim = claims.begin(); itclaim != claims.end(); ++itclaim)
{
if (itsupport->supportedClaimId == itclaim->claimId)
{
itclaim->nEffectiveAmount += itsupport->nAmount;
break;
}
}
}
std::make_heap(claims.begin(), claims.end());
}
uint256 CClaimTrie::getMerkleHash()
{
return root.hash;
}
bool CClaimTrie::empty() const
{
return root.empty();
}
template<typename K> bool CClaimTrie::keyTypeEmpty(char keyType, K& dummy) const
{
boost::scoped_ptr<CDBIterator> pcursor(const_cast<CDBWrapper*>(&db)->NewIterator());
pcursor->SeekToFirst();
while (pcursor->Valid())
{
std::pair<char, K> key;
if (pcursor->GetKey(key))
{
if (key.first == keyType)
{
return false;
}
}
else
{
break;
}
pcursor->Next();
}
return true;
}
bool CClaimTrie::queueEmpty() const
{
for (claimQueueType::const_iterator itRow = dirtyQueueRows.begin(); itRow != dirtyQueueRows.end(); ++itRow)
{
if (!itRow->second.empty())
return false;
}
int dummy;
return keyTypeEmpty(CLAIM_QUEUE_ROW, dummy);
}
bool CClaimTrie::expirationQueueEmpty() const
{
for (expirationQueueType::const_iterator itRow = dirtyExpirationQueueRows.begin(); itRow != dirtyExpirationQueueRows.end(); ++itRow)
{
if (!itRow->second.empty())
return false;
}
int dummy;
return keyTypeEmpty(EXP_QUEUE_ROW, dummy);
}
bool CClaimTrie::supportEmpty() const
{
for (supportMapType::const_iterator itNode = dirtySupportNodes.begin(); itNode != dirtySupportNodes.end(); ++itNode)
{
if (!itNode->second.empty())
return false;
}
std::string dummy;
return keyTypeEmpty(SUPPORT, dummy);
}
bool CClaimTrie::supportQueueEmpty() const
{
for (supportQueueType::const_iterator itRow = dirtySupportQueueRows.begin(); itRow != dirtySupportQueueRows.end(); ++itRow)
{
if (!itRow->second.empty())
return false;
}
int dummy;
return keyTypeEmpty(SUPPORT_QUEUE_ROW, dummy);
}
void CClaimTrie::setExpirationTime(int t)
{
nExpirationTime = t;
LogPrintf("%s: Expiration time is now %d\n", __func__, nExpirationTime);
}
void CClaimTrie::clear()
{
clear(&root);
}
void CClaimTrie::clear(CClaimTrieNode* current)
{
for (nodeMapType::const_iterator itchildren = current->children.begin(); itchildren != current->children.end(); ++itchildren)
{
clear(itchildren->second);
delete itchildren->second;
}
}
bool CClaimTrie::haveClaim(const std::string& name, const COutPoint& outPoint) const
{
const CClaimTrieNode* current = &root;
for (std::string::const_iterator itname = name.begin(); itname != name.end(); ++itname)
{
nodeMapType::const_iterator itchildren = current->children.find(*itname);
if (itchildren == current->children.end())
return false;
current = itchildren->second;
}
return current->haveClaim(outPoint);
}
bool CClaimTrie::haveSupport(const std::string& name, const COutPoint& outPoint) const
{
supportMapEntryType node;
if (!getSupportNode(name, node))
{
return false;
}
for (supportMapEntryType::const_iterator itnode = node.begin(); itnode != node.end(); ++itnode)
{
if (itnode->outPoint == outPoint)
return true;
}
return false;
}
bool CClaimTrie::haveClaimInQueue(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight) const
{
queueNameRowType nameRow;
if (!getQueueNameRow(name, nameRow))
{
return false;
}
queueNameRowType::const_iterator itNameRow;
for (itNameRow = nameRow.begin(); itNameRow != nameRow.end(); ++itNameRow)
{
if (itNameRow->outPoint == outPoint)
{
nValidAtHeight = itNameRow->nHeight;
break;
}
}
if (itNameRow == nameRow.end())
{
return false;
}
claimQueueRowType row;
if (getQueueRow(nValidAtHeight, row))
{
for (claimQueueRowType::const_iterator itRow = row.begin(); itRow != row.end(); ++itRow)
{
if (itRow->first == name && itRow->second.outPoint == outPoint)
{
if (itRow->second.nValidAtHeight != nValidAtHeight)
{
LogPrintf("%s: An inconsistency was found in the claim queue. Please report this to the developers:\nDifferent nValidAtHeight between named queue and height queue\n: name: %s, txid: %s, nOut: %d, nValidAtHeight in named queue: %d, nValidAtHeight in height queue: %d current height: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nValidAtHeight, itRow->second.nValidAtHeight, nCurrentHeight);
}
return true;
}
}
}
LogPrintf("%s: An inconsistency was found in the claim queue. Please report this to the developers:\nFound in named queue but not in height queue: name: %s, txid: %s, nOut: %d, nValidAtHeight: %d, current height: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nValidAtHeight, nCurrentHeight);
return false;
}
bool CClaimTrie::haveSupportInQueue(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight) const
{
queueNameRowType nameRow;
if (!getSupportQueueNameRow(name, nameRow))
{
return false;
}
queueNameRowType::const_iterator itNameRow;
for (itNameRow = nameRow.begin(); itNameRow != nameRow.end(); ++itNameRow)
{
if (itNameRow->outPoint == outPoint)
{
nValidAtHeight = itNameRow->nHeight;
break;
}
}
if (itNameRow == nameRow.end())
{
return false;
}
supportQueueRowType row;
if (getSupportQueueRow(nValidAtHeight, row))
{
for (supportQueueRowType::const_iterator itRow = row.begin(); itRow != row.end(); ++itRow)
{
if (itRow->first == name && itRow->second.outPoint == outPoint)
{
if (itRow->second.nValidAtHeight != nValidAtHeight)
{
LogPrintf("%s: An inconsistency was found in the support queue. Please report this to the developers:\nDifferent nValidAtHeight between named queue and height queue\n: name: %s, txid: %s, nOut: %d, nValidAtHeight in named queue: %d, nValidAtHeight in height queue: %d current height: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nValidAtHeight, itRow->second.nValidAtHeight, nCurrentHeight);
}
return true;
}
}
}
LogPrintf("%s: An inconsistency was found in the claim queue. Please report this to the developers:\nFound in named queue but not in height queue: name: %s, txid: %s, nOut: %d, nValidAtHeight: %d, current height: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nValidAtHeight, nCurrentHeight);
return false;
}
unsigned int CClaimTrie::getTotalNamesInTrie() const
{
if (empty())
return 0;
const CClaimTrieNode* current = &root;
return getTotalNamesRecursive(current);
}
unsigned int CClaimTrie::getTotalNamesRecursive(const CClaimTrieNode* current) const
{
unsigned int names_in_subtrie = 0;
if (!(current->claims.empty()))
names_in_subtrie += 1;
for (nodeMapType::const_iterator it = current->children.begin(); it != current->children.end(); ++it)
{
names_in_subtrie += getTotalNamesRecursive(it->second);
}
return names_in_subtrie;
}
unsigned int CClaimTrie::getTotalClaimsInTrie() const
{
if (empty())
return 0;
const CClaimTrieNode* current = &root;
return getTotalClaimsRecursive(current);
}
unsigned int CClaimTrie::getTotalClaimsRecursive(const CClaimTrieNode* current) const
{
unsigned int claims_in_subtrie = current->claims.size();
for (nodeMapType::const_iterator it = current->children.begin(); it != current->children.end(); ++it)
{
claims_in_subtrie += getTotalClaimsRecursive(it->second);
}
return claims_in_subtrie;
}
CAmount CClaimTrie::getTotalValueOfClaimsInTrie(bool fControllingOnly) const
{
if (empty())
return 0;
const CClaimTrieNode* current = &root;
return getTotalValueOfClaimsRecursive(current, fControllingOnly);
}
CAmount CClaimTrie::getTotalValueOfClaimsRecursive(const CClaimTrieNode* current, bool fControllingOnly) const
{
CAmount value_in_subtrie = 0;
for (std::vector<CClaimValue>::const_iterator itclaim = current->claims.begin(); itclaim != current->claims.end(); ++itclaim)
{
value_in_subtrie += itclaim->nAmount;
if (fControllingOnly)
break;
}
for (nodeMapType::const_iterator itchild = current->children.begin(); itchild != current->children.end(); ++itchild)
{
value_in_subtrie += getTotalValueOfClaimsRecursive(itchild->second, fControllingOnly);
}
return value_in_subtrie;
}
bool CClaimTrie::recursiveFlattenTrie(const std::string& name, const CClaimTrieNode* current, std::vector<namedNodeType>& nodes) const
{
namedNodeType node(name, *current);
nodes.push_back(node);
for (nodeMapType::const_iterator it = current->children.begin(); it != current->children.end(); ++it)
{
std::stringstream ss;
ss << name << it->first;
if (!recursiveFlattenTrie(ss.str(), it->second, nodes))
return false;
}
return true;
}
std::vector<namedNodeType> CClaimTrie::flattenTrie() const
{
std::vector<namedNodeType> nodes;
if (!recursiveFlattenTrie("", &root, nodes))
LogPrintf("%s: Something went wrong flattening the trie", __func__);
return nodes;
}
const CClaimTrieNode* CClaimTrie::getNodeForName(const std::string& name) const
{
const CClaimTrieNode* current = &root;
for (std::string::const_iterator itname = name.begin(); itname != name.end(); ++itname)
{
nodeMapType::const_iterator itchildren = current->children.find(*itname);
if (itchildren == current->children.end())
return NULL;
current = itchildren->second;
}
return current;
}
bool CClaimTrie::getInfoForName(const std::string& name, CClaimValue& claim) const
{
const CClaimTrieNode* current = getNodeForName(name);
if (current)
{
return current->getBestClaim(claim);
}
return false;
}
bool CClaimTrie::getLastTakeoverForName(const std::string& name, int& lastTakeoverHeight) const
{
const CClaimTrieNode* current = getNodeForName(name);
if (current && !current->claims.empty())
{
lastTakeoverHeight = current->nHeightOfLastTakeover;
return true;
}
return false;
}
claimsForNameType CClaimTrie::getClaimsForName(const std::string& name) const
{
std::vector<CClaimValue> claims;
std::vector<CSupportValue> supports;
int nLastTakeoverHeight = 0;
const CClaimTrieNode* current = getNodeForName(name);
if (current)
{
if (!current->claims.empty())
{
nLastTakeoverHeight = current->nHeightOfLastTakeover;
}
for (std::vector<CClaimValue>::const_iterator itClaims = current->claims.begin(); itClaims != current->claims.end(); ++itClaims)
{
claims.push_back(*itClaims);
}
}
supportMapEntryType supportNode;
if (getSupportNode(name, supportNode))
{
for (std::vector<CSupportValue>::const_iterator itSupports = supportNode.begin(); itSupports != supportNode.end(); ++itSupports)
{
supports.push_back(*itSupports);
}
}
queueNameRowType namedClaimRow;
if (getQueueNameRow(name, namedClaimRow))
{
for (queueNameRowType::const_iterator itClaimsForName = namedClaimRow.begin(); itClaimsForName != namedClaimRow.end(); ++itClaimsForName)
{
claimQueueRowType claimRow;
if (getQueueRow(itClaimsForName->nHeight, claimRow))
{
for (claimQueueRowType::const_iterator itClaimRow = claimRow.begin(); itClaimRow != claimRow.end(); ++itClaimRow)
{
if (itClaimRow->first == name && itClaimRow->second.outPoint == itClaimsForName->outPoint)
{
claims.push_back(itClaimRow->second);
break;
}
}
}
}
}
queueNameRowType namedSupportRow;
if (getSupportQueueNameRow(name, namedSupportRow))
{
for (queueNameRowType::const_iterator itSupportsForName = namedSupportRow.begin(); itSupportsForName != namedSupportRow.end(); ++itSupportsForName)
{
supportQueueRowType supportRow;
if (getSupportQueueRow(itSupportsForName->nHeight, supportRow))
{
for (supportQueueRowType::const_iterator itSupportRow = supportRow.begin(); itSupportRow != supportRow.end(); ++itSupportRow)
{
if (itSupportRow->first == name && itSupportRow->second.outPoint == itSupportsForName->outPoint)
{
supports.push_back(itSupportRow->second);
break;
}
}
}
}
}
claimsForNameType allClaims(claims, supports, nLastTakeoverHeight);
return allClaims;
}
//return effective amount from claim, retuns 0 if claim is not found
CAmount CClaimTrie::getEffectiveAmountForClaim(const std::string& name, uint160 claimId) const
{
std::vector<CSupportValue> supports;
return getEffectiveAmountForClaimWithSupports(name, claimId, supports);
}
//return effective amount from claim and the supports used as inputs, retuns 0 if claim is not found
CAmount CClaimTrie::getEffectiveAmountForClaimWithSupports(const std::string& name, uint160 claimId,
std::vector<CSupportValue>& supports) const
{
claimsForNameType claims = getClaimsForName(name);
CAmount effectiveAmount = 0;
bool claim_found = false;
for (std::vector<CClaimValue>::iterator it=claims.claims.begin(); it!=claims.claims.end(); ++it)
{
if (it->claimId == claimId && it->nValidAtHeight < nCurrentHeight)
{
effectiveAmount += it->nAmount;
claim_found = true;
break;
}
}
if (!claim_found)
return effectiveAmount;
for (std::vector<CSupportValue>::iterator it=claims.supports.begin(); it!=claims.supports.end(); ++it)
{
if (it->supportedClaimId == claimId && it->nValidAtHeight < nCurrentHeight)
{
effectiveAmount += it->nAmount;
supports.push_back(*it);
}
}
return effectiveAmount;
}
bool CClaimTrie::checkConsistency() const
{
if (empty())
return true;
return recursiveCheckConsistency(&root);
}
bool CClaimTrie::recursiveCheckConsistency(const CClaimTrieNode* node) const
{
std::vector<unsigned char> vchToHash;
for (nodeMapType::const_iterator it = node->children.begin(); it != node->children.end(); ++it)
{
if (recursiveCheckConsistency(it->second))
{
vchToHash.push_back(it->first);
vchToHash.insert(vchToHash.end(), it->second->hash.begin(), it->second->hash.end());
}
else
return false;
}
CClaimValue claim;
bool hasClaim = node->getBestClaim(claim);
if (hasClaim)
{
uint256 valueHash = getValueHash(claim.outPoint, node->nHeightOfLastTakeover);
vchToHash.insert(vchToHash.end(), valueHash.begin(), valueHash.end());
}
CHash256 hasher;
std::vector<unsigned char> vchHash(hasher.OUTPUT_SIZE);
hasher.Write(vchToHash.data(), vchToHash.size());
hasher.Finalize(&(vchHash[0]));
uint256 calculatedHash(vchHash);
return calculatedHash == node->hash;
}
void CClaimTrie::addToClaimIndex(const std::string& name, const CClaimValue& claim)
{
CClaimIndexElement element = { name, claim };
LogPrintf("%s: ClaimIndex[%s] updated %s\n", __func__, claim.claimId.GetHex(), name);
db.Write(std::make_pair(CLAIM_BY_ID, claim.claimId), element);
}
void CClaimTrie::removeFromClaimIndex(const CClaimValue& claim)
{
LogPrintf("%s: ClaimIndex[%s] removed\n", __func__, claim.claimId.GetHex());
db.Erase(std::make_pair(CLAIM_BY_ID, claim.claimId));
}
bool CClaimTrie::getClaimById(const uint160 claimId, std::string& name, CClaimValue& claim) const
{
CClaimIndexElement element;
if (db.Read(std::make_pair(CLAIM_BY_ID, claimId), element))
{
if (element.claim.claimId == claimId) {
name = element.name;
claim = element.claim;
return true;
} else {
LogPrintf("%s: ClaimIndex[%s] returned unmatched claimId %s when looking for %s\n",
__func__, claimId.GetHex(), element.claim.claimId.GetHex(), name);
}
}
return false;
}
bool CClaimTrie::getQueueRow(int nHeight, claimQueueRowType& row) const
{
claimQueueType::const_iterator itQueueRow = dirtyQueueRows.find(nHeight);
if (itQueueRow != dirtyQueueRows.end())
{
row = itQueueRow->second;
return true;
}
return db.Read(std::make_pair(CLAIM_QUEUE_ROW, nHeight), row);
}
bool CClaimTrie::getQueueNameRow(const std::string& name, queueNameRowType& row) const
{
queueNameType::const_iterator itQueueNameRow = dirtyQueueNameRows.find(name);
if (itQueueNameRow != dirtyQueueNameRows.end())
{
row = itQueueNameRow->second;
return true;
}
return db.Read(std::make_pair(CLAIM_QUEUE_NAME_ROW, name), row);
}
bool CClaimTrie::getExpirationQueueRow(int nHeight, expirationQueueRowType& row) const
{
expirationQueueType::const_iterator itQueueRow = dirtyExpirationQueueRows.find(nHeight);
if (itQueueRow != dirtyExpirationQueueRows.end())
{
row = itQueueRow->second;
return true;
}
return db.Read(std::make_pair(EXP_QUEUE_ROW, nHeight), row);
}
void CClaimTrie::updateQueueRow(int nHeight, claimQueueRowType& row)
{
claimQueueType::iterator itQueueRow = dirtyQueueRows.find(nHeight);
if (itQueueRow == dirtyQueueRows.end())
{
claimQueueRowType newRow;
std::pair<claimQueueType::iterator, bool> ret;
ret = dirtyQueueRows.insert(std::pair<int, claimQueueRowType >(nHeight, newRow));
assert(ret.second);
itQueueRow = ret.first;
}
itQueueRow->second.swap(row);
}
void CClaimTrie::updateQueueNameRow(const std::string& name, queueNameRowType& row)
{
queueNameType::iterator itQueueRow = dirtyQueueNameRows.find(name);
if (itQueueRow == dirtyQueueNameRows.end())
{
queueNameRowType newRow;
std::pair<queueNameType::iterator, bool> ret;
ret = dirtyQueueNameRows.insert(std::pair<std::string, queueNameRowType>(name, newRow));
assert(ret.second);
itQueueRow = ret.first;
}
itQueueRow->second.swap(row);
}
void CClaimTrie::updateExpirationRow(int nHeight, expirationQueueRowType& row)
{
expirationQueueType::iterator itQueueRow = dirtyExpirationQueueRows.find(nHeight);
if (itQueueRow == dirtyExpirationQueueRows.end())
{
expirationQueueRowType newRow;
std::pair<expirationQueueType::iterator, bool> ret;
ret = dirtyExpirationQueueRows.insert(std::pair<int, expirationQueueRowType >(nHeight, newRow));
assert(ret.second);
itQueueRow = ret.first;
}
itQueueRow->second.swap(row);
}
void CClaimTrie::updateSupportMap(const std::string& name, supportMapEntryType& node)
{
supportMapType::iterator itNode = dirtySupportNodes.find(name);
if (itNode == dirtySupportNodes.end())
{
supportMapEntryType newNode;
std::pair<supportMapType::iterator, bool> ret;
ret = dirtySupportNodes.insert(std::pair<std::string, supportMapEntryType>(name, newNode));
assert(ret.second);
itNode = ret.first;
}
itNode->second.swap(node);
}
void CClaimTrie::updateSupportQueue(int nHeight, supportQueueRowType& row)
{
supportQueueType::iterator itQueueRow = dirtySupportQueueRows.find(nHeight);
if (itQueueRow == dirtySupportQueueRows.end())
{
supportQueueRowType newRow;
std::pair<supportQueueType::iterator, bool> ret;
ret = dirtySupportQueueRows.insert(std::pair<int, supportQueueRowType >(nHeight, newRow));
assert(ret.second);
itQueueRow = ret.first;
}
itQueueRow->second.swap(row);
}
void CClaimTrie::updateSupportNameQueue(const std::string& name, queueNameRowType& row)
{
queueNameType::iterator itQueueRow = dirtySupportQueueNameRows.find(name);
if (itQueueRow == dirtySupportQueueNameRows.end())
{
queueNameRowType newRow;
std::pair<queueNameType::iterator, bool> ret;
ret = dirtySupportQueueNameRows.insert(std::pair<std::string, queueNameRowType>(name, newRow));
assert(ret.second);
itQueueRow = ret.first;
}
itQueueRow->second.swap(row);
}
void CClaimTrie::updateSupportExpirationQueue(int nHeight, expirationQueueRowType& row)
{
expirationQueueType::iterator itQueueRow = dirtySupportExpirationQueueRows.find(nHeight);
if (itQueueRow == dirtySupportExpirationQueueRows.end())
{
expirationQueueRowType newRow;
std::pair<expirationQueueType::iterator, bool> ret;
ret = dirtySupportExpirationQueueRows.insert(std::pair<int, expirationQueueRowType >(nHeight, newRow));
assert(ret.second);
itQueueRow = ret.first;
}
itQueueRow->second.swap(row);
}
bool CClaimTrie::getSupportNode(std::string name, supportMapEntryType& node) const
{
supportMapType::const_iterator itNode = dirtySupportNodes.find(name);
if (itNode != dirtySupportNodes.end())
{
node = itNode->second;
return true;
}
return db.Read(std::make_pair(SUPPORT, name), node);
}
bool CClaimTrie::getSupportQueueRow(int nHeight, supportQueueRowType& row) const
{
supportQueueType::const_iterator itQueueRow = dirtySupportQueueRows.find(nHeight);
if (itQueueRow != dirtySupportQueueRows.end())
{
row = itQueueRow->second;
return true;
}
return db.Read(std::make_pair(SUPPORT_QUEUE_ROW, nHeight), row);
}
bool CClaimTrie::getSupportQueueNameRow(const std::string& name, queueNameRowType& row) const
{
queueNameType::const_iterator itQueueNameRow = dirtySupportQueueNameRows.find(name);
if (itQueueNameRow != dirtySupportQueueNameRows.end())
{
row = itQueueNameRow->second;
return true;
}
return db.Read(std::make_pair(SUPPORT_QUEUE_NAME_ROW, name), row);
}
bool CClaimTrie::getSupportExpirationQueueRow(int nHeight, expirationQueueRowType& row) const
{
expirationQueueType::const_iterator itQueueRow = dirtySupportExpirationQueueRows.find(nHeight);
if (itQueueRow != dirtySupportExpirationQueueRows.end())
{
row = itQueueRow->second;
return true;
}
return db.Read(std::make_pair(SUPPORT_EXP_QUEUE_ROW, nHeight), row);
}
bool CClaimTrie::update(nodeCacheType& cache, hashMapType& hashes, std::map<std::string, int>& takeoverHeights, const uint256& hashBlockIn, claimQueueType& queueCache, queueNameType& queueNameCache, expirationQueueType& expirationQueueCache, int nNewHeight, supportMapType& supportCache, supportQueueType& supportQueueCache, queueNameType& supportQueueNameCache, expirationQueueType& supportExpirationQueueCache)
{
for (nodeCacheType::iterator itcache = cache.begin(); itcache != cache.end(); ++itcache)
{
if (!updateName(itcache->first, itcache->second))
{
LogPrintf("%s: Failed to update name for:%s\n", __func__, itcache->first);
return false;
}
}
for (hashMapType::iterator ithash = hashes.begin(); ithash != hashes.end(); ++ithash)
{
if (!updateHash(ithash->first, ithash->second))
{
LogPrintf("%s: Failed to update hash for:%s\n", __func__, ithash->first);
return false;
}
}
for (std::map<std::string, int>::iterator itheight = takeoverHeights.begin(); itheight != takeoverHeights.end(); ++itheight)
{
if (!updateTakeoverHeight(itheight->first, itheight->second))
{
LogPrintf("%s: Failed to update takeover height for:%s\n", __func__, itheight->first);
return false;
}
}
for (claimQueueType::iterator itQueueCacheRow = queueCache.begin(); itQueueCacheRow != queueCache.end(); ++itQueueCacheRow)
{
updateQueueRow(itQueueCacheRow->first, itQueueCacheRow->second);
}
for (queueNameType::iterator itQueueNameCacheRow = queueNameCache.begin(); itQueueNameCacheRow != queueNameCache.end(); ++itQueueNameCacheRow)
{
updateQueueNameRow(itQueueNameCacheRow->first, itQueueNameCacheRow->second);
}
for (expirationQueueType::iterator itExpirationRow = expirationQueueCache.begin(); itExpirationRow != expirationQueueCache.end(); ++itExpirationRow)
{
updateExpirationRow(itExpirationRow->first, itExpirationRow->second);
}
for (supportMapType::iterator itSupportCache = supportCache.begin(); itSupportCache != supportCache.end(); ++itSupportCache)
{
updateSupportMap(itSupportCache->first, itSupportCache->second);
}
for (supportQueueType::iterator itSupportQueue = supportQueueCache.begin(); itSupportQueue != supportQueueCache.end(); ++itSupportQueue)
{
updateSupportQueue(itSupportQueue->first, itSupportQueue->second);
}
for (queueNameType::iterator itSupportNameQueue = supportQueueNameCache.begin(); itSupportNameQueue != supportQueueNameCache.end(); ++itSupportNameQueue)
{
updateSupportNameQueue(itSupportNameQueue->first, itSupportNameQueue->second);
}
for (expirationQueueType::iterator itSupportExpirationQueue = supportExpirationQueueCache.begin(); itSupportExpirationQueue != supportExpirationQueueCache.end(); ++itSupportExpirationQueue)
{
updateSupportExpirationQueue(itSupportExpirationQueue->first, itSupportExpirationQueue->second);
}
hashBlock = hashBlockIn;
nCurrentHeight = nNewHeight;
return true;
}
void CClaimTrie::markNodeDirty(const std::string &name, CClaimTrieNode* node)
{
std::pair<nodeCacheType::iterator, bool> ret;
ret = dirtyNodes.insert(std::pair<std::string, CClaimTrieNode*>(name, node));
if (ret.second == false)
ret.first->second = node;
}
bool CClaimTrie::updateName(const std::string &name, CClaimTrieNode* updatedNode)
{
CClaimTrieNode* current = &root;
for (std::string::const_iterator itname = name.begin(); itname != name.end(); ++itname)
{
nodeMapType::iterator itchild = current->children.find(*itname);
if (itchild == current->children.end())
{
if (itname + 1 == name.end())
{
CClaimTrieNode* newNode = new CClaimTrieNode();
current->children[*itname] = newNode;
current = newNode;
}
else
return false;
}
else
{
current = itchild->second;
}
}
assert(current != NULL);
current->claims.swap(updatedNode->claims);
markNodeDirty(name, current);
for (nodeMapType::iterator itchild = current->children.begin(); itchild != current->children.end();)
{
nodeMapType::iterator itupdatechild = updatedNode->children.find(itchild->first);
if (itupdatechild == updatedNode->children.end())
{
// This character has apparently been deleted, so delete
// all descendents from this child.
std::stringstream ss;
ss << name << itchild->first;
std::string newName = ss.str();
if (!recursiveNullify(itchild->second, newName))
return false;
current->children.erase(itchild++);
}
else
++itchild;
}
return true;
}
bool CClaimTrie::recursiveNullify(CClaimTrieNode* node, std::string& name)
{
assert(node != NULL);
for (nodeMapType::iterator itchild = node->children.begin(); itchild != node->children.end(); ++itchild)
{
std::stringstream ss;
ss << name << itchild->first;
std::string newName = ss.str();
if (!recursiveNullify(itchild->second, newName))
return false;
}
node->children.clear();
markNodeDirty(name, NULL);
delete node;
return true;
}
bool CClaimTrie::updateHash(const std::string& name, uint256& hash)
{
CClaimTrieNode* current = &root;
for (std::string::const_iterator itname = name.begin(); itname != name.end(); ++itname)
{
nodeMapType::iterator itchild = current->children.find(*itname);
if (itchild == current->children.end())
return false;
current = itchild->second;
}
assert(current != NULL);
current->hash = hash;
markNodeDirty(name, current);
return true;
}
bool CClaimTrie::updateTakeoverHeight(const std::string& name, int nTakeoverHeight)
{
CClaimTrieNode* current = &root;
for (std::string::const_iterator itname = name.begin(); itname != name.end(); ++itname)
{
nodeMapType::iterator itchild = current->children.find(*itname);
if (itchild == current->children.end())
return false;
current = itchild->second;
}
assert(current != NULL);
current->nHeightOfLastTakeover = nTakeoverHeight;
markNodeDirty(name, current);
return true;
}
void CClaimTrie::BatchWriteNode(CDBBatch& batch, const std::string& name, const CClaimTrieNode* pNode) const
{
if (pNode)
batch.Write(std::make_pair(TRIE_NODE, name), *pNode);
else
batch.Erase(std::make_pair(TRIE_NODE, name));
}
void CClaimTrie::BatchWriteQueueRows(CDBBatch& batch)
{
for (claimQueueType::iterator itQueue = dirtyQueueRows.begin(); itQueue != dirtyQueueRows.end(); ++itQueue)
{
if (itQueue->second.empty())
{
batch.Erase(std::make_pair(CLAIM_QUEUE_ROW, itQueue->first));
}
else
{
batch.Write(std::make_pair(CLAIM_QUEUE_ROW, itQueue->first), itQueue->second);
}
}
}
void CClaimTrie::BatchWriteQueueNameRows(CDBBatch& batch)
{
for (queueNameType::iterator itQueue = dirtyQueueNameRows.begin(); itQueue != dirtyQueueNameRows.end(); ++itQueue)
{
if (itQueue->second.empty())
{
batch.Erase(std::make_pair(CLAIM_QUEUE_NAME_ROW, itQueue->first));
}
else
{
batch.Write(std::make_pair(CLAIM_QUEUE_NAME_ROW, itQueue->first), itQueue->second);
}
}
}
void CClaimTrie::BatchWriteExpirationQueueRows(CDBBatch& batch)
{
for (expirationQueueType::iterator itQueue = dirtyExpirationQueueRows.begin(); itQueue != dirtyExpirationQueueRows.end(); ++itQueue)
{
if (itQueue->second.empty())
{
batch.Erase(std::make_pair(EXP_QUEUE_ROW, itQueue->first));
}
else
{
batch.Write(std::make_pair(EXP_QUEUE_ROW, itQueue->first), itQueue->second);
}
}
}
void CClaimTrie::BatchWriteSupportNodes(CDBBatch& batch)
{
for (supportMapType::iterator itSupport = dirtySupportNodes.begin(); itSupport != dirtySupportNodes.end(); ++itSupport)
{
if (itSupport->second.empty())
{
batch.Erase(std::make_pair(SUPPORT, itSupport->first));
}
else
{
batch.Write(std::make_pair(SUPPORT, itSupport->first), itSupport->second);
}
}
}
void CClaimTrie::BatchWriteSupportQueueRows(CDBBatch& batch)
{
for (supportQueueType::iterator itQueue = dirtySupportQueueRows.begin(); itQueue != dirtySupportQueueRows.end(); ++itQueue)
{
if (itQueue->second.empty())
{
batch.Erase(std::make_pair(SUPPORT_QUEUE_ROW, itQueue->first));
}
else
{
batch.Write(std::make_pair(SUPPORT_QUEUE_ROW, itQueue->first), itQueue->second);
}
}
}
void CClaimTrie::BatchWriteSupportQueueNameRows(CDBBatch& batch)
{
for (queueNameType::iterator itQueue = dirtySupportQueueNameRows.begin(); itQueue != dirtySupportQueueNameRows.end(); ++itQueue)
{
if (itQueue->second.empty())
{
batch.Erase(std::make_pair(SUPPORT_QUEUE_NAME_ROW, itQueue->first));
}
else
{
batch.Write(std::make_pair(SUPPORT_QUEUE_NAME_ROW, itQueue->first), itQueue->second);
}
}
}
void CClaimTrie::BatchWriteSupportExpirationQueueRows(CDBBatch& batch)
{
for (expirationQueueType::iterator itQueue = dirtySupportExpirationQueueRows.begin(); itQueue != dirtySupportExpirationQueueRows.end(); ++itQueue)
{
if (itQueue->second.empty())
{
batch.Erase(std::make_pair(SUPPORT_EXP_QUEUE_ROW, itQueue->first));
}
else
{
batch.Write(std::make_pair(SUPPORT_EXP_QUEUE_ROW, itQueue->first), itQueue->second);
}
}
}
bool CClaimTrie::WriteToDisk()
{
CDBBatch batch(&db.GetObfuscateKey());
for (nodeCacheType::iterator itcache = dirtyNodes.begin(); itcache != dirtyNodes.end(); ++itcache)
BatchWriteNode(batch, itcache->first, itcache->second);
dirtyNodes.clear();
BatchWriteQueueRows(batch);
dirtyQueueRows.clear();
BatchWriteQueueNameRows(batch);
dirtyQueueNameRows.clear();
BatchWriteExpirationQueueRows(batch);
dirtyExpirationQueueRows.clear();
BatchWriteSupportNodes(batch);
dirtySupportNodes.clear();
BatchWriteSupportQueueRows(batch);
dirtySupportQueueRows.clear();
BatchWriteSupportQueueNameRows(batch);
dirtySupportQueueNameRows.clear();
BatchWriteSupportExpirationQueueRows(batch);
dirtySupportExpirationQueueRows.clear();
batch.Write(HASH_BLOCK, hashBlock);
batch.Write(CURRENT_HEIGHT, nCurrentHeight);
return db.WriteBatch(batch);
}
bool CClaimTrie::InsertFromDisk(const std::string& name, CClaimTrieNode* node)
{
if (name.size() == 0)
{
root = *node;
return true;
}
CClaimTrieNode* current = &root;
for (std::string::const_iterator itname = name.begin(); itname + 1 != name.end(); ++itname)
{
nodeMapType::iterator itchild = current->children.find(*itname);
if (itchild == current->children.end())
return false;
current = itchild->second;
}
current->children[name[name.size()-1]] = node;
return true;
}
bool CClaimTrie::ReadFromDisk(bool check)
{
if (!db.Read(HASH_BLOCK, hashBlock))
LogPrintf("%s: Couldn't read the best block's hash\n", __func__);
if (!db.Read(CURRENT_HEIGHT, nCurrentHeight))
LogPrintf("%s: Couldn't read the current height\n", __func__);
setExpirationTime(Params().GetConsensus().GetExpirationTime(nCurrentHeight-1));
boost::scoped_ptr<CDBIterator> pcursor(const_cast<CDBWrapper*>(&db)->NewIterator());
pcursor->SeekToFirst();
while (pcursor->Valid())
{
std::pair<char, std::string> key;
if (pcursor->GetKey(key))
{
if (key.first == TRIE_NODE)
{
CClaimTrieNode* node = new CClaimTrieNode();
if (pcursor->GetValue(*node))
{
if (!InsertFromDisk(key.second, node))
{
return error("%s(): error restoring claim trie from disk", __func__);
}
}
else
{
return error("%s(): error reading claim trie from disk", __func__);
}
}
}
pcursor->Next();
}
if (check)
{
LogPrintf("Checking Claim trie consistency...");
if (checkConsistency())
{
LogPrintf("consistent\n");
return true;
}
LogPrintf("inconsistent!\n");
return false;
}
return true;
}
bool CClaimTrieCache::recursiveComputeMerkleHash(CClaimTrieNode* tnCurrent, std::string sPos) const
{
if (sPos == "" && tnCurrent->empty())
{
cacheHashes[""] = uint256S("0000000000000000000000000000000000000000000000000000000000000001");
return true;
}
std::vector<unsigned char> vchToHash;
nodeCacheType::iterator cachedNode;
for (nodeMapType::iterator it = tnCurrent->children.begin(); it != tnCurrent->children.end(); ++it)
{
std::stringstream ss;
ss << it->first;
std::string sNextPos = sPos + ss.str();
if (dirtyHashes.count(sNextPos) != 0)
{
// the child might be in the cache, so look for it there
cachedNode = cache.find(sNextPos);
if (cachedNode != cache.end())
recursiveComputeMerkleHash(cachedNode->second, sNextPos);
else
recursiveComputeMerkleHash(it->second, sNextPos);
}
vchToHash.push_back(it->first);
hashMapType::iterator ithash = cacheHashes.find(sNextPos);
if (ithash != cacheHashes.end())
{
vchToHash.insert(vchToHash.end(), ithash->second.begin(), ithash->second.end());
}
else
{
vchToHash.insert(vchToHash.end(), it->second->hash.begin(), it->second->hash.end());
}
}
CClaimValue claim;
bool hasClaim = tnCurrent->getBestClaim(claim);
if (hasClaim)
{
int nHeightOfLastTakeover;
assert(getLastTakeoverForName(sPos, nHeightOfLastTakeover));
uint256 valueHash = getValueHash(claim.outPoint, nHeightOfLastTakeover);
vchToHash.insert(vchToHash.end(), valueHash.begin(), valueHash.end());
}
CHash256 hasher;
std::vector<unsigned char> vchHash(hasher.OUTPUT_SIZE);
hasher.Write(vchToHash.data(), vchToHash.size());
hasher.Finalize(&(vchHash[0]));
cacheHashes[sPos] = uint256(vchHash);
std::set<std::string>::iterator itDirty = dirtyHashes.find(sPos);
if (itDirty != dirtyHashes.end())
dirtyHashes.erase(itDirty);
return true;
}
uint256 CClaimTrieCache::getMerkleHash() const
{
if (empty())
{
uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
return one;
}
if (dirty())
{
nodeCacheType::iterator cachedNode = cache.find("");
if (cachedNode != cache.end())
recursiveComputeMerkleHash(cachedNode->second, "");
else
recursiveComputeMerkleHash(&(base->root), "");
}
hashMapType::iterator ithash = cacheHashes.find("");
if (ithash != cacheHashes.end())
return ithash->second;
else
return base->root.hash;
}
bool CClaimTrieCache::empty() const
{
return base->empty() && cache.empty();
}
CClaimTrieNode* CClaimTrieCache::addNodeToCache(const std::string& position, CClaimTrieNode* original) const
{
// create a copy of the node in the cache, if new node, create empty node
CClaimTrieNode* cacheCopy;
if(!original)
cacheCopy = new CClaimTrieNode();
else
cacheCopy = new CClaimTrieNode(*original);
cache[position] = cacheCopy;
// check to see if there is the original node in block_originals,
// if not, add it to block_originals cache
nodeCacheType::const_iterator itOriginals = block_originals.find(position);
if (block_originals.end() == itOriginals)
{
CClaimTrieNode* originalCopy;
if(!original)
originalCopy = new CClaimTrieNode();
else
originalCopy = new CClaimTrieNode(*original);
block_originals[position] = originalCopy;
}
return cacheCopy;
}
bool CClaimTrieCache::getOriginalInfoForName(const std::string& name, CClaimValue& claim) const
{
nodeCacheType::const_iterator itOriginalCache = block_originals.find(name);
if (itOriginalCache == block_originals.end())
{
return base->getInfoForName(name, claim);
}
return itOriginalCache->second->getBestClaim(claim);
}
bool CClaimTrieCache::insertClaimIntoTrie(const std::string& name, CClaimValue claim, bool fCheckTakeover) const
{
assert(base);
CClaimTrieNode* currentNode = &(base->root);
nodeCacheType::iterator cachedNode;
cachedNode = cache.find("");
if (cachedNode != cache.end())
currentNode = cachedNode->second;
for (std::string::const_iterator itCur = name.begin(); itCur != name.end(); ++itCur)
{
std::string sCurrentSubstring(name.begin(), itCur);
std::string sNextSubstring(name.begin(), itCur + 1);
cachedNode = cache.find(sNextSubstring);
if (cachedNode != cache.end())
{
currentNode = cachedNode->second;
continue;
}
nodeMapType::iterator childNode = currentNode->children.find(*itCur);
if (childNode != currentNode->children.end())
{
currentNode = childNode->second;
continue;
}
// This next substring doesn't exist in the cache and the next
// character doesn't exist in current node's children, so check
// if the current node is in the cache, and if it's not, copy
// it and stick it in the cache, and then create a new node as
// its child and stick that in the cache. We have to have both
// this node and its child in the cache so that the current
// node's child map will contain the next letter, which will be
// used to find the child in the cache. This is necessary in
// order to calculate the merkle hash.
cachedNode = cache.find(sCurrentSubstring);
if (cachedNode != cache.end())
{
assert(cachedNode->second == currentNode);
}
else
{
currentNode = addNodeToCache(sCurrentSubstring, currentNode);
}
CClaimTrieNode* newNode = addNodeToCache(sNextSubstring, NULL);
currentNode->children[*itCur] = newNode;
currentNode = newNode;
}
cachedNode = cache.find(name);
if (cachedNode != cache.end())
{
assert(cachedNode->second == currentNode);
}
else
{
currentNode = addNodeToCache(name, currentNode);
}
bool fChanged = false;
if (currentNode->claims.empty())
{
fChanged = true;
currentNode->insertClaim(claim);
}
else
{
CClaimValue currentTop = currentNode->claims.front();
currentNode->insertClaim(claim);
supportMapEntryType node;
getSupportsForName(name, node);
currentNode->reorderClaims(node);
if (currentTop != currentNode->claims.front())
fChanged = true;
}
if (fChanged)
{
for (std::string::const_iterator itCur = name.begin(); itCur != name.end(); ++itCur)
{
std::string sub(name.begin(), itCur);
dirtyHashes.insert(sub);
}
dirtyHashes.insert(name);
if (fCheckTakeover)
namesToCheckForTakeover.insert(name);
}
return true;
}
bool CClaimTrieCache::removeClaimFromTrie(const std::string& name, const COutPoint& outPoint, CClaimValue& claim, bool fCheckTakeover) const
{
assert(base);
CClaimTrieNode* currentNode = &(base->root);
nodeCacheType::iterator cachedNode;
cachedNode = cache.find("");
if (cachedNode != cache.end())
currentNode = cachedNode->second;
assert(currentNode != NULL); // If there is no root in either the trie or the cache, how can there be any names to remove?
for (std::string::const_iterator itCur = name.begin(); itCur != name.end(); ++itCur)
{
std::string sCurrentSubstring(name.begin(), itCur);
std::string sNextSubstring(name.begin(), itCur + 1);
cachedNode = cache.find(sNextSubstring);
if (cachedNode != cache.end())
{
currentNode = cachedNode->second;
continue;
}
nodeMapType::iterator childNode = currentNode->children.find(*itCur);
if (childNode != currentNode->children.end())
{
currentNode = childNode->second;
continue;
}
LogPrintf("%s: The name %s does not exist in the trie\n", __func__, name.c_str());
return false;
}
cachedNode = cache.find(name);
if (cachedNode != cache.end())
assert(cachedNode->second == currentNode);
else
{
currentNode = addNodeToCache(name, currentNode);
}
bool fChanged = false;
assert(currentNode != NULL);
bool success = false;
if (currentNode->claims.empty())
{
LogPrintf("%s: Asked to remove claim from node without claims\n", __func__);
return false;
}
CClaimValue currentTop = currentNode->claims.front();
success = currentNode->removeClaim(outPoint, claim);
if (!currentNode->claims.empty())
{
supportMapEntryType node;
getSupportsForName(name, node);
currentNode->reorderClaims(node);
if (currentTop != currentNode->claims.front())
fChanged = true;
}
else
fChanged = true;
if (!success)
{
LogPrintf("%s: Removing a claim was unsuccessful. name = %s, txhash = %s, nOut = %d", __func__, name.c_str(), outPoint.hash.GetHex(), outPoint.n);
return false;
}
if (fChanged)
{
for (std::string::const_iterator itCur = name.begin(); itCur != name.end(); ++itCur)
{
std::string sub(name.begin(), itCur);
dirtyHashes.insert(sub);
}
dirtyHashes.insert(name);
if (fCheckTakeover)
namesToCheckForTakeover.insert(name);
}
CClaimTrieNode* rootNode = &(base->root);
cachedNode = cache.find("");
if (cachedNode != cache.end())
rootNode = cachedNode->second;
return recursivePruneName(rootNode, 0, name);
}
bool CClaimTrieCache::recursivePruneName(CClaimTrieNode* tnCurrent, unsigned int nPos, std::string sName, bool* pfNullified) const
{
// Recursively prune leaf node(s) without any claims in it and store
// the modified nodes in the cache
bool fNullified = false;
std::string sCurrentSubstring = sName.substr(0, nPos);
if (nPos < sName.size())
{
std::string sNextSubstring = sName.substr(0, nPos + 1);
unsigned char cNext = sName.at(nPos);
CClaimTrieNode* tnNext = NULL;
nodeCacheType::iterator cachedNode = cache.find(sNextSubstring);
if (cachedNode != cache.end())
tnNext = cachedNode->second;
else
{
nodeMapType::iterator childNode = tnCurrent->children.find(cNext);
if (childNode != tnCurrent->children.end())
tnNext = childNode->second;
}
if (tnNext == NULL)
return false;
bool fChildNullified = false;
if (!recursivePruneName(tnNext, nPos + 1, sName, &fChildNullified))
return false;
if (fChildNullified)
{
// If the child nullified itself, the child should already be
// out of the cache, and the character must now be removed
// from the current node's map of child nodes to ensure that
// it isn't found when calculating the merkle hash. But
// tnCurrent isn't necessarily in the cache. If it's not, it
// has to be added to the cache, so nothing is changed in the
// trie. If the current node is added to the cache, however,
// that does not imply that the parent node must be altered to
// reflect that its child is now in the cache, since it
// already has a character in its child map which will be used
// when calculating the merkle root.
// First, find out if this node is in the cache.
cachedNode = cache.find(sCurrentSubstring);
if (cachedNode == cache.end())
{
// it isn't, so make a copy, stick it in the cache,
// and make it the new current node
tnCurrent = addNodeToCache(sCurrentSubstring, tnCurrent);
}
// erase the character from the current node, which is
// now guaranteed to be in the cache
nodeMapType::iterator childNode = tnCurrent->children.find(cNext);
if (childNode != tnCurrent->children.end())
tnCurrent->children.erase(childNode);
else
return false;
}
}
if (sCurrentSubstring.size() != 0 && tnCurrent->empty())
{
// If the current node is in the cache, remove it from there
nodeCacheType::iterator cachedNode = cache.find(sCurrentSubstring);
if (cachedNode != cache.end())
{
assert(tnCurrent == cachedNode->second);
delete tnCurrent;
cache.erase(cachedNode);
}
fNullified = true;
}
if (pfNullified)
*pfNullified = fNullified;
return true;
}
claimQueueType::iterator CClaimTrieCache::getQueueCacheRow(int nHeight, bool createIfNotExists) const
{
claimQueueType::iterator itQueueRow = claimQueueCache.find(nHeight);
if (itQueueRow == claimQueueCache.end())
{
// Have to make a new row it put in the cache, if createIfNotExists is true
claimQueueRowType queueRow;
// If the row exists in the base, copy its claims into the new row.
bool exists = base->getQueueRow(nHeight, queueRow);
if (!exists)
if (!createIfNotExists)
return itQueueRow;
// Stick the new row in the cache
std::pair<claimQueueType::iterator, bool> ret;
ret = claimQueueCache.insert(std::pair<int, claimQueueRowType >(nHeight, queueRow));
assert(ret.second);
itQueueRow = ret.first;
}
return itQueueRow;
}
queueNameType::iterator CClaimTrieCache::getQueueCacheNameRow(const std::string& name, bool createIfNotExists) const
{
queueNameType::iterator itQueueNameRow = claimQueueNameCache.find(name);
if (itQueueNameRow == claimQueueNameCache.end())
{
// Have to make a new name row and put it in the cache, if createIfNotExists is true
queueNameRowType queueNameRow;
// If the row exists in the base, copy its claims into the new row.
bool exists = base->getQueueNameRow(name, queueNameRow);
if (!exists)
if (!createIfNotExists)
return itQueueNameRow;
// Stick the new row in the cache
std::pair<queueNameType::iterator, bool> ret;
ret = claimQueueNameCache.insert(std::pair<std::string, queueNameRowType>(name, queueNameRow));
assert(ret.second);
itQueueNameRow = ret.first;
}
return itQueueNameRow;
}
bool CClaimTrieCache::addClaim(const std::string& name, const COutPoint& outPoint, uint160 claimId, CAmount nAmount, int nHeight) const
{
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, claimId: %s, nAmount: %d, nHeight: %d, nCurrentHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, claimId.GetHex(), nAmount, nHeight, nCurrentHeight);
assert(nHeight == nCurrentHeight);
CClaimValue currentClaim;
int delayForClaim;
if (getOriginalInfoForName(name, currentClaim) && currentClaim.claimId == claimId)
{
LogPrintf("%s: This is an update to a best claim.\n", __func__);
delayForClaim = 0;
}
else
{
delayForClaim = getDelayForName(name);
}
CClaimValue newClaim(outPoint, claimId, nAmount, nHeight, nHeight + delayForClaim);
return addClaimToQueues(name, newClaim);
}
bool CClaimTrieCache::undoSpendClaim(const std::string& name, const COutPoint& outPoint, uint160 claimId, CAmount nAmount, int nHeight, int nValidAtHeight) const
{
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, claimId: %s, nAmount: %d, nHeight: %d, nValidAtHeight: %d, nCurrentHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, claimId.GetHex(), nAmount, nHeight, nValidAtHeight, nCurrentHeight);
CClaimValue claim(outPoint, claimId, nAmount, nHeight, nValidAtHeight);
if (nValidAtHeight < nCurrentHeight)
{
nameOutPointType entry(name, claim.outPoint);
addToExpirationQueue(claim.nHeight + base->nExpirationTime, entry);
CClaimIndexElement element = {name, claim};
claimsToAdd.push_back(element);
return insertClaimIntoTrie(name, claim, false);
}
else
{
return addClaimToQueues(name, claim);
}
}
bool CClaimTrieCache::addClaimToQueues(const std::string& name, CClaimValue& claim) const
{
LogPrintf("%s: nValidAtHeight: %d\n", __func__, claim.nValidAtHeight);
claimQueueEntryType entry(name, claim);
claimQueueType::iterator itQueueRow = getQueueCacheRow(claim.nValidAtHeight, true);
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(name, true);
itQueueRow->second.push_back(entry);
itQueueNameRow->second.push_back(outPointHeightType(claim.outPoint, claim.nValidAtHeight));
nameOutPointType expireEntry(name, claim.outPoint);
addToExpirationQueue(claim.nHeight + base->nExpirationTime, expireEntry);
CClaimIndexElement element = {name, claim};
claimsToAdd.push_back(element);
return true;
}
bool CClaimTrieCache::removeClaimFromQueue(const std::string& name, const COutPoint& outPoint, CClaimValue& claim) const
{
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(name, false);
if (itQueueNameRow == claimQueueNameCache.end())
{
return false;
}
queueNameRowType::iterator itQueueName;
for (itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
{
if (itQueueName->outPoint == outPoint)
{
break;
}
}
if (itQueueName == itQueueNameRow->second.end())
{
return false;
}
claimQueueType::iterator itQueueRow = getQueueCacheRow(itQueueName->nHeight, false);
if (itQueueRow != claimQueueCache.end())
{
claimQueueRowType::iterator itQueue;
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
{
if (name == itQueue->first && itQueue->second.outPoint == outPoint)
{
break;
}
}
if (itQueue != itQueueRow->second.end())
{
std::swap(claim, itQueue->second);
itQueueNameRow->second.erase(itQueueName);
itQueueRow->second.erase(itQueue);
return true;
}
}
LogPrintf("%s: An inconsistency was found in the claim queue. Please report this to the developers:\nFound in named queue but not in height queue: name: %s, txid: %s, nOut: %d, nValidAtHeight: %d, current height: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, itQueueName->nHeight, nCurrentHeight);
return false;
}
bool CClaimTrieCache::undoAddClaim(const std::string& name, const COutPoint& outPoint, int nHeight) const
{
int throwaway;
return removeClaim(name, outPoint, nHeight, throwaway, false);
}
bool CClaimTrieCache::spendClaim(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight) const
{
return removeClaim(name, outPoint, nHeight, nValidAtHeight, true);
}
bool CClaimTrieCache::removeClaim(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight, bool fCheckTakeover) const
{
LogPrintf("%s: name: %s, txhash: %s, nOut: %s, nHeight: %s, nCurrentHeight: %s\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nHeight, nCurrentHeight);
bool removed = false;
CClaimValue claim;
if (removeClaimFromQueue(name, outPoint, claim))
{
removed = true;
}
if (removed == false && removeClaimFromTrie(name, outPoint, claim, fCheckTakeover))
{
removed = true;
}
if (removed == true)
{
nValidAtHeight = claim.nValidAtHeight;
int expirationHeight = nHeight + base->nExpirationTime;
removeFromExpirationQueue(name, outPoint, expirationHeight);
claimsToDelete.insert(claim);
}
return removed;
}
void CClaimTrieCache::addToExpirationQueue(int nExpirationHeight, nameOutPointType& entry) const
{
expirationQueueType::iterator itQueueRow = getExpirationQueueCacheRow(nExpirationHeight, true);
itQueueRow->second.push_back(entry);
}
void CClaimTrieCache::removeFromExpirationQueue(const std::string& name, const COutPoint& outPoint, int expirationHeight) const
{
expirationQueueType::iterator itQueueRow = getExpirationQueueCacheRow(expirationHeight, false);
expirationQueueRowType::iterator itQueue;
if (itQueueRow != expirationQueueCache.end())
{
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
{
if (name == itQueue->name && outPoint == itQueue->outPoint)
break;
}
if (itQueue != itQueueRow->second.end())
{
itQueueRow->second.erase(itQueue);
}
}
}
expirationQueueType::iterator CClaimTrieCache::getExpirationQueueCacheRow(int nHeight, bool createIfNotExists) const
{
expirationQueueType::iterator itQueueRow = expirationQueueCache.find(nHeight);
if (itQueueRow == expirationQueueCache.end())
{
// Have to make a new row it put in the cache, if createIfNotExists is true
expirationQueueRowType queueRow;
// If the row exists in the base, copy its claims into the new row.
bool exists = base->getExpirationQueueRow(nHeight, queueRow);
if (!exists)
if (!createIfNotExists)
return itQueueRow;
// Stick the new row in the cache
std::pair<expirationQueueType::iterator, bool> ret;
ret = expirationQueueCache.insert(std::pair<int, expirationQueueRowType >(nHeight, queueRow));
assert(ret.second);
itQueueRow = ret.first;
}
return itQueueRow;
}
bool CClaimTrieCache::reorderTrieNode(const std::string& name, bool fCheckTakeover) const
{
assert(base);
nodeCacheType::iterator cachedNode;
cachedNode = cache.find(name);
if (cachedNode == cache.end())
{
CClaimTrieNode* currentNode;
cachedNode = cache.find("");
if(cachedNode == cache.end())
currentNode = &(base->root);
else
currentNode = cachedNode->second;
for (std::string::const_iterator itCur = name.begin(); itCur != name.end(); ++itCur)
{
std::string sCurrentSubstring(name.begin(), itCur);
std::string sNextSubstring(name.begin(), itCur + 1);
cachedNode = cache.find(sNextSubstring);
if (cachedNode != cache.end())
{
currentNode = cachedNode->second;
continue;
}
nodeMapType::iterator childNode = currentNode->children.find(*itCur);
if (childNode != currentNode->children.end())
{
currentNode = childNode->second;
continue;
}
// The node doesn't exist, so it can't be reordered.
return true;
}
currentNode = new CClaimTrieNode(*currentNode);
std::pair<nodeCacheType::iterator, bool> ret;
ret = cache.insert(std::pair<std::string, CClaimTrieNode*>(name, currentNode));
assert(ret.second);
cachedNode = ret.first;
}
bool fChanged = false;
if (cachedNode->second->claims.empty())
{
// Nothing in there to reorder
return true;
}
else
{
CClaimValue currentTop = cachedNode->second->claims.front();
supportMapEntryType node;
getSupportsForName(name, node);
cachedNode->second->reorderClaims(node);
if (cachedNode->second->claims.front() != currentTop)
fChanged = true;
}
if (fChanged)
{
for (std::string::const_iterator itCur = name.begin(); itCur != name.end(); ++itCur)
{
std::string sub(name.begin(), itCur);
dirtyHashes.insert(sub);
}
dirtyHashes.insert(name);
if (fCheckTakeover)
namesToCheckForTakeover.insert(name);
}
return true;
}
bool CClaimTrieCache::getSupportsForName(const std::string& name, supportMapEntryType& node) const
{
supportMapType::iterator cachedNode;
cachedNode = supportCache.find(name);
if (cachedNode != supportCache.end())
{
node = cachedNode->second;
return true;
}
else
{
return base->getSupportNode(name, node);
}
}
bool CClaimTrieCache::insertSupportIntoMap(const std::string& name, CSupportValue support, bool fCheckTakeover) const
{
supportMapType::iterator cachedNode;
// If this node is already in the cache, use that
cachedNode = supportCache.find(name);
// If not, copy the one from base if it exists, and use that
if (cachedNode == supportCache.end())
{
supportMapEntryType node;
base->getSupportNode(name, node);
std::pair<supportMapType::iterator, bool> ret;
ret = supportCache.insert(std::pair<std::string, supportMapEntryType>(name, node));
assert(ret.second);
cachedNode = ret.first;
}
cachedNode->second.push_back(support);
// See if this changed the biggest bid
return reorderTrieNode(name, fCheckTakeover);
}
bool CClaimTrieCache::removeSupportFromMap(const std::string& name, const COutPoint& outPoint, CSupportValue& support, bool fCheckTakeover) const
{
supportMapType::iterator cachedNode;
cachedNode = supportCache.find(name);
if (cachedNode == supportCache.end())
{
supportMapEntryType node;
if (!base->getSupportNode(name, node))
{
// clearly, this support does not exist
return false;
}
std::pair<supportMapType::iterator, bool> ret;
ret = supportCache.insert(std::pair<std::string, supportMapEntryType>(name, node));
assert(ret.second);
cachedNode = ret.first;
}
supportMapEntryType::iterator itSupport;
for (itSupport = cachedNode->second.begin(); itSupport != cachedNode->second.end(); ++itSupport)
{
if (itSupport->outPoint == outPoint)
{
break;
}
}
if (itSupport != cachedNode->second.end())
{
std::swap(support, *itSupport);
cachedNode->second.erase(itSupport);
return reorderTrieNode(name, fCheckTakeover);
}
else
{
LogPrintf("CClaimTrieCache::%s() : asked to remove a support that doesn't exist\n", __func__);
return false;
}
}
supportQueueType::iterator CClaimTrieCache::getSupportQueueCacheRow(int nHeight, bool createIfNotExists) const
{
supportQueueType::iterator itQueueRow = supportQueueCache.find(nHeight);
if (itQueueRow == supportQueueCache.end())
{
supportQueueRowType queueRow;
bool exists = base->getSupportQueueRow(nHeight, queueRow);
if (!exists)
if (!createIfNotExists)
return itQueueRow;
// Stick the new row in the cache
std::pair<supportQueueType::iterator, bool> ret;
ret = supportQueueCache.insert(std::pair<int, supportQueueRowType >(nHeight, queueRow));
assert(ret.second);
itQueueRow = ret.first;
}
return itQueueRow;
}
queueNameType::iterator CClaimTrieCache::getSupportQueueCacheNameRow(const std::string& name, bool createIfNotExists) const
{
queueNameType::iterator itQueueNameRow = supportQueueNameCache.find(name);
if (itQueueNameRow == supportQueueNameCache.end())
{
queueNameRowType queueNameRow;
bool exists = base->getSupportQueueNameRow(name, queueNameRow);
if (!exists)
if (!createIfNotExists)
return itQueueNameRow;
// Stick the new row in the name cache
std::pair<queueNameType::iterator, bool> ret;
ret = supportQueueNameCache.insert(std::pair<std::string, queueNameRowType>(name, queueNameRow));
assert(ret.second);
itQueueNameRow = ret.first;
}
return itQueueNameRow;
}
bool CClaimTrieCache::addSupportToQueues(const std::string& name, CSupportValue& support) const
{
LogPrintf("%s: nValidAtHeight: %d\n", __func__, support.nValidAtHeight);
supportQueueEntryType entry(name, support);
supportQueueType::iterator itQueueRow = getSupportQueueCacheRow(support.nValidAtHeight, true);
queueNameType::iterator itQueueNameRow = getSupportQueueCacheNameRow(name, true);
itQueueRow->second.push_back(entry);
itQueueNameRow->second.push_back(outPointHeightType(support.outPoint, support.nValidAtHeight));
nameOutPointType expireEntry(name, support.outPoint);
addSupportToExpirationQueue(support.nHeight + base->nExpirationTime, expireEntry);
return true;
}
bool CClaimTrieCache::removeSupportFromQueue(const std::string& name, const COutPoint& outPoint, CSupportValue& support) const
{
queueNameType::iterator itQueueNameRow = getSupportQueueCacheNameRow(name, false);
if (itQueueNameRow == supportQueueNameCache.end())
{
return false;
}
queueNameRowType::iterator itQueueName;
for (itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
{
if (itQueueName->outPoint == outPoint)
{
break;
}
}
if (itQueueName == itQueueNameRow->second.end())
{
return false;
}
supportQueueType::iterator itQueueRow = getSupportQueueCacheRow(itQueueName->nHeight, false);
if (itQueueRow != supportQueueCache.end())
{
supportQueueRowType::iterator itQueue;
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
{
CSupportValue& support = itQueue->second;
if (name == itQueue->first && support.outPoint == outPoint)
{
break;
}
}
if (itQueue != itQueueRow->second.end())
{
std::swap(support, itQueue->second);
itQueueNameRow->second.erase(itQueueName);
itQueueRow->second.erase(itQueue);
return true;
}
}
LogPrintf("%s: An inconsistency was found in the claim queue. Please report this to the developers:\nFound in named support queue but not in height support queue: name: %s, txid: %s, nOut: %d, nValidAtHeight: %d, current height: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, itQueueName->nHeight, nCurrentHeight);
return false;
}
bool CClaimTrieCache::addSupport(const std::string& name, const COutPoint& outPoint, CAmount nAmount, uint160 supportedClaimId, int nHeight) const
{
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, nAmount: %d, supportedClaimId: %s, nHeight: %d, nCurrentHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nAmount, supportedClaimId.GetHex(), nHeight, nCurrentHeight);
assert(nHeight == nCurrentHeight);
CClaimValue claim;
int delayForSupport;
if (getOriginalInfoForName(name, claim) && claim.claimId == supportedClaimId)
{
LogPrintf("%s: This is a support to a best claim.\n", __func__);
delayForSupport = 0;
}
else
{
delayForSupport = getDelayForName(name);
}
CSupportValue support(outPoint, supportedClaimId, nAmount, nHeight, nHeight + delayForSupport);
return addSupportToQueues(name, support);
}
bool CClaimTrieCache::undoSpendSupport(const std::string& name, const COutPoint& outPoint, uint160 supportedClaimId, CAmount nAmount, int nHeight, int nValidAtHeight) const
{
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, nAmount: %d, supportedClaimId: %s, nHeight: %d, nCurrentHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nAmount, supportedClaimId.GetHex(), nHeight, nCurrentHeight);
CSupportValue support(outPoint, supportedClaimId, nAmount, nHeight, nValidAtHeight);
if (nValidAtHeight < nCurrentHeight)
{
nameOutPointType entry(name, support.outPoint);
addSupportToExpirationQueue(support.nHeight + base->nExpirationTime, entry);
return insertSupportIntoMap(name, support, false);
}
else
{
return addSupportToQueues(name, support);
}
}
bool CClaimTrieCache::removeSupport(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight, bool fCheckTakeover) const
{
bool removed = false;
CSupportValue support;
if (removeSupportFromQueue(name, outPoint, support))
removed = true;
if (removed == false && removeSupportFromMap(name, outPoint, support, fCheckTakeover))
removed = true;
if (removed)
{
int expirationHeight = nHeight + base->nExpirationTime;
removeSupportFromExpirationQueue(name, outPoint, expirationHeight);
nValidAtHeight = support.nValidAtHeight;
}
return removed;
}
void CClaimTrieCache::addSupportToExpirationQueue(int nExpirationHeight, nameOutPointType& entry) const
{
expirationQueueType::iterator itQueueRow = getSupportExpirationQueueCacheRow(nExpirationHeight, true);
itQueueRow->second.push_back(entry);
}
void CClaimTrieCache::removeSupportFromExpirationQueue(const std::string& name, const COutPoint& outPoint, int expirationHeight) const
{
expirationQueueType::iterator itQueueRow = getSupportExpirationQueueCacheRow(expirationHeight, false);
expirationQueueRowType::iterator itQueue;
if (itQueueRow != supportExpirationQueueCache.end())
{
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
{
if (name == itQueue->name && outPoint == itQueue->outPoint)
break;
}
}
if (itQueue != itQueueRow->second.end())
{
itQueueRow->second.erase(itQueue);
}
}
expirationQueueType::iterator CClaimTrieCache::getSupportExpirationQueueCacheRow(int nHeight, bool createIfNotExists) const
{
expirationQueueType::iterator itQueueRow = supportExpirationQueueCache.find(nHeight);
if (itQueueRow == supportExpirationQueueCache.end())
{
// Have to make a new row it put in the cache, if createIfNotExists is true
expirationQueueRowType queueRow;
// If the row exists in the base, copy its claims into the new row.
bool exists = base->getSupportExpirationQueueRow(nHeight, queueRow);
if (!exists)
if (!createIfNotExists)
return itQueueRow;
// Stick the new row in the cache
std::pair<expirationQueueType::iterator, bool> ret;
ret = supportExpirationQueueCache.insert(std::pair<int, expirationQueueRowType >(nHeight, queueRow));
assert(ret.second);
itQueueRow = ret.first;
}
return itQueueRow;
}
bool CClaimTrieCache::undoAddSupport(const std::string& name, const COutPoint& outPoint, int nHeight) const
{
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, nHeight: %d, nCurrentHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nHeight, nCurrentHeight);
int throwaway;
return removeSupport(name, outPoint, nHeight, throwaway, false);
}
bool CClaimTrieCache::spendSupport(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight) const
{
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, nHeight: %d, nCurrentHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nHeight, nCurrentHeight);
return removeSupport(name, outPoint, nHeight, nValidAtHeight, true);
}
bool CClaimTrieCache::incrementBlock(insertUndoType& insertUndo, claimQueueRowType& expireUndo, insertUndoType& insertSupportUndo, supportQueueRowType& expireSupportUndo, std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const
{
LogPrintf("%s: nCurrentHeight (before increment): %d\n", __func__, nCurrentHeight);
claimQueueType::iterator itQueueRow = getQueueCacheRow(nCurrentHeight, false);
if (itQueueRow != claimQueueCache.end())
{
for (claimQueueRowType::iterator itEntry = itQueueRow->second.begin(); itEntry != itQueueRow->second.end(); ++itEntry)
{
bool found = false;
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(itEntry->first, false);
if (itQueueNameRow != claimQueueNameCache.end())
{
for (queueNameRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
{
if (itQueueName->outPoint == itEntry->second.outPoint && itQueueName->nHeight == nCurrentHeight)
{
found = true;
itQueueNameRow->second.erase(itQueueName);
break;
}
}
}
if (!found)
{
LogPrintf("%s: An inconsistency was found in the claim queue. Please report this to the developers:\nFound in height queue but not in named queue: name: %s, txid: %s, nOut: %d, nValidAtHeight: %d, current height: %d\n", __func__, itEntry->first, itEntry->second.outPoint.hash.GetHex(), itEntry->second.outPoint.n, itEntry->second.nValidAtHeight, nCurrentHeight);
if (itQueueNameRow != claimQueueNameCache.end())
{
LogPrintf("Claims found for that name:\n");
for (queueNameRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
{
LogPrintf("\ttxid: %s, nOut: %d, nValidAtHeight: %d\n", itQueueName->outPoint.hash.GetHex(), itQueueName->outPoint.n, itQueueName->nHeight);
}
}
else
{
LogPrintf("No claims found for that name\n");
}
}
assert(found);
insertClaimIntoTrie(itEntry->first, itEntry->second, true);
insertUndo.push_back(nameOutPointHeightType(itEntry->first, itEntry->second.outPoint, itEntry->second.nValidAtHeight));
}
itQueueRow->second.clear();
}
expirationQueueType::iterator itExpirationRow = getExpirationQueueCacheRow(nCurrentHeight, false);
if (itExpirationRow != expirationQueueCache.end())
{
for (expirationQueueRowType::iterator itEntry = itExpirationRow->second.begin(); itEntry != itExpirationRow->second.end(); ++itEntry)
{
CClaimValue claim;
assert(removeClaimFromTrie(itEntry->name, itEntry->outPoint, claim, true));
claimsToDelete.insert(claim);
expireUndo.push_back(std::make_pair(itEntry->name, claim));
LogPrintf("Expiring claim %s: %s, nHeight: %d, nValidAtHeight: %d\n", claim.claimId.GetHex(), itEntry->name, claim.nHeight, claim.nValidAtHeight);
}
itExpirationRow->second.clear();
}
supportQueueType::iterator itSupportRow = getSupportQueueCacheRow(nCurrentHeight, false);
if (itSupportRow != supportQueueCache.end())
{
for (supportQueueRowType::iterator itSupport = itSupportRow->second.begin(); itSupport != itSupportRow->second.end(); ++itSupport)
{
bool found = false;
queueNameType::iterator itSupportNameRow = getSupportQueueCacheNameRow(itSupport->first, false);
if (itSupportNameRow != supportQueueNameCache.end())
{
for (queueNameRowType::iterator itSupportName = itSupportNameRow->second.begin(); itSupportName != itSupportNameRow->second.end(); ++itSupportName)
{
if (itSupportName->outPoint == itSupport->second.outPoint && itSupportName->nHeight == itSupport->second.nValidAtHeight)
{
found = true;
itSupportNameRow->second.erase(itSupportName);
break;
}
}
}
if (!found)
{
LogPrintf("%s: An inconsistency was found in the support queue. Please report this to the developers:\nFound in height queue but not in named queue: %s, txid: %s, nOut: %d, nValidAtHeight: %d, current height: %d\n", __func__, itSupport->first, itSupport->second.outPoint.hash.GetHex(), itSupport->second.outPoint.n, itSupport->second.nValidAtHeight, nCurrentHeight);
if (itSupportNameRow != supportQueueNameCache.end())
{
LogPrintf("Supports found for that name:\n");
for (queueNameRowType::iterator itSupportName = itSupportNameRow->second.begin(); itSupportName != itSupportNameRow->second.end(); ++itSupportName)
{
LogPrintf("\ttxid: %s, nOut: %d, nValidAtHeight: %d\n", itSupportName->outPoint.hash.GetHex(), itSupportName->outPoint.n, itSupportName->nHeight);
}
}
else
{
LogPrintf("No support found for that name\n");
}
}
insertSupportIntoMap(itSupport->first, itSupport->second, true);
insertSupportUndo.push_back(nameOutPointHeightType(itSupport->first, itSupport->second.outPoint, itSupport->second.nValidAtHeight));
}
itSupportRow->second.clear();
}
expirationQueueType::iterator itSupportExpirationRow = getSupportExpirationQueueCacheRow(nCurrentHeight, false);
if (itSupportExpirationRow != supportExpirationQueueCache.end())
{
for (expirationQueueRowType::iterator itEntry = itSupportExpirationRow->second.begin(); itEntry != itSupportExpirationRow->second.end(); ++itEntry)
{
CSupportValue support;
assert(removeSupportFromMap(itEntry->name, itEntry->outPoint, support, true));
expireSupportUndo.push_back(std::make_pair(itEntry->name, support));
LogPrintf("Expiring support %s: %s, nHeight: %d, nValidAtHeight: %d\n", support.supportedClaimId.GetHex(), itEntry->name, support.nHeight, support.nValidAtHeight);
}
itSupportExpirationRow->second.clear();
}
// check each potentially taken over name to see if a takeover occurred.
// if it did, then check the claim and support insertion queues for
// the names that have been taken over, immediately insert all claim and
// supports for those names, and stick them in the insertUndo or
// insertSupportUndo vectors, with the nValidAtHeight they had prior to
// this block.
// Run through all names that have been taken over
for (std::set<std::string>::iterator itNamesToCheck = namesToCheckForTakeover.begin(); itNamesToCheck != namesToCheckForTakeover.end(); ++itNamesToCheck)
{
// Check if a takeover has occurred
nodeCacheType::iterator itCachedNode = cache.find(*itNamesToCheck);
// many possibilities
// if this node is new, don't put it into the undo -- there will be nothing to restore, after all
// if all of this node's claims were deleted, it should be put into the undo -- there could be
// claims in the queue for that name and the takeover height should be the current height
// if the node is not in the cache, or getbestclaim fails, that means all of its claims were
// deleted
// if getOriginalInfoForName returns false, that means it's new and shouldn't go into the undo
// if both exist, and the current best claim is not the same as or the parent to the new best
// claim, then ownership has changed and the current height of last takeover should go into
// the queue
CClaimValue claimInCache;
CClaimValue claimInTrie;
bool haveClaimInCache;
bool haveClaimInTrie;
if (itCachedNode == cache.end())
{
haveClaimInCache = false;
}
else
{
haveClaimInCache = itCachedNode->second->getBestClaim(claimInCache);
}
haveClaimInTrie = getOriginalInfoForName(*itNamesToCheck, claimInTrie);
bool takeoverHappened = false;
if (!haveClaimInTrie)
{
takeoverHappened = true;
}
else if (!haveClaimInCache)
{
takeoverHappened = true;
}
else if (claimInCache != claimInTrie)
{
if (claimInCache.claimId != claimInTrie.claimId)
{
takeoverHappened = true;
}
}
if (takeoverHappened)
{
// Get all claims in the queue for that name
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(*itNamesToCheck, false);
if (itQueueNameRow != claimQueueNameCache.end())
{
for (queueNameRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
{
bool found = false;
// Pull those claims out of the height-based queue
claimQueueType::iterator itQueueRow = getQueueCacheRow(itQueueName->nHeight, false);
claimQueueRowType::iterator itQueue;
if (itQueueRow != claimQueueCache.end())
{
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
{
if (*itNamesToCheck == itQueue->first && itQueue->second.outPoint == itQueueName->outPoint && itQueue->second.nValidAtHeight == itQueueName->nHeight)
{
found = true;
break;
}
}
}
if (found)
{
// Insert them into the queue undo with their previous nValidAtHeight
insertUndo.push_back(nameOutPointHeightType(itQueue->first, itQueue->second.outPoint, itQueue->second.nValidAtHeight));
// Insert them into the name trie with the new nValidAtHeight
itQueue->second.nValidAtHeight = nCurrentHeight;
insertClaimIntoTrie(itQueue->first, itQueue->second, false);
// Delete them from the height-based queue
itQueueRow->second.erase(itQueue);
}
else
{
LogPrintf("%s(): An inconsistency was found in the claim queue. Please report this to the developers:\nClaim found in name queue but not in height based queue:\nname: %s, txid: %s, nOut: %d, nValidAtHeight in name based queue: %d, current height: %d\n", __func__, *itNamesToCheck, itQueueName->outPoint.hash.GetHex(), itQueueName->outPoint.n, itQueueName->nHeight, nCurrentHeight);
}
assert(found);
}
// remove all claims from the queue for that name
itQueueNameRow->second.clear();
}
//
// Then, get all supports in the queue for that name
queueNameType::iterator itSupportQueueNameRow = getSupportQueueCacheNameRow(*itNamesToCheck, false);
if (itSupportQueueNameRow != supportQueueNameCache.end())
{
for (queueNameRowType::iterator itSupportQueueName = itSupportQueueNameRow->second.begin(); itSupportQueueName != itSupportQueueNameRow->second.end(); ++itSupportQueueName)
{
// Pull those supports out of the height-based queue
supportQueueType::iterator itSupportQueueRow = getSupportQueueCacheRow(itSupportQueueName->nHeight, false);
if (itSupportQueueRow != supportQueueCache.end())
{
supportQueueRowType::iterator itSupportQueue;
for (itSupportQueue = itSupportQueueRow->second.begin(); itSupportQueue != itSupportQueueRow->second.end(); ++itSupportQueue)
{
if (*itNamesToCheck == itSupportQueue->first && itSupportQueue->second.outPoint == itSupportQueueName->outPoint && itSupportQueue->second.nValidAtHeight == itSupportQueueName->nHeight)
{
break;
}
}
if (itSupportQueue != itSupportQueueRow->second.end())
{
// Insert them into the support queue undo with the previous nValidAtHeight
insertSupportUndo.push_back(nameOutPointHeightType(itSupportQueue->first, itSupportQueue->second.outPoint, itSupportQueue->second.nValidAtHeight));
// Insert them into the support map with the new nValidAtHeight
itSupportQueue->second.nValidAtHeight = nCurrentHeight;
insertSupportIntoMap(itSupportQueue->first, itSupportQueue->second, false);
// Delete them from the height-based queue
itSupportQueueRow->second.erase(itSupportQueue);
}
else
{
// here be problems TODO: show error, assert false
}
}
else
{
// here be problems
}
}
// remove all supports from the queue for that name
itSupportQueueNameRow->second.clear();
}
// save the old last height so that it can be restored if the block is undone
if (haveClaimInTrie)
{
int nHeightOfLastTakeover;
assert(getLastTakeoverForName(*itNamesToCheck, nHeightOfLastTakeover));
takeoverHeightUndo.push_back(std::make_pair(*itNamesToCheck, nHeightOfLastTakeover));
}
itCachedNode = cache.find(*itNamesToCheck);
if (itCachedNode != cache.end())
{
cacheTakeoverHeights[*itNamesToCheck] = nCurrentHeight;
}
}
}
for (nodeCacheType::const_iterator itOriginals = block_originals.begin(); itOriginals != block_originals.end(); ++itOriginals)
{
delete itOriginals->second;
}
block_originals.clear();
for (nodeCacheType::const_iterator itCache = cache.begin(); itCache != cache.end(); ++itCache)
{
block_originals[itCache->first] = new CClaimTrieNode(*(itCache->second));
}
namesToCheckForTakeover.clear();
nCurrentHeight++;
return true;
}
bool CClaimTrieCache::decrementBlock(insertUndoType& insertUndo, claimQueueRowType& expireUndo, insertUndoType& insertSupportUndo, supportQueueRowType& expireSupportUndo, std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const
{
LogPrintf("%s: nCurrentHeight (before decrement): %d\n", __func__, nCurrentHeight);
nCurrentHeight--;
if (expireSupportUndo.begin() != expireSupportUndo.end())
{
expirationQueueType::iterator itSupportExpireRow = getSupportExpirationQueueCacheRow(nCurrentHeight, true);
for (supportQueueRowType::iterator itSupportExpireUndo = expireSupportUndo.begin(); itSupportExpireUndo != expireSupportUndo.end(); ++itSupportExpireUndo)
{
insertSupportIntoMap(itSupportExpireUndo->first, itSupportExpireUndo->second, false);
itSupportExpireRow->second.push_back(nameOutPointType(itSupportExpireUndo->first, itSupportExpireUndo->second.outPoint));
}
}
for (insertUndoType::iterator itSupportUndo = insertSupportUndo.begin(); itSupportUndo != insertSupportUndo.end(); ++itSupportUndo)
{
supportQueueType::iterator itSupportRow = getSupportQueueCacheRow(itSupportUndo->nHeight, true);
CSupportValue support;
assert(removeSupportFromMap(itSupportUndo->name, itSupportUndo->outPoint, support, false));
queueNameType::iterator itSupportNameRow = getSupportQueueCacheNameRow(itSupportUndo->name, true);
itSupportRow->second.push_back(std::make_pair(itSupportUndo->name, support));
itSupportNameRow->second.push_back(outPointHeightType(support.outPoint, support.nValidAtHeight));
}
if (expireUndo.begin() != expireUndo.end())
{
expirationQueueType::iterator itExpireRow = getExpirationQueueCacheRow(nCurrentHeight, true);
for (claimQueueRowType::iterator itExpireUndo = expireUndo.begin(); itExpireUndo != expireUndo.end(); ++itExpireUndo)
{
insertClaimIntoTrie(itExpireUndo->first, itExpireUndo->second, false);
CClaimIndexElement element = {itExpireUndo->first, itExpireUndo->second};
claimsToAdd.push_back(element);
itExpireRow->second.push_back(nameOutPointType(itExpireUndo->first, itExpireUndo->second.outPoint));
}
}
for (insertUndoType::iterator itInsertUndo = insertUndo.begin(); itInsertUndo != insertUndo.end(); ++itInsertUndo)
{
claimQueueType::iterator itQueueRow = getQueueCacheRow(itInsertUndo->nHeight, true);
CClaimValue claim;
assert(removeClaimFromTrie(itInsertUndo->name, itInsertUndo->outPoint, claim, false));
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(itInsertUndo->name, true);
itQueueRow->second.push_back(std::make_pair(itInsertUndo->name, claim));
itQueueNameRow->second.push_back(outPointHeightType(itInsertUndo->outPoint, itInsertUndo->nHeight));
}
for (std::vector<std::pair<std::string, int> >::iterator itTakeoverHeightUndo = takeoverHeightUndo.begin(); itTakeoverHeightUndo != takeoverHeightUndo.end(); ++itTakeoverHeightUndo)
{
cacheTakeoverHeights[itTakeoverHeightUndo->first] = itTakeoverHeightUndo->second;
}
return true;
}
bool CClaimTrieCache::finalizeDecrement() const
{
for (nodeCacheType::iterator itOriginals = block_originals.begin(); itOriginals != block_originals.end(); ++itOriginals)
{
delete itOriginals->second;
}
block_originals.clear();
for (nodeCacheType::const_iterator itCache = cache.begin(); itCache != cache.end(); ++itCache)
{
block_originals[itCache->first] = new CClaimTrieNode(*(itCache->second));
}
return true;
}
bool CClaimTrieCache::getLastTakeoverForName(const std::string& name, int& nLastTakeoverForName) const
{
if (!fRequireTakeoverHeights)
{
nLastTakeoverForName = 0;
return true;
}
std::map<std::string, int>::iterator itHeights = cacheTakeoverHeights.find(name);
if (itHeights == cacheTakeoverHeights.end())
{
return base->getLastTakeoverForName(name, nLastTakeoverForName);
}
nLastTakeoverForName = itHeights->second;
return true;
}
int CClaimTrieCache::getNumBlocksOfContinuousOwnership(const std::string& name) const
{
const CClaimTrieNode* node = NULL;
nodeCacheType::const_iterator itCache = cache.find(name);
if (itCache != cache.end())
{
node = itCache->second;
}
if (!node)
{
node = base->getNodeForName(name);
}
if (!node || node->claims.empty())
{
return 0;
}
int nLastTakeoverHeight;
assert(getLastTakeoverForName(name, nLastTakeoverHeight));
return nCurrentHeight - nLastTakeoverHeight;
}
int CClaimTrieCache::getDelayForName(const std::string& name) const
{
if (!fRequireTakeoverHeights)
{
return 0;
}
int nBlocksOfContinuousOwnership = getNumBlocksOfContinuousOwnership(name);
return std::min(nBlocksOfContinuousOwnership / base->nProportionalDelayFactor, 4032);
}
uint256 CClaimTrieCache::getBestBlock()
{
if (hashBlock.IsNull())
if (base != NULL)
hashBlock = base->hashBlock;
return hashBlock;
}
void CClaimTrieCache::setBestBlock(const uint256& hashBlockIn)
{
hashBlock = hashBlockIn;
}
bool CClaimTrieCache::clear() const
{
for (nodeCacheType::iterator itcache = cache.begin(); itcache != cache.end(); ++itcache)
{
delete itcache->second;
}
cache.clear();
for (nodeCacheType::iterator itOriginals = block_originals.begin(); itOriginals != block_originals.end(); ++itOriginals)
{
delete itOriginals->second;
}
block_originals.clear();
dirtyHashes.clear();
cacheHashes.clear();
claimQueueCache.clear();
claimQueueNameCache.clear();
expirationQueueCache.clear();
supportCache.clear();
supportQueueCache.clear();
supportQueueNameCache.clear();
supportExpirationQueueCache.clear();
namesToCheckForTakeover.clear();
cacheTakeoverHeights.clear();
return true;
}
bool CClaimTrieCache::flush()
{
if (dirty())
getMerkleHash();
if (!claimsToDelete.empty()) {
for (claimIndexClaimListType::iterator it = claimsToDelete.begin(); it != claimsToDelete.end(); ++it)
base->removeFromClaimIndex(*it);
claimsToDelete.clear();
}
if (!claimsToAdd.empty()) {
for (claimIndexElementListType::iterator it = claimsToAdd.begin(); it != claimsToAdd.end(); ++it)
base->addToClaimIndex(it->name, it->claim);
claimsToAdd.clear();
}
bool success = base->update(cache, cacheHashes, cacheTakeoverHeights, getBestBlock(), claimQueueCache, claimQueueNameCache, expirationQueueCache, nCurrentHeight, supportCache, supportQueueCache, supportQueueNameCache, supportExpirationQueueCache);
if (success)
{
success = clear();
}
return success;
}
uint256 CClaimTrieCache::getLeafHashForProof(const std::string& currentPosition, unsigned char nodeChar, const CClaimTrieNode* currentNode) const
{
std::stringstream leafPosition;
leafPosition << currentPosition << nodeChar;
hashMapType::iterator cachedHash = cacheHashes.find(leafPosition.str());
if (cachedHash != cacheHashes.end())
{
return cachedHash->second;
}
else
{
return currentNode->hash;
}
}
CClaimTrieProof CClaimTrieCache::getProofForName(const std::string& name) const
{
if (dirty())
getMerkleHash();
std::vector<CClaimTrieProofNode> nodes;
CClaimTrieNode* current = &(base->root);
nodeCacheType::const_iterator cachedNode;
bool fNameHasValue = false;
COutPoint outPoint;
int nHeightOfLastTakeover = 0;
for (std::string::const_iterator itName = name.begin(); current; ++itName)
{
std::string currentPosition(name.begin(), itName);
cachedNode = cache.find(currentPosition);
if (cachedNode != cache.end())
current = cachedNode->second;
CClaimValue claim;
bool fNodeHasValue = current->getBestClaim(claim);
uint256 valueHash;
if (fNodeHasValue)
{
int nHeightOfLastTakeover;
assert(getLastTakeoverForName(currentPosition, nHeightOfLastTakeover));
valueHash = getValueHash(claim.outPoint, nHeightOfLastTakeover);
}
std::vector<std::pair<unsigned char, uint256> > children;
CClaimTrieNode* nextCurrent = NULL;
for (nodeMapType::const_iterator itChildren = current->children.begin(); itChildren != current->children.end(); ++itChildren)
{
if (itName == name.end() || itChildren->first != *itName) // Leaf node
{
uint256 childHash = getLeafHashForProof(currentPosition, itChildren->first, itChildren->second);
children.push_back(std::make_pair(itChildren->first, childHash));
}
else // Full node
{
nextCurrent = itChildren->second;
uint256 childHash;
children.push_back(std::make_pair(itChildren->first, childHash));
}
}
if (currentPosition == name)
{
fNameHasValue = fNodeHasValue;
if (fNameHasValue)
{
outPoint = claim.outPoint;
assert(getLastTakeoverForName(name, nHeightOfLastTakeover));
}
valueHash.SetNull();
}
CClaimTrieProofNode node(children, fNodeHasValue, valueHash);
nodes.push_back(node);
current = nextCurrent;
}
return CClaimTrieProof(nodes, fNameHasValue, outPoint,
nHeightOfLastTakeover);
}
void CClaimTrieCache::removeAndAddToExpirationQueue(expirationQueueRowType &row, int height, bool increment) const
{
for (expirationQueueRowType::iterator e = row.begin(); e != row.end(); ++e)
{
// remove and insert with new expiration time
removeFromExpirationQueue(e->name, e->outPoint, height);
int extend_expiration = Params().GetConsensus().nExtendedClaimExpirationTime - Params().GetConsensus().nOriginalClaimExpirationTime;
int new_expiration_height = increment ? height + extend_expiration : height - extend_expiration;
nameOutPointType entry(e->name, e->outPoint);
addToExpirationQueue(new_expiration_height, entry);
}
}
void CClaimTrieCache::removeAndAddSupportToExpirationQueue(expirationQueueRowType &row, int height, bool increment) const
{
for (expirationQueueRowType::iterator e = row.begin(); e != row.end(); ++e)
{
// remove and insert with new expiration time
removeSupportFromExpirationQueue(e->name, e->outPoint, height);
int extend_expiration = Params().GetConsensus().nExtendedClaimExpirationTime - Params().GetConsensus().nOriginalClaimExpirationTime;
int new_expiration_height = increment ? height + extend_expiration : height - extend_expiration;
nameOutPointType entry(e->name, e->outPoint);
addSupportToExpirationQueue(new_expiration_height, entry);
}
}
bool CClaimTrieCache::forkForExpirationChange(bool increment) const
{
/*
If increment is True, we have forked to extend the expiration time, thus items in the expiration queue
will have their expiration extended by "new expiration time - original expiration time"
If increment is False, we are decremented a block to reverse the fork. Thus items in the expiration queue
will have their expiration extension removed.
*/
// look through dirty expiration queues
std::set<int> dirtyHeights;
for (expirationQueueType::const_iterator i = base->dirtyExpirationQueueRows.begin(); i != base->dirtyExpirationQueueRows.end(); ++i)
{
int height = i->first;
dirtyHeights.insert(height);
expirationQueueRowType row = i->second;
removeAndAddToExpirationQueue(row, height, increment);
}
std::set<int> dirtySupportHeights;
for (expirationQueueType::const_iterator i = base->dirtySupportExpirationQueueRows.begin(); i != base->dirtySupportExpirationQueueRows.end(); ++i)
{
int height = i->first;
dirtySupportHeights.insert(height);
expirationQueueRowType row = i->second;
removeAndAddSupportToExpirationQueue(row, height, increment);
}
//look through db for expiration queues, if we haven't already found it in dirty expiration queue
boost::scoped_ptr<CDBIterator> pcursor(const_cast<CDBWrapper*>(&base->db)->NewIterator());
pcursor->SeekToFirst();
while (pcursor->Valid())
{
std::pair<char, int> key;
if (pcursor->GetKey(key))
{
int height = key.second;
// if we've looked through this in dirtyExprirationQueueRows, don't use it
// because its stale
if ((key.first == EXP_QUEUE_ROW) & (dirtyHeights.count(height) == 0))
{
expirationQueueRowType row;
if (pcursor->GetValue(row))
{
removeAndAddToExpirationQueue(row, height, increment);
}
else
{
return error("%s(): error reading expiration queue rows from disk", __func__);
}
}
else if ((key.first == SUPPORT_EXP_QUEUE_ROW) & (dirtySupportHeights.count(height) == 0))
{
expirationQueueRowType row;
if (pcursor->GetValue(row))
{
removeAndAddSupportToExpirationQueue(row, height, increment);
}
else
{
return error("%s(): error reading support expiration queue rows from disk", __func__);
}
}
}
pcursor->Next();
}
return true;
}
|
// Copyright (c) 2011-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparams.h>
#include <coins.h>
#include <consensus/consensus.h>
#include <consensus/merkle.h>
#include <consensus/tx_verify.h>
#include <miner.h>
#include <key/extkey.h>
#include <key/stealth.h>
#include <policy/policy.h>
#include <pubkey.h>
#include <script/standard.h>
#include <txmempool.h>
#include <uint256.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <validation.h>
#include <test/setup_common.h>
#include <memory>
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup)
// BOOST_CHECK_EXCEPTION predicates to check the specific validation error
class HasReason {
public:
explicit HasReason(const std::string& reason) : m_reason(reason) {}
bool operator() (const std::runtime_error& e) const {
return std::string(e.what()).find(m_reason) != std::string::npos;
};
private:
const std::string m_reason;
};
static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
static BlockAssembler AssemblerForTest(const CChainParams& params) {
BlockAssembler::Options options;
options.nBlockMaxWeight = MAX_BLOCK_WEIGHT;
options.blockMinFeeRate = blockMinFeeRate;
return BlockAssembler(params, options);
}
static
struct {
unsigned char extranonce;
unsigned int nonce;
} blockinfo[] = {
{4, 0xa4a3e223}, {2, 0x15c32f9e}, {1, 0x0375b547}, {1, 0x7004a8a5},
{2, 0xce440296}, {2, 0x52cfe198}, {1, 0x77a72cd0}, {2, 0xbb5d6f84},
{2, 0x83f30c2c}, {1, 0x48a73d5b}, {1, 0xef7dcd01}, {2, 0x6809c6c4},
{2, 0x0883ab3c}, {1, 0x087bbbe2}, {2, 0x2104a814}, {2, 0xdffb6daa},
{1, 0xee8a0a08}, {2, 0xba4237c1}, {1, 0xa70349dc}, {1, 0x344722bb},
{3, 0xd6294733}, {2, 0xec9f5c94}, {2, 0xca2fbc28}, {1, 0x6ba4f406},
{2, 0x015d4532}, {1, 0x6e119b7c}, {2, 0x43e8f314}, {2, 0x27962f38},
{2, 0xb571b51b}, {2, 0xb36bee23}, {2, 0xd17924a8}, {2, 0x6bc212d9},
{1, 0x630d4948}, {2, 0x9a4c4ebb}, {2, 0x554be537}, {1, 0xd63ddfc7},
{2, 0xa10acc11}, {1, 0x759a8363}, {2, 0xfb73090d}, {1, 0xe82c6a34},
{1, 0xe33e92d7}, {3, 0x658ef5cb}, {2, 0xba32ff22}, {5, 0x0227a10c},
{1, 0xa9a70155}, {5, 0xd096d809}, {1, 0x37176174}, {1, 0x830b8d0f},
{1, 0xc6e3910e}, {2, 0x823f3ca8}, {1, 0x99850849}, {1, 0x7521fb81},
{1, 0xaacaabab}, {1, 0xd645a2eb}, {5, 0x7aea1781}, {5, 0x9d6e4b78},
{1, 0x4ce90fd8}, {1, 0xabdc832d}, {6, 0x4a34f32a}, {2, 0xf2524c1c},
{2, 0x1bbeb08a}, {1, 0xad47f480}, {1, 0x9f026aeb}, {1, 0x15a95049},
{2, 0xd1cb95b2}, {2, 0xf84bbda5}, {1, 0x0fa62cd1}, {1, 0xe05f9169},
{1, 0x78d194a9}, {5, 0x3e38147b}, {5, 0x737ba0d4}, {1, 0x63378e10},
{1, 0x6d5f91cf}, {2, 0x88612eb8}, {2, 0xe9639484}, {1, 0xb7fabc9d},
{2, 0x19b01592}, {1, 0x5a90dd31}, {2, 0x5bd7e028}, {2, 0x94d00323},
{1, 0xa9b9c01a}, {1, 0x3a40de61}, {1, 0x56e7eec7}, {5, 0x859f7ef6},
{1, 0xfd8e5630}, {1, 0x2b0c9f7f}, {1, 0xba700e26}, {1, 0x7170a408},
{1, 0x70de86a8}, {1, 0x74d64cd5}, {1, 0x49e738a1}, {2, 0x6910b602},
{0, 0x643c565f}, {1, 0x54264b3f}, {2, 0x97ea6396}, {2, 0x55174459},
{2, 0x03e8779a}, {1, 0x98f34d8f}, {1, 0xc07b2b07}, {1, 0xdfe29668},
{1, 0x3141c7c1}, {1, 0xb3b595f4}, {1, 0x735abf08}, {5, 0x623bfbce},
{2, 0xd351e722}, {1, 0xf4ca48c9}, {1, 0x5b19c670}, {1, 0xa164bf0e},
{2, 0xbbbeb305}, {2, 0xfe1c810a},
};
static CBlockIndex CreateBlockIndex(int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
CBlockIndex index;
index.nHeight = nHeight;
index.pprev = ::ChainActive().Tip();
return index;
}
static bool TestSequenceLocks(const CTransaction &tx, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
LOCK(::mempool.cs);
return CheckSequenceLocks(::mempool, tx, flags);
}
// Test suite for ancestor feerate transaction selection.
// Implemented as an additional function, rather than a separate test case,
// to allow reusing the blockchain created in CreateNewBlock_validity.
static void TestPackageSelection(const CChainParams& chainparams, const CScript& scriptPubKey, const std::vector<CTransactionRef>& txFirst) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs)
{
// Test the ancestor feerate transaction selection.
TestMemPoolEntryHelper entry;
// Test that a medium fee transaction will be selected after a higher fee
// rate package with a low fee rate parent.
CMutableTransaction tx;
tx.vin.resize(1);
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].prevout.n = 0;
tx.vout.resize(1);
tx.vout[0].nValue = 5000000000LL - 1000;
// This tx has a low fee: 1000 satoshis
uint256 hashParentTx = tx.GetHash(); // save this txid for later use
mempool.addUnchecked(entry.Fee(1000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
// This tx has a medium fee: 10000 satoshis
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
tx.vout[0].nValue = 5000000000LL - 10000;
uint256 hashMediumFeeTx = tx.GetHash();
mempool.addUnchecked(entry.Fee(10000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
// This tx has a high fee, but depends on the first transaction
tx.vin[0].prevout.hash = hashParentTx;
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 50k satoshi fee
uint256 hashHighFeeTx = tx.GetHash();
mempool.addUnchecked(entry.Fee(50000).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashParentTx);
BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashHighFeeTx);
BOOST_CHECK(pblocktemplate->block.vtx[3]->GetHash() == hashMediumFeeTx);
// Test that a package below the block min tx fee doesn't get included
tx.vin[0].prevout.hash = hashHighFeeTx;
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 0 fee
uint256 hashFreeTx = tx.GetHash();
mempool.addUnchecked(entry.Fee(0).FromTx(tx));
size_t freeTxSize = ::GetSerializeSize(tx, PROTOCOL_VERSION);
// Calculate a fee on child transaction that will put the package just
// below the block min tx fee (assuming 1 child tx of the same size).
CAmount feeToUse = blockMinFeeRate.GetFee(2*freeTxSize) - 1;
tx.vin[0].prevout.hash = hashFreeTx;
tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
uint256 hashLowFeeTx = tx.GetHash();
mempool.addUnchecked(entry.Fee(feeToUse).FromTx(tx));
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
// Verify that the free tx and the low fee tx didn't get selected
for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx);
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx);
}
// Test that packages above the min relay fee do get included, even if one
// of the transactions is below the min relay fee
// Remove the low fee transaction and replace with a higher fee transaction
mempool.removeRecursive(CTransaction(tx));
tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee
hashLowFeeTx = tx.GetHash();
mempool.addUnchecked(entry.Fee(feeToUse+2).FromTx(tx));
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
BOOST_CHECK(pblocktemplate->block.vtx[4]->GetHash() == hashFreeTx);
BOOST_CHECK(pblocktemplate->block.vtx[5]->GetHash() == hashLowFeeTx);
// Test that transaction selection properly updates ancestor fee
// calculations as ancestor transactions get included in a block.
// Add a 0-fee transaction that has 2 outputs.
tx.vin[0].prevout.hash = txFirst[2]->GetHash();
tx.vout.resize(2);
tx.vout[0].nValue = 5000000000LL - 100000000;
tx.vout[1].nValue = 100000000; // 1BTC output
uint256 hashFreeTx2 = tx.GetHash();
mempool.addUnchecked(entry.Fee(0).SpendsCoinbase(true).FromTx(tx));
// This tx can't be mined by itself
tx.vin[0].prevout.hash = hashFreeTx2;
tx.vout.resize(1);
feeToUse = blockMinFeeRate.GetFee(freeTxSize);
tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
uint256 hashLowFeeTx2 = tx.GetHash();
mempool.addUnchecked(entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
// Verify that this tx isn't selected.
for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx2);
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx2);
}
// This tx will be mineable, and should cause hashLowFeeTx2 to be selected
// as well.
tx.vin[0].prevout.n = 1;
tx.vout[0].nValue = 100000000 - 10000; // 10k satoshi fee
mempool.addUnchecked(entry.Fee(10000).FromTx(tx));
pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
BOOST_CHECK(pblocktemplate->block.vtx[8]->GetHash() == hashLowFeeTx2);
}
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
{
// Note that by default, these tests run with size accounting enabled.
auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
SetOldParams(chainParams);
const CChainParams& chainparams = *chainParams;
CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
std::unique_ptr<CBlockTemplate> pblocktemplate;
CMutableTransaction tx;
CScript script;
uint256 hash;
TestMemPoolEntryHelper entry;
entry.nFee = 11;
entry.nHeight = 11;
fCheckpointsEnabled = false;
// Simple block creation, nothing special yet:
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
// We can't make transactions until we have inputs
// Therefore, load 100 blocks :)
int baseheight = 0;
std::vector<CTransactionRef> txFirst;
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
{
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
{
LOCK(cs_main);
pblock->nVersion = 1;
pblock->nTime = ::ChainActive().Tip()->GetMedianTimePast()+1;
CMutableTransaction txCoinbase(*pblock->vtx[0]);
txCoinbase.nVersion = 1;
txCoinbase.vin[0].scriptSig = CScript();
txCoinbase.vin[0].scriptSig.push_back(blockinfo[i].extranonce);
txCoinbase.vin[0].scriptSig.push_back(::ChainActive().Height());
txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this)
txCoinbase.vout[0].scriptPubKey = CScript();
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
if (txFirst.size() == 0)
baseheight = ::ChainActive().Height();
if (txFirst.size() < 4)
txFirst.push_back(pblock->vtx[0]);
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
pblock->nNonce = blockinfo[i].nonce;
}
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
BOOST_CHECK(ProcessNewBlock(chainparams, shared_pblock, true, nullptr));
pblock->hashPrevBlock = pblock->GetHash();
}
LOCK(cs_main);
LOCK(::mempool.cs);
// Just to make sure we can still make simple blocks
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
const CAmount BLOCKSUBSIDY = 50*COIN;
const CAmount LOWFEE = CENT;
const CAmount HIGHFEE = COIN;
const CAmount HIGHERFEE = 4*COIN;
// block sigops > limit: 1000 CHECKMULTISIG + 1
tx.vin.resize(1);
// NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG
tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP << OP_CHECKMULTISIG << OP_1;
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].prevout.n = 0;
tx.vout.resize(1);
tx.vout[0].nValue = BLOCKSUBSIDY;
for (unsigned int i = 0; i < 2001; ++i)
{
tx.vout[0].nValue -= LOWFEE;
hash = tx.GetHash();
bool spendsCoinbase = i == 0; // only first tx spends coinbase
// If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-blk-sigops"));
mempool.clear();
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vout[0].nValue = BLOCKSUBSIDY;
for (unsigned int i = 0; i < 1001; ++i)
{
tx.vout[0].nValue -= LOWFEE;
hash = tx.GetHash();
bool spendsCoinbase = i == 0; // only first tx spends coinbase
// If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).SigOpsCost(80).FromTx(tx));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
mempool.clear();
// block size > limit
tx.vin[0].scriptSig = CScript();
// 18 * (520char + DROP) + OP_1 = 9433 bytes
std::vector<unsigned char> vchData(520);
for (unsigned int i = 0; i < 18; ++i)
tx.vin[0].scriptSig << vchData << OP_DROP;
tx.vin[0].scriptSig << OP_1;
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vout[0].nValue = BLOCKSUBSIDY;
for (unsigned int i = 0; i < 128; ++i)
{
tx.vout[0].nValue -= LOWFEE;
hash = tx.GetHash();
bool spendsCoinbase = i == 0; // only first tx spends coinbase
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
mempool.clear();
// orphan in mempool, template creation fails
hash = tx.GetHash();
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx));
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
mempool.clear();
// child with higher feerate than parent
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
hash = tx.GetHash();
mempool.addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
tx.vin[0].prevout.hash = hash;
tx.vin.resize(2);
tx.vin[1].scriptSig = CScript() << OP_1;
tx.vin[1].prevout.hash = txFirst[0]->GetHash();
tx.vin[1].prevout.n = 0;
tx.vout[0].nValue = tx.vout[0].nValue+BLOCKSUBSIDY-HIGHERFEE; //First txn output + fresh coinbase - new txn fee
hash = tx.GetHash();
mempool.addUnchecked(entry.Fee(HIGHERFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
mempool.clear();
// coinbase in mempool, template creation fails
tx.vin.resize(1);
tx.vin[0].prevout.SetNull();
tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
tx.vout[0].nValue = 0;
hash = tx.GetHash();
// give it a fee so it'll get mined
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
// Should throw bad-cb-multiple
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-cb-multiple"));
mempool.clear();
// double spend txn pair in mempool, template creation fails
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
tx.vout[0].scriptPubKey = CScript() << OP_1;
hash = tx.GetHash();
mempool.addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
tx.vout[0].scriptPubKey = CScript() << OP_2;
hash = tx.GetHash();
mempool.addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
mempool.clear();
// subsidy changing
int nHeight = ::ChainActive().Height();
// Create an actual 209999-long block chain (without valid blocks).
while (::ChainActive().Tip()->nHeight < 209999) {
CBlockIndex* prev = ::ChainActive().Tip();
CBlockIndex* next = new CBlockIndex();
next->phashBlock = new uint256(InsecureRand256());
pcoinsTip->SetBestBlock(next->GetBlockHash(), prev->nHeight + 1);
next->pprev = prev;
next->nHeight = prev->nHeight + 1;
next->BuildSkip();
::ChainActive().SetTip(next);
}
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
// Extend to a 210000-long block chain.
while (::ChainActive().Tip()->nHeight < 210000) {
CBlockIndex* prev = ::ChainActive().Tip();
CBlockIndex* next = new CBlockIndex();
next->phashBlock = new uint256(InsecureRand256());
pcoinsTip->SetBestBlock(next->GetBlockHash(), prev->nHeight + 1);
next->pprev = prev;
next->nHeight = prev->nHeight + 1;
next->BuildSkip();
::ChainActive().SetTip(next);
}
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
// invalid p2sh txn in mempool, template creation fails
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].prevout.n = 0;
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vout[0].nValue = BLOCKSUBSIDY-LOWFEE;
script = CScript() << OP_0;
tx.vout[0].scriptPubKey = GetScriptForDestination(ScriptHash(script));
hash = tx.GetHash();
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
tx.vin[0].prevout.hash = hash;
tx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(script.begin(), script.end());
tx.vout[0].nValue -= LOWFEE;
hash = tx.GetHash();
mempool.addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
// Should throw block-validation-failed
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("block-validation-failed"));
mempool.clear();
// Delete the dummy blocks again.
while (::ChainActive().Tip()->nHeight > nHeight) {
CBlockIndex* del = ::ChainActive().Tip();
::ChainActive().SetTip(del->pprev);
pcoinsTip->SetBestBlock(del->pprev->GetBlockHash(), del->pprev->nHeight);
delete del->phashBlock;
delete del;
}
// non-final txs in mempool
SetMockTime(::ChainActive().Tip()->GetMedianTimePast()+1);
int flags = LOCKTIME_VERIFY_SEQUENCE|LOCKTIME_MEDIAN_TIME_PAST;
// height map
std::vector<int> prevheights;
// relative height locked
tx.nVersion = 2;
tx.vin.resize(1);
prevheights.resize(1);
tx.vin[0].prevout.hash = txFirst[0]->GetHash(); // only 1 transaction
tx.vin[0].prevout.n = 0;
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].nSequence = ::ChainActive().Tip()->nHeight + 1; // txFirst[0] is the 2nd block
prevheights[0] = baseheight + 1;
tx.vout.resize(1);
tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
tx.vout[0].scriptPubKey = CScript() << OP_1;
tx.nLockTime = 0;
hash = tx.GetHash();
mempool.addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, &prevheights, CreateBlockIndex(::ChainActive().Tip()->nHeight + 2))); // Sequence locks pass on 2nd block
// relative time locked
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | (((::ChainActive().Tip()->GetMedianTimePast()+1-::ChainActive()[1]->GetMedianTimePast()) >> CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) + 1); // txFirst[1] is the 3rd block
prevheights[0] = baseheight + 2;
hash = tx.GetHash();
mempool.addUnchecked(entry.Time(GetTime()).FromTx(tx));
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime += 512; //Trick the MedianTimePast
BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, &prevheights, CreateBlockIndex(::ChainActive().Tip()->nHeight + 1))); // Sequence locks pass 512 seconds later
for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime -= 512; //undo tricked MTP
// absolute height locked
tx.vin[0].prevout.hash = txFirst[2]->GetHash();
tx.vin[0].nSequence = CTxIn::SEQUENCE_FINAL - 1;
prevheights[0] = baseheight + 3;
tx.nLockTime = ::ChainActive().Tip()->nHeight + 1;
hash = tx.GetHash();
mempool.addUnchecked(entry.Time(GetTime()).FromTx(tx));
BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast())); // Locktime passes on 2nd block
// absolute time locked
tx.vin[0].prevout.hash = txFirst[3]->GetHash();
tx.nLockTime = ::ChainActive().Tip()->GetMedianTimePast();
prevheights.resize(1);
prevheights[0] = baseheight + 4;
hash = tx.GetHash();
mempool.addUnchecked(entry.Time(GetTime()).FromTx(tx));
BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast() + 1)); // Locktime passes 1 second later
// mempool-dependent transactions (not added)
tx.vin[0].prevout.hash = hash;
prevheights[0] = ::ChainActive().Tip()->nHeight + 1;
tx.nLockTime = 0;
tx.vin[0].nSequence = 0;
BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
tx.vin[0].nSequence = 1;
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG;
BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | 1;
BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
// None of the of the absolute height/time locked tx should have made
// it into the template because we still check IsFinalTx in CreateNewBlock,
// but relative locked txs will if inconsistently added to mempool.
// For now these will still generate a valid template until BIP68 soft fork
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 3U);
// However if we advance height by 1 and time by 512, all of them should be mined
for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime += 512; //Trick the MedianTimePast
::ChainActive().Tip()->nHeight++;
SetMockTime(::ChainActive().Tip()->GetMedianTimePast() + 1);
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5U);
::ChainActive().Tip()->nHeight--;
SetMockTime(0);
mempool.clear();
TestPackageSelection(chainparams, scriptPubKey, txFirst);
fCheckpointsEnabled = true;
}
BOOST_AUTO_TEST_SUITE_END()
|
/*=========================================================================
Program: Visualization Toolkit
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkNew.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkInteractorStyleImage.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkCamera.h"
#include "vtkImageData.h"
#include "vtkImageSliceMapper.h"
#include "vtkImageProperty.h"
#include "vtkImageSlice.h"
#include "vtkImageReader2.h"
#include "vtkOpenGLImageGradient.h"
#include "vtkPointData.h"
#include "vtkDataArray.h"
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
int TestOpenGLImageGradient(int argc, char *argv[])
{
vtkNew<vtkRenderWindowInteractor> iren;
vtkNew<vtkInteractorStyleImage> style;
style->SetInteractionModeToImageSlicing();
vtkNew<vtkRenderWindow> renWin;
iren->SetRenderWindow(renWin);
iren->SetInteractorStyle(style);
char* fname =
vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/headsq/quarter");
vtkNew<vtkImageReader2> reader;
reader->SetDataByteOrderToLittleEndian();
reader->SetDataExtent(0,63,0,63,1,93);
reader->SetDataSpacing(3.2, 3.2, 1.5);
reader->SetFilePrefix(fname);
delete [] fname;
vtkNew<vtkOpenGLImageGradient> filter;
// vtkNew<vtkImageGradient> filter;
filter->SetInputConnection(reader->GetOutputPort());
filter->Update();
// double *rnger = filter->GetOutput()->GetPointData()->GetScalars()->GetRange();
vtkNew<vtkImageSliceMapper> imageMapper;
imageMapper->SetInputConnection(filter->GetOutputPort());
imageMapper->SetOrientation(2);
imageMapper->SliceAtFocalPointOn();
vtkNew<vtkImageSlice> image;
image->SetMapper(imageMapper);
double range[2] = { -100, 100 };
image->GetProperty()->SetColorWindow(range[1] - range[0]);
image->GetProperty()->SetColorLevel(0.5*(range[0] + range[1]));
image->GetProperty()->SetInterpolationTypeToNearest();
vtkNew<vtkRenderer> renderer;
renderer->AddViewProp(image);
renderer->SetBackground(0.2,0.3,0.4);
renWin->AddRenderer(renderer);
const double *bounds = imageMapper->GetBounds();
double point[3];
point[0] = 0.5*(bounds[0] + bounds[1]);
point[1] = 0.5*(bounds[2] + bounds[3]);
point[2] = 0.5*(bounds[4] + bounds[5]);
vtkCamera *camera = renderer->GetActiveCamera();
camera->SetFocalPoint(point);
point[imageMapper->GetOrientation()] += 500.0;
camera->SetPosition(point);
if (imageMapper->GetOrientation() == 2)
{
camera->SetViewUp(0.0, 1.0, 0.0);
}
else
{
camera->SetViewUp(0.0, 0.0, -1.0);
}
camera->ParallelProjectionOn();
camera->SetParallelScale(0.8*128);
renWin->SetSize(512,512);
iren->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage( renWin );
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
|
/*
Copyright 2017-present Zoltan Somogyi (AI-TOOLKIT), All Rights Reserved
You may use this file only if you agree to the software license:
AI-TOOLKIT Open Source Software License - Version 2.1 - February 22, 2018:
https://ai-toolkit.blogspot.com/p/ai-toolkit-open-source-software-license.html.
Also included with the source code distribution in AI-TOOLKIT-LICENSE.txt.
Based on : Copyright 2009-2011 Microsoft Corporation, Apache 2.0
2014 Hainan Xu
See ../../COPYING for clarification regarding multiple authors
*/
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "matrix/kaldi-matrix.h"
#include "kaldi-win/src/kaldi_src.h"
using namespace kaldi;
int32 CopyIncludedFeats(std::string filename,
SequentialBaseFloatMatrixReader *kaldi_reader,
BaseFloatMatrixWriter *kaldi_writer, fs::ofstream & file_log) {
unordered_set<std::string, StringHasher> include_set;
bool binary;
Input ki(filename, &binary);
KALDI_ASSERT(!binary);
std::string line;
while (std::getline(ki.Stream(), line)) {
std::vector<std::string> split_line;
SplitStringToVector(line, " \t\r", true, &split_line);
KALDI_ASSERT(!split_line.empty() &&
"Empty line encountered in input from --include option");
include_set.insert(split_line[0]);
}
int32 num_total = 0;
size_t num_success = 0;
for (; !kaldi_reader->Done(); kaldi_reader->Next(), num_total++) {
if (include_set.count(kaldi_reader->Key()) > 0) {
kaldi_writer->Write(kaldi_reader->Key(), kaldi_reader->Value());
num_success++;
}
}
if(file_log)
file_log << "Wrote " << num_success << " out of " << num_total << " utterances.";
else
KALDI_LOG << "Wrote " << num_success << " out of " << num_total << " utterances.";
return (num_success != 0 ? 0 : 1);
}
int32 CopyExcludedFeats(std::string filename,
SequentialBaseFloatMatrixReader *kaldi_reader,
BaseFloatMatrixWriter *kaldi_writer, fs::ofstream & file_log) {
unordered_set<std::string, StringHasher> exclude_set;
bool binary;
Input ki(filename, &binary);
KALDI_ASSERT(!binary);
std::string line;
while (std::getline(ki.Stream(), line)) {
std::vector<std::string> split_line;
SplitStringToVector(line, " \t\r", true, &split_line);
KALDI_ASSERT(!split_line.empty() &&
"Empty line encountered in input from --include option");
exclude_set.insert(split_line[0]);
}
int32 num_total = 0;
size_t num_success = 0;
for (; !kaldi_reader->Done(); kaldi_reader->Next(), num_total++) {
if (exclude_set.count(kaldi_reader->Key()) == 0) {
kaldi_writer->Write(kaldi_reader->Key(), kaldi_reader->Value());
num_success++;
}
}
if(file_log)
file_log << "Wrote " << num_success << " out of " << num_total << " utterances.";
else
KALDI_LOG << "Wrote " << num_success << " out of " << num_total << " utterances.";
return (num_success != 0 ? 0 : 1);
}
int SubsetFeats(int argc, char *argv[], fs::ofstream & file_log) {
try {
using namespace kaldi;
const char *usage =
"Copy a subset of features (by default, the first n feature files)\n"
"Usually used where only a small amount of data is needed\n"
"Note: if you want a specific subset, it's usually best to\n"
"filter the original .scp file with utils/filter_scp.pl\n"
"(possibly with the --exclude option). The --include and --exclude\n"
"options of this program are intended for specialized uses.\n"
"The --include and --exclude options are mutually exclusive, \n"
"and both cause the --n option to be ignored.\n"
"Usage: subset-feats [options] <in-rspecifier> <out-wspecifier>\n"
"e.g.: subset-feats --n=10 ark:- ark:-\n"
"or: subset-feats --include=include_uttlist ark:- ark:-\n"
"or: subset-feats --exclude=exclude_uttlist ark:- ark:-\n"
"See also extract-feature-segments, select-feats, subsample-feats\n";
ParseOptions po(usage);
int32 n = 10;
std::string include_rxfilename;
std::string exclude_rxfilename;
po.Register("n", &n, "If nonnegative, copy the first n feature files.");
po.Register("include", &include_rxfilename,
"Text file, the first field of each"
" line being interpreted as an "
"utterance-id whose features will be included");
po.Register("exclude", &exclude_rxfilename,
"Text file, the first field of each "
"line being interpreted as an utterance-id"
" whose features will be excluded");
po.Read(argc, argv);
if (po.NumArgs() != 2) {
//po.PrintUsage();
//exit(1);
KALDI_ERR << "Wrong arguments.";
return -1;
}
std::string rspecifier = po.GetArg(1);
std::string wspecifier = po.GetArg(2);
KALDI_ASSERT(n >= 0);
BaseFloatMatrixWriter kaldi_writer(wspecifier);
SequentialBaseFloatMatrixReader kaldi_reader(rspecifier);
if (include_rxfilename != "") {
if (n != 10) {
KALDI_ERR << "Should not have both --include and --n option!";
return -1; //VB
}
if (exclude_rxfilename != "") {
KALDI_ERR << "should not have both --exclude and --include option!";
return -1; //VB
}
return CopyIncludedFeats(include_rxfilename,
&kaldi_reader, &kaldi_writer, file_log);
}
else if (exclude_rxfilename != "") {
if (n != 10) {
KALDI_ERR << "Should not have both --exclude and --n option!";
return -1; //VB
}
return CopyExcludedFeats(exclude_rxfilename,
&kaldi_reader, &kaldi_writer, file_log);
}
if (n == 0) {
KALDI_ERR << "Invalid option --n=0. Should be at least 1";
return -1; //VB
}
int32 k = 0;
for (; !kaldi_reader.Done() && k < n; kaldi_reader.Next(), k++)
kaldi_writer.Write(kaldi_reader.Key(), kaldi_reader.Value());
return 0;
} catch(const std::exception &e) {
KALDI_ERR << e.what();
return -1;
}
}
|
/* console Trainer for RL Competition
* Copyright (C) 2007, Brian Tanner brian@tannerpages.com (http://brian.tannerpages.com/)
*
* This program 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#include "consoleTrainerHelper.h"
#include <sstream>
#include "ParameterHolder.h"
#include <rlglue/RL_glue.h>
#include <cstring>
#define BENCHMARK 0
#define ENVSHELL 1
#define LISTQUERY 1
#define NOVALUE 3
#define STRINGLIST 0
#define LOADQUERY 2
#define UNLOADQUERY 3
void load(std::string envNameString, ParameterHolder *theParams){
char theRequest[2048]={0};
std::string loadPayLoad=envNameString+":"+theParams->stringSerialize();
printf("Payload we are sending is:\n%s\n",loadPayLoad.c_str());
sprintf(theRequest,"TO=%d FROM=%d CMD=%d VALTYPE=%d VALS=%s",ENVSHELL, BENCHMARK, LOADQUERY, STRINGLIST,loadPayLoad.c_str());
printf("The request is: \n%s\nLength:%d\n",theRequest,(int)strlen(theRequest));
RL_env_message(theRequest);
}
ParameterHolder *preload(std::string envNameString){
char theRequest[2048]={0};
sprintf(theRequest,"TO=%d FROM=%d CMD=%d VALTYPE=%d VALS=NULL",ENVSHELL, BENCHMARK, LISTQUERY, NOVALUE);
std::string theResponse=std::string(RL_env_message(theRequest));
std::string::size_type lastColonPos = theResponse.find_last_of ("=");
std::string thePayLoad=theResponse.substr(lastColonPos+1);
std::vector<std::string> payLoadVector;
std::string thisItem;
std::istringstream iss(thePayLoad);
while (getline(iss,thisItem,':'))
{
payLoadVector.push_back (thisItem);
}
std::vector<std::string> theNames;
std::vector<ParameterHolder *> theParamHolders;
for(size_t i=1;i<payLoadVector.size();i+=2){
theNames.push_back(payLoadVector[i]);
theParamHolders.push_back(new ParameterHolder(payLoadVector[i+1]));
}
unsigned int indexOfMyEnv=0;
for(unsigned int i=0;i<theNames.size();i++){
if(theNames[i]==envNameString){
indexOfMyEnv=i;
}
}
return theParamHolders[indexOfMyEnv];
}
void preloadAndLoad(std::string envNameString){
ParameterHolder *p=preload(envNameString);
load(envNameString,p);
}
/*
* Tetris has an integer parameter called pnum that takes values in [0,19]
* Setting this parameter changes the exact tetris problem you are solving
*/
void loadTetris(int whichParamSet){
std::string theEnvString="GeneralizedTetris - Java";
ParameterHolder *theParams=preload(theEnvString);
theParams->setIntegerParam("pnum",whichParamSet);
load(theEnvString, theParams);
}
void loadMario(int levelSeed, int levelType, int levelDifficulty, int instance){
std::string theEnvString="GeneralizedMario - Java";
ParameterHolder *theParams=preload(theEnvString);
theParams->setIntegerParam("fast",1);
theParams->setIntegerParam("dark",1);
theParams->setIntegerParam("level seed",levelSeed);
theParams->setIntegerParam("level difficulty",levelType);
theParams->setIntegerParam("level type",levelDifficulty);
theParams->setIntegerParam("instance",instance);
load(theEnvString, theParams);
}
void loadOctopus(){
std::string theEnvString="Octopus - Java";
ParameterHolder *theParams=preload(theEnvString);
load(theEnvString, theParams);
}
/*
* Acrobot has an integer parameter called pnum that takes values in [0,39]
* Setting this parameter changes the exact acrobot problem you are solving
*/
void loadAcrobot(int whichParamSet){
std::string theEnvString="GeneralizedAcrobot - Java";
ParameterHolder *theParams=preload(theEnvString);
theParams->setIntegerParam("pnum",whichParamSet);
load(theEnvString, theParams);
}
/*
* Helicopter has an integer parameter called pnum that takes values in [0,9]
* Setting this parameter changes the exact helicopter problem you are solving
*/
void loadHelicopter(int whichParamSet){
std::string theEnvString="GeneralizedHelicopter - Java";
ParameterHolder *theParams=preload(theEnvString);
theParams->setIntegerParam("pnum",whichParamSet);
load(theEnvString, theParams);
}
void loadPolyathlon(int whichParamSet){
std::string theEnvString="TrainingPolyathlon - Java";
ParameterHolder *theParams=preload(theEnvString);
theParams->setIntegerParam("whichDomain",whichParamSet);
load(theEnvString, theParams);
}
|
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2021, PickNik, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of PickNik 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.
*********************************************************************/
/* Author: Tyler Weaver */
#include <chrono>
#include <string>
#include <tf2_ros/qos.hpp>
#include <rclcpp/rclcpp.hpp>
#include <moveit/planning_scene_monitor/current_state_monitor_middleware_handle.hpp>
namespace planning_scene_monitor
{
namespace
{
static const auto SUBSCRIPTION_QOS = rclcpp::QoS(25);
}
CurrentStateMonitorMiddlewareHandle::CurrentStateMonitorMiddlewareHandle(const rclcpp::Node::SharedPtr& node)
: node_(node)
{
}
rclcpp::Time CurrentStateMonitorMiddlewareHandle::now() const
{
return node_->now();
}
void CurrentStateMonitorMiddlewareHandle::createJointStateSubscription(const std::string& topic,
JointStateUpdateCallback callback)
{
joint_state_subscription_ =
node_->create_subscription<sensor_msgs::msg::JointState>(topic, SUBSCRIPTION_QOS, callback);
}
void CurrentStateMonitorMiddlewareHandle::resetJointStateSubscription()
{
joint_state_subscription_.reset();
}
std::string CurrentStateMonitorMiddlewareHandle::getJointStateTopicName() const
{
if (joint_state_subscription_)
{
return joint_state_subscription_->get_topic_name();
}
else
{
return "";
}
}
bool CurrentStateMonitorMiddlewareHandle::sleepFor(const std::chrono::nanoseconds& nanoseconds) const
{
return rclcpp::sleep_for(nanoseconds);
}
void CurrentStateMonitorMiddlewareHandle::createDynamicTfSubscription(TfCallback callback)
{
transform_subscriber_ =
node_->create_subscription<tf2_msgs::msg::TFMessage>("/tf", tf2_ros::DynamicListenerQoS(), callback);
}
void CurrentStateMonitorMiddlewareHandle::createStaticTfSubscription(TfCallback callback)
{
static_transform_subscriber_ =
node_->create_subscription<tf2_msgs::msg::TFMessage>("/tf_static", tf2_ros::StaticListenerQoS(), callback);
}
std::string CurrentStateMonitorMiddlewareHandle::getStaticTfTopicName() const
{
return static_transform_subscriber_ ? static_transform_subscriber_->get_topic_name() : "";
}
std::string CurrentStateMonitorMiddlewareHandle::getDynamicTfTopicName() const
{
return transform_subscriber_ ? transform_subscriber_->get_topic_name() : "";
}
void CurrentStateMonitorMiddlewareHandle::resetTfSubscriptions()
{
transform_subscriber_.reset();
static_transform_subscriber_.reset();
}
} // namespace planning_scene_monitor
|
#pragma comment(linker, "/stack:640000000")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI=acos(-1.0);
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define MP(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define rep(i,n) for(int i = 1 ; i<=(n) ; i++)
#define repI(i,n) for(int i = 0 ; i<(n) ; i++)
#define FOR(i,L,R) for (int i = (int)(L); i <= (int)(R); i++)
#define ROF(i,L,R) for (int i = (int)(L); i >= (int)(R); i--)
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define ALL(p) p.begin(),p.end()
#define ALLR(p) p.rbegin(),p.rend()
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define getC(n) scanf("%c",&n)
#define getF(n) scanf("%lf",&n)
#define getS(n) scanf("%s",n)
#define bitCheck(N,in) ((bool)(N&(1<<(in))))
#define bitOff(N,in) (N&(~(1<<(in))))
#define bitOn(N,in) (N|(1<<(in)))
#define bitCount(a) __builtin_popcount(a)
#define iseq(a,b) (fabs(a-b)<EPS)
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define vi vector < int >
#define vii vector < vector < int > >
#define pii pair< int, int >
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
template< class T > inline T _abs(T n) { return ((n) < 0 ? -(n) : (n)); }
template< class T > inline T _max(T a, T b) { return (!((a)<(b))?(a):(b)); }
template< class T > inline T _min(T a, T b) { return (((a)<(b))?(a):(b)); }
template< class T > inline T _swap(T &a, T &b) { a=a^b;b=a^b;a=a^b;}
template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
#ifdef dipta007
#define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;}
#else
#define debug(args...) // Just strip off all debug tokens
#endif
struct debugger{
template<typename T> debugger& operator , (const T& v){
cerr<<v<<" ";
return *this;
}
}dbg;
int arr[1000004];
int main() {
#ifdef dipta007
//READ("in.txt");
// WRITE("in.txt");
#endif // dipta007
ios_base::sync_with_stdio(0);cin.tie(0);
int k;
while(cin >> k)
{
string st;
cin >> st;
int len = st.size()-1;
st += "##";
arr[len+1]=0;
ROF(i,len,0)
{
if(st[i]==st[i+2])
{
arr[i] = arr[i+1]+1;
}
else
{
if(i==len) arr[i]=1;
else arr[i]=2;
}
}
int res = 0;
FOR(i,0,len)
{
int now = arr[i];
debug(i,now)
int left = i;
int right = (len+1) - (i+arr[i]);
int mx = max(left, right);
mx = min(mx, k);
res = max(res, arr[i]+mx);
}
printf("%d\n",res);
}
return 0;
}
|
/*=========================================================================
*
* Copyright Insight Software Consortium
*
* 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.txt
*
* 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 <fstream>
#include "itkPointSetToListSampleAdaptor.h"
int itkPointSetToListSampleAdaptorTest( int, char * [] )
{
typedef itk::PointSet< double, 3 > PointSetType;
typedef itk::Statistics::PointSetToListSampleAdaptor< PointSetType > PointSetToListSampleAdaptorType;
PointSetType::Pointer pointSet = PointSetType::New();
PointSetType::PointType point;
unsigned int numberOfPoints=10;
for( unsigned int i=0; i < numberOfPoints; i++ )
{
point[0] = i*3;
point[1] = i*3 + 1;
point[2] = i*3 + 2;
pointSet->SetPoint( i, point );
}
PointSetToListSampleAdaptorType::Pointer listSample = PointSetToListSampleAdaptorType::New();
bool exceptionsProperlyCaught=true;
//Test if the methods throw exceptions if invoked before setting the pointset
try
{
// Purposely calling the Size() method in order to trigger an exception.
listSample->Size();
std::cerr << "Exception should have been thrown since the input point set \
is not set yet" << std::endl;
exceptionsProperlyCaught=false;
}
catch ( itk::ExceptionObject & excp )
{
std::cerr << "Caught expected exception: " << excp << std::endl;
}
try
{
// Purposely calling the GetTotalFrequency() method in order to trigger an exception.
listSample->GetTotalFrequency();
std::cerr << "Exception should have been thrown since the input point set \
is not set yet" << std::endl;
exceptionsProperlyCaught=false;
}
catch ( itk::ExceptionObject & excp )
{
std::cerr << "Caught expected exception: " << excp << std::endl;
}
try
{
PointSetToListSampleAdaptorType::MeasurementVectorType m = listSample->GetMeasurementVector( 0 );
std::cerr << "Exception should have been thrown since the input point set \
is not set yet" << std::endl;
std::cerr << "The invalid listSample->GetMeasurementVector is: " << m << std::endl;
exceptionsProperlyCaught=false;
}
catch ( itk::ExceptionObject & excp )
{
std::cerr << "Caught expected exception: " << excp << std::endl;
}
try
{
// Purposely calling the GetPointSet() method in order to trigger an exception.
listSample->GetPointSet();
std::cerr << "Exception should have been thrown since the input point set \
is not set yet" << std::endl;
exceptionsProperlyCaught=false;
}
catch ( itk::ExceptionObject & excp )
{
std::cerr << "Caught expected exception: " << excp << std::endl;
}
try
{
// Purposely calling the GetFrequency() method in order to trigger an exception.
listSample->GetFrequency(0 );
std::cerr << "Exception should have been thrown since the input point set \
is not set yet" << std::endl;
exceptionsProperlyCaught=false;
}
catch ( itk::ExceptionObject & excp )
{
std::cerr << "Caught expected exception: " << excp << std::endl;
}
if( ! exceptionsProperlyCaught )
{
std::cerr << "At least one exception that should have been caught was not." << std::endl;
return EXIT_FAILURE;
}
listSample->SetPointSet( pointSet.GetPointer() );
//exercise returned pointset
const PointSetToListSampleAdaptorType::PointSetType * pointSetReturned = listSample->GetPointSet( );
//check for NULL
if( pointSetReturned == NULL )
{
std::cerr << "GetPointSet() returned a NULL pointer"<< std::endl;
return EXIT_FAILURE;
}
//check size
if (numberOfPoints != listSample->Size())
{
std::cerr << "Size() is not returning the correct size"<< std::endl;
return EXIT_FAILURE;
}
//check frequency
if ( listSample->GetFrequency( 0 ) != 1 )
{
std::cerr << "GetFrequency() is not returning the correct frequency"<< std::endl;
return EXIT_FAILURE;
}
//check frequency
if (numberOfPoints != listSample->GetTotalFrequency())
{
std::cerr << "GetTotalFrequency() is not returning the correct frequency"<< std::endl;
return EXIT_FAILURE;
}
listSample->Print( std::cout );
for( unsigned int i=0; i < numberOfPoints; i++ )
{
PointSetToListSampleAdaptorType::InstanceIdentifier id = i;
PointSetType::PointType tempPointSet;
pointSet->GetPoint( i, &tempPointSet );
if ( listSample->GetMeasurementVector( id ) != tempPointSet )
{
std::cerr << "Error in point set accessed by the adaptor" << std::endl;
return EXIT_FAILURE;
}
}
//Test the iterators
std::cerr << "Iterators..." << std::endl;
{
// forward iterator
typedef PointSetToListSampleAdaptorType::Iterator IteratorType;
IteratorType s_iter = listSample->Begin();
// copy constructor
IteratorType bs_iter(s_iter);
if (bs_iter != s_iter)
{
std::cerr << "Iterator::Copy Constructor failed" << std::endl;
return EXIT_FAILURE;
}
// assignment operator
IteratorType assignment_iter( bs_iter );
assignment_iter = s_iter;
if (assignment_iter != s_iter)
{
std::cerr << "Iterator::assignment operator failed" << std::endl;
return EXIT_FAILURE;
}
PointSetToListSampleAdaptorType::InstanceIdentifier id = 0;
while (s_iter != listSample->End())
{
if (listSample->GetMeasurementVector(id) !=
s_iter.GetMeasurementVector())
{
std::cerr << "Iterator::GetMeasurementVector (forward) failed"
<< std::endl;
return EXIT_FAILURE;
}
if (id != s_iter.GetInstanceIdentifier())
{
std::cerr << "Iterator::GetInstanceIdentifier (forward) failed"
<< std::endl;
return EXIT_FAILURE;
}
if (s_iter.GetFrequency() != 1)
{
std::cerr << "Iterator::GetFrequency (forward) failed" << std::endl;
return EXIT_FAILURE;
}
if (listSample->GetFrequency(id) != 1)
{
std::cerr << "GetFrequency (forward) failed" << std::endl;
return EXIT_FAILURE;
}
++id;
++s_iter;
}
if (s_iter != listSample->End())
{
std::cerr << "Iterator::End (forward) failed" << std::endl;
return EXIT_FAILURE;
}
}
std::cerr << "Const Iterators..." << std::endl;
{
// forward iterator
typedef PointSetToListSampleAdaptorType::ConstIterator ConstIteratorType;
ConstIteratorType s_iter = listSample->Begin();
// copy constructor
ConstIteratorType bs_iter(s_iter);
if (bs_iter != s_iter)
{
std::cerr << "Iterator::Copy Constructor (from const) failed"
<< std::endl;
return EXIT_FAILURE;
}
// assignment operator
ConstIteratorType assignment_iter( bs_iter );
assignment_iter = s_iter;
if (assignment_iter != s_iter)
{
std::cerr << "Const Iterator::operator= () failed"
<< std::endl;
return EXIT_FAILURE;
}
// copy from non-const iterator
PointSetToListSampleAdaptorType::Iterator nonconst_iter = listSample->Begin();
PointSetToListSampleAdaptorType::ConstIterator s2_iter(nonconst_iter);
if (s2_iter != s_iter)
{
std::cerr << "Iterator::Copy Constructor (from non-const) failed"
<< std::endl;
return EXIT_FAILURE;
}
// assignment from non-const iterator
s2_iter = nonconst_iter;
if (s2_iter != s_iter)
{
std::cerr << "Iterator::assignment (from non-const) failed" << std::endl;
return EXIT_FAILURE;
}
PointSetToListSampleAdaptorType::InstanceIdentifier id = 0;
while (s_iter != listSample->End())
{
if (listSample->GetMeasurementVector(id) !=
s_iter.GetMeasurementVector())
{
std::cerr << "Iterator::GetMeasurementVector (forward) failed"
<< std::endl;
return EXIT_FAILURE;
}
if (id != s_iter.GetInstanceIdentifier())
{
std::cerr << "Iterator::GetInstanceIdentifier (forward) failed"
<< std::endl;
return EXIT_FAILURE;
}
if (s_iter.GetFrequency() != 1)
{
std::cerr << "Iterator::GetFrequency (forward) failed" << std::endl;
return EXIT_FAILURE;
}
++id;
++s_iter;
}
if (s_iter != listSample->End())
{
std::cerr << "Iterator::End (forward) failed" << std::endl;
return EXIT_FAILURE;
}
}
std::cout << "Test passed." << std::endl;
return EXIT_SUCCESS;
}
|
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* 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 "Power.h"
#include "Implementation.h"
namespace WPEFramework {
namespace Plugin {
SERVICE_REGISTRATION(Power, 1, 0);
static Core::ProxyPoolType<Web::JSONBodyType<Power::Data>> jsonBodyDataFactory(2);
static Core::ProxyPoolType<Web::JSONBodyType<Power::Data>> jsonResponseFactory(4);
extern "C" {
static void PowerStateChange(void* userData, enum WPEFramework::Exchange::IPower::PCState newState) {
reinterpret_cast<Power*>(userData)->PowerChange(newState);
}
}
/* virtual */ const string Power::Initialize(PluginHost::IShell* service)
{
string message;
ASSERT(_service == nullptr);
// Setup skip URL for right offset.
_service = service;
_skipURL = static_cast<uint8_t>(_service->WebPrefix().length());
Config config;
config.FromString(_service->ConfigLine());
_powerKey = config.PowerKey.Value();
_powerOffMode = config.OffMode.Value();
_controlClients = config.ControlClients.Value();
if (_powerKey != KEY_RESERVED) {
PluginHost::VirtualInput* keyHandler(PluginHost::InputHandler::Handler());
ASSERT(keyHandler != nullptr);
keyHandler->Register(&_sink, _powerKey);
}
// Receive all plugin information on state changes.
_service->Register(&_sink);
power_initialize(PowerStateChange, this, _service->ConfigLine().c_str());
return message;
}
/* virtual */ void Power::Deinitialize(PluginHost::IShell* service)
{
ASSERT(_service == service);
// No need to monitor the Process::Notification anymore, we will kill it anyway.
_service->Unregister(&_sink);
// Remove all registered clients
_clients.clear();
if (_powerKey != KEY_RESERVED) {
// Also we are nolonger interested in the powerkey events, we have been requested to shut down our services!
PluginHost::VirtualInput* keyHandler(PluginHost::InputHandler::Handler());
ASSERT(keyHandler != nullptr);
keyHandler->Unregister(&_sink, _powerKey);
}
power_deinitialize();
_service = nullptr;
}
/* virtual */ string Power::Information() const
{
// No additional info to report.
return (string());
}
/* virtual */ void Power::Inbound(Web::Request& request)
{
if (request.Verb == Web::Request::HTTP_POST)
request.Body(jsonBodyDataFactory.Element());
}
/* virtual */ Core::ProxyType<Web::Response> Power::Process(const Web::Request& request)
{
ASSERT(_skipURL <= request.Path.length());
Core::ProxyType<Web::Response> result(PluginHost::IFactories::Instance().Response());
Core::TextSegmentIterator index(
Core::TextFragment(request.Path, _skipURL, request.Path.length() - _skipURL), false, '/');
result->ErrorCode = Web::STATUS_BAD_REQUEST;
result->Message = "Unknown error";
if ((request.Verb == Web::Request::HTTP_GET) && ((index.Next() == true) && (index.Next() == true))) {
result->ErrorCode = Web::STATUS_OK;
result->Message = "OK";
if (index.Remainder() == _T("State")) {
Core::ProxyType<Web::JSONBodyType<Data>> response(jsonResponseFactory.Element());
response->PowerState = power_get_state();
if (response->PowerState) {
result->ContentType = Web::MIMETypes::MIME_JSON;
result->Body(Core::proxy_cast<Web::IBody>(response));
} else {
result->Message = "Invalid State";
}
} else {
result->ErrorCode = Web::STATUS_BAD_REQUEST;
result->Message = "Unknown error";
}
} else if ((request.Verb == Web::Request::HTTP_POST) && (index.Next() == true) && (index.Next() == true)) {
result->ErrorCode = Web::STATUS_OK;
result->Message = "OK";
if (index.Remainder() == _T("State")) {
uint32_t timeout = request.Body<const Data>()->Timeout.Value();
Exchange::IPower::PCState state = static_cast<Exchange::IPower::PCState>(request.Body<const Data>()->PowerState.Value());
ControlClients(state);
Core::ProxyType<Web::JSONBodyType<Data>> response(jsonResponseFactory.Element());
response->Status = SetState(state, timeout);
result->ContentType = Web::MIMETypes::MIME_JSON;
result->Body(Core::proxy_cast<Web::IBody>(response));
} else {
result->ErrorCode = Web::STATUS_BAD_REQUEST;
result->Message = "Unknown error";
}
}
return result;
}
void Power::Register(Exchange::IPower::INotification* sink)
{
_adminLock.Lock();
// Make sure a sink is not registered multiple times.
ASSERT(std::find(_notificationClients.begin(), _notificationClients.end(), sink) == _notificationClients.end());
_notificationClients.push_back(sink);
sink->AddRef();
_adminLock.Unlock();
TRACE(Trace::Information, (_T("Registered a sink on the power")));
}
void Power::Unregister(Exchange::IPower::INotification* sink)
{
_adminLock.Lock();
std::list<Exchange::IPower::INotification*>::iterator index(std::find(_notificationClients.begin(), _notificationClients.end(), sink));
// Make sure you do not unregister something you did not register !!!
ASSERT(index != _notificationClients.end());
if (index != _notificationClients.end()) {
(*index)->Release();
_notificationClients.erase(index);
TRACE(Trace::Information, (_T("Unregistered a sink on the power")));
}
_adminLock.Unlock();
}
Exchange::IPower::PCState Power::GetState() const /* override */ {
return (power_get_state());
}
uint32_t Power::SetState(const Exchange::IPower::PCState state, const uint32_t waitTime) /* override */ {
uint32_t result = Core::ERROR_ILLEGAL_STATE;
if (power_get_state() == state) {
TRACE(Trace::Information, (_T("No need to change power states, we are already at this stage!")));
}
else {
_adminLock.Unlock();
std::list<Exchange::IPower::INotification*>::iterator index(_notificationClients.begin());
while (index != _notificationClients.end()) {
(*index)->StateChange(state);
index++;
}
_adminLock.Unlock();
if (state != Exchange::IPower::PCState::On) {
ControlClients(state);
}
if ( (result = power_set_state(state, waitTime)) != Core::ERROR_NONE) {
TRACE(Trace::Information, (_T("Could not change the power state, error: %d"), result));
}
}
return (result);
}
void Power::PowerChange(const Exchange::IPower::PCState state) {
if (state == Exchange::IPower::PCState::On) {
ControlClients(state);
}
_adminLock.Lock();
std::list<Exchange::IPower::INotification*>::iterator index(_notificationClients.begin());
while (index != _notificationClients.end()) {
(*index)->StateChange(state);
index++;
}
_adminLock.Unlock();
}
void Power::PowerKey() /* override */ {
if (power_get_state() == Exchange::IPower::PCState::On) {
// Maybe this value should be coming from the config :-)
SetState(_powerOffMode, ~0);
}
else {
SetState(Exchange::IPower::PCState::On, 0);
}
}
void Power::KeyEvent(const uint32_t keyCode)
{
// We only subscribed for the KEY_POWER event so do not
// expect anything else !!!
ASSERT(keyCode == KEY_POWER)
if (keyCode == KEY_POWER) {
PowerKey();
}
}
void Power::StateChange(PluginHost::IShell* plugin)
{
const string callsign(plugin->Callsign());
_adminLock.Lock();
Clients::iterator index(_clients.find(callsign));
if (plugin->State() == PluginHost::IShell::ACTIVATED) {
if (index == _clients.end()) {
PluginHost::IStateControl* stateControl(plugin->QueryInterface<PluginHost::IStateControl>());
if (stateControl != nullptr) {
_clients.emplace(std::piecewise_construct,
std::forward_as_tuple(callsign),
std::forward_as_tuple(stateControl));
TRACE(Trace::Information, (_T("%s plugin is add to power control list"), callsign.c_str()));
stateControl->Release();
}
}
} else if (plugin->State() == PluginHost::IShell::DEACTIVATED) {
if (index != _clients.end()) { // Remove from the list, if it is already there
_clients.erase(index);
TRACE(Trace::Information, (_T("%s plugin is removed from power control list"), plugin->Callsign().c_str()));
}
}
_adminLock.Unlock();
}
void Power::ControlClients(Exchange::IPower::PCState state)
{
if (_controlClients) {
Clients::iterator client(_clients.begin());
switch (state) {
case Exchange::IPower::PCState::On:
TRACE(Trace::Information, (_T("Change state to RESUME for")));
while (client != _clients.end()) {
client->second.Resume();
client++;
}
//Nothing to be done
break;
case Exchange::IPower::PCState::ActiveStandby:
case Exchange::IPower::PCState::PassiveStandby:
case Exchange::IPower::PCState::SuspendToRAM:
case Exchange::IPower::PCState::Hibernate:
case Exchange::IPower::PCState::PowerOff:
while (client != _clients.end()) {
client->second.Suspend();
client++;
}
break;
default:
ASSERT(false);
break;
}
}
}
} //namespace Plugin
} // namespace WPEFramework
|
// 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::stroke_collation_tailoring());
return tailored_collation_table(
table_str,
"zh::stroke_collation_tailoring()", error, warning);
#else
if (!exists(boost::filesystem::path("zh_stroke.table"))) {
std::string const table_str(data::zh::stroke_collation_tailoring());
collation_table table = tailored_collation_table(
table_str,
"zh::stroke_collation_tailoring()", error, warning);
save_table(table, "zh_stroke.table.1");
boost::filesystem::rename("zh_stroke.table.1", "zh_stroke.table");
}
return load_table("zh_stroke.table");
#endif
}
collation_table const & table()
{
static collation_table retval = make_save_load_table();
return retval;
}
TEST(tailoring, zh_stroke_000_000)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5217);
auto const rel = std::vector<uint32_t>(1, 0x5218);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5218);
auto const rel = std::vector<uint32_t>(1, 0x5219);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5219);
auto const rel = std::vector<uint32_t>(1, 0x521a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x521a);
auto const rel = std::vector<uint32_t>(1, 0x521b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x521b);
auto const rel = std::vector<uint32_t>(1, 0x52a3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52a3);
auto const rel = std::vector<uint32_t>(1, 0x52a4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52a4);
auto const rel = std::vector<uint32_t>(1, 0x52a5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52a5);
auto const rel = std::vector<uint32_t>(1, 0x52a6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52a6);
auto const rel = std::vector<uint32_t>(1, 0x52a7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52a7);
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, 0x5308);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5308);
auto const rel = std::vector<uint32_t>(1, 0x531f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x531f);
auto const rel = std::vector<uint32_t>(1, 0x5320);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5320);
auto const rel = std::vector<uint32_t>(1, 0x5321);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5321);
auto const rel = std::vector<uint32_t>(1, 0x5322);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5322);
auto const rel = std::vector<uint32_t>(1, 0x534b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x534b);
auto const rel = std::vector<uint32_t>(1, 0x534d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x534d);
auto const rel = std::vector<uint32_t>(1, 0x534e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x534e);
auto const rel = std::vector<uint32_t>(1, 0x534f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x534f);
auto const rel = std::vector<uint32_t>(1, 0x5350);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5350);
auto const rel = std::vector<uint32_t>(1, 0x353b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x353b);
auto const rel = std::vector<uint32_t>(1, 0x5370);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5370);
auto const rel = std::vector<uint32_t>(1, 0x5371);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5371);
auto const rel = std::vector<uint32_t>(1, 0x538a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x538a);
auto const rel = std::vector<uint32_t>(1, 0x538b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x538b);
auto const rel = std::vector<uint32_t>(1, 0x538c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x538c);
auto const rel = std::vector<uint32_t>(1, 0x538d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x538d);
auto const rel = std::vector<uint32_t>(1, 0x3542);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3542);
auto const rel = std::vector<uint32_t>(1, 0x53bd);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x53bd);
auto const rel = std::vector<uint32_t>(1, 0x53be);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x53be);
auto const rel = std::vector<uint32_t>(1, 0x53d2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x53d2);
auto const rel = std::vector<uint32_t>(1, 0x53ff);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x53ff);
auto const rel = std::vector<uint32_t>(1, 0x5400);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5400);
auto const rel = std::vector<uint32_t>(1, 0x5401);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5401);
auto const rel = std::vector<uint32_t>(1, 0x5402);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5402);
auto const rel = std::vector<uint32_t>(1, 0x5403);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5403);
auto const rel = std::vector<uint32_t>(1, 0x5404);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5404);
auto const rel = std::vector<uint32_t>(1, 0x5405);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5405);
auto const rel = std::vector<uint32_t>(1, 0x5406);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5406);
auto const rel = std::vector<uint32_t>(1, 0x5407);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5407);
auto const rel = std::vector<uint32_t>(1, 0x5408);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5408);
auto const rel = std::vector<uint32_t>(1, 0x5409);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5409);
auto const rel = std::vector<uint32_t>(1, 0x540a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x540a);
auto const rel = std::vector<uint32_t>(1, 0x540b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x540b);
auto const rel = std::vector<uint32_t>(1, 0x540c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x540c);
auto const rel = std::vector<uint32_t>(1, 0x540d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x540d);
auto const rel = std::vector<uint32_t>(1, 0x540e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x540e);
auto const rel = std::vector<uint32_t>(1, 0x540f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x540f);
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, 0x5411);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5411);
auto const rel = std::vector<uint32_t>(1, 0x5412);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_001)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5412);
auto const rel = std::vector<uint32_t>(1, 0x5413);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5413);
auto const rel = std::vector<uint32_t>(1, 0x5414);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5414);
auto const rel = std::vector<uint32_t>(1, 0x5415);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5415);
auto const rel = std::vector<uint32_t>(1, 0x5416);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5416);
auto const rel = std::vector<uint32_t>(1, 0x5417);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5417);
auto const rel = std::vector<uint32_t>(1, 0x3566);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3566);
auto const rel = std::vector<uint32_t>(1, 0x20bbf);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20bbf);
auto const rel = std::vector<uint32_t>(1, 0x20bc6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20bc6);
auto const rel = std::vector<uint32_t>(1, 0x56dd);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56dd);
auto const rel = std::vector<uint32_t>(1, 0x56de);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56de);
auto const rel = std::vector<uint32_t>(1, 0x56df);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56df);
auto const rel = std::vector<uint32_t>(1, 0x56e0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e0);
auto const rel = std::vector<uint32_t>(1, 0x56e1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e1);
auto const rel = std::vector<uint32_t>(1, 0x56e2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e2);
auto const rel = std::vector<uint32_t>(1, 0x56e3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e3);
auto const rel = std::vector<uint32_t>(1, 0x5728);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5728);
auto const rel = std::vector<uint32_t>(1, 0x5729);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5729);
auto const rel = std::vector<uint32_t>(1, 0x572a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x572a);
auto const rel = std::vector<uint32_t>(1, 0x572b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x572b);
auto const rel = std::vector<uint32_t>(1, 0x572c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x572c);
auto const rel = std::vector<uint32_t>(1, 0x572d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x572d);
auto const rel = std::vector<uint32_t>(1, 0x572e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x572e);
auto const rel = std::vector<uint32_t>(1, 0x572f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x572f);
auto const rel = std::vector<uint32_t>(1, 0x5730);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5730);
auto const rel = std::vector<uint32_t>(1, 0x5731);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5731);
auto const rel = std::vector<uint32_t>(1, 0x5732);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5732);
auto const rel = std::vector<uint32_t>(1, 0x5733);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5733);
auto const rel = std::vector<uint32_t>(1, 0x5734);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5734);
auto const rel = std::vector<uint32_t>(1, 0x5735);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5735);
auto const rel = std::vector<uint32_t>(1, 0x5736);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5736);
auto const rel = std::vector<uint32_t>(1, 0x5737);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5737);
auto const rel = std::vector<uint32_t>(1, 0x5738);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5738);
auto const rel = std::vector<uint32_t>(1, 0x5739);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5739);
auto const rel = std::vector<uint32_t>(1, 0x573a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x573a);
auto const rel = std::vector<uint32_t>(1, 0x2124f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x2124f);
auto const rel = std::vector<uint32_t>(1, 0x58ee);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x58ee);
auto const rel = std::vector<uint32_t>(1, 0x5905);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5905);
auto const rel = std::vector<uint32_t>(1, 0x5919);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5919);
auto const rel = std::vector<uint32_t>(1, 0x591a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x591a);
auto const rel = std::vector<uint32_t>(1, 0x591b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x591b);
auto const rel = std::vector<uint32_t>(1, 0x5935);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5935);
auto const rel = std::vector<uint32_t>(1, 0x5936);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5936);
auto const rel = std::vector<uint32_t>(1, 0x5937);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5937);
auto const rel = std::vector<uint32_t>(1, 0x5938);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5938);
auto const rel = std::vector<uint32_t>(1, 0x5939);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5939);
auto const rel = std::vector<uint32_t>(1, 0x593a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x593a);
auto const rel = std::vector<uint32_t>(1, 0x593b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x593b);
auto const rel = std::vector<uint32_t>(1, 0x593c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x593c);
auto const rel = std::vector<uint32_t>(1, 0x5977);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5977);
auto const rel = std::vector<uint32_t>(1, 0x5978);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5978);
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);
}
}
TEST(tailoring, zh_stroke_001_002)
{
{
// 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, 0x597a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x597a);
auto const rel = std::vector<uint32_t>(1, 0x597b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x597b);
auto const rel = std::vector<uint32_t>(1, 0x597c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x597c);
auto const rel = std::vector<uint32_t>(1, 0x597d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x597d);
auto const rel = std::vector<uint32_t>(1, 0x597e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x597e);
auto const rel = std::vector<uint32_t>(1, 0x597f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x597f);
auto const rel = std::vector<uint32_t>(1, 0x5980);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5980);
auto const rel = std::vector<uint32_t>(1, 0x5981);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5981);
auto const rel = std::vector<uint32_t>(1, 0x5982);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5982);
auto const rel = std::vector<uint32_t>(1, 0x5983);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5983);
auto const rel = std::vector<uint32_t>(1, 0x5984);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5984);
auto const rel = std::vector<uint32_t>(1, 0x5985);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5985);
auto const rel = std::vector<uint32_t>(1, 0x5986);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5986);
auto const rel = std::vector<uint32_t>(1, 0x5987);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5987);
auto const rel = std::vector<uint32_t>(1, 0x5988);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5988);
auto const rel = std::vector<uint32_t>(1, 0x36a5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x36a5);
auto const rel = std::vector<uint32_t>(1, 0x216b8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x216b8);
auto const rel = std::vector<uint32_t>(1, 0x216ba);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x216ba);
auto const rel = std::vector<uint32_t>(1, 0x5b56);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b56);
auto const rel = std::vector<uint32_t>(1, 0x5b57);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b57);
auto const rel = std::vector<uint32_t>(1, 0x5b58);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b58);
auto const rel = std::vector<uint32_t>(1, 0x5b59);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b59);
auto const rel = std::vector<uint32_t>(1, 0x21944);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x21944);
auto const rel = std::vector<uint32_t>(1, 0x5b85);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b85);
auto const rel = std::vector<uint32_t>(1, 0x5b86);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b86);
auto const rel = std::vector<uint32_t>(1, 0x5b87);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b87);
auto const rel = std::vector<uint32_t>(1, 0x5b88);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b88);
auto const rel = std::vector<uint32_t>(1, 0x5b89);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b89);
auto const rel = std::vector<uint32_t>(1, 0x5bfa);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5bfa);
auto const rel = std::vector<uint32_t>(1, 0x5bfb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5bfb);
auto const rel = std::vector<uint32_t>(1, 0x5bfc);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5bfc);
auto const rel = std::vector<uint32_t>(1, 0x5c16);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c16);
auto const rel = std::vector<uint32_t>(1, 0x5c17);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c17);
auto const rel = std::vector<uint32_t>(1, 0x5c18);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c18);
auto const rel = std::vector<uint32_t>(1, 0x5c25);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c25);
auto const rel = std::vector<uint32_t>(1, 0x5c26);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c26);
auto const rel = std::vector<uint32_t>(1, 0x5c27);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c27);
auto const rel = std::vector<uint32_t>(1, 0x5c3d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c3d);
auto const rel = std::vector<uint32_t>(1, 0x21c2a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x21c2a);
auto const rel = std::vector<uint32_t>(1, 0x5c70);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c70);
auto const rel = std::vector<uint32_t>(1, 0x5c78);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c78);
auto const rel = std::vector<uint32_t>(1, 0x5c79);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c79);
auto const rel = std::vector<uint32_t>(1, 0x5c7a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c7a);
auto const rel = std::vector<uint32_t>(1, 0x5c7b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c7b);
auto const rel = std::vector<uint32_t>(1, 0x5c7c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c7c);
auto const rel = std::vector<uint32_t>(1, 0x5c7d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c7d);
auto const rel = std::vector<uint32_t>(1, 0x5c7e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c7e);
auto const rel = std::vector<uint32_t>(1, 0x5c7f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c7f);
auto const rel = std::vector<uint32_t>(1, 0x5c80);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c80);
auto const rel = std::vector<uint32_t>(1, 0x5c81);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c81);
auto const rel = std::vector<uint32_t>(1, 0x5c82);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_003)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c82);
auto const rel = std::vector<uint32_t>(1, 0x5c83);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c83);
auto const rel = std::vector<uint32_t>(1, 0x21d46);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x21d46);
auto const rel = std::vector<uint32_t>(1, 0x5dde);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5dde);
auto const rel = std::vector<uint32_t>(1, 0x5ddf);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ddf);
auto const rel = std::vector<uint32_t>(1, 0x5de9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5de9);
auto const rel = std::vector<uint32_t>(1, 0x5dea);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5dea);
auto const rel = std::vector<uint32_t>(1, 0x5e06);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e06);
auto const rel = std::vector<uint32_t>(1, 0x5e07);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e07);
auto const rel = std::vector<uint32_t>(1, 0x5e08);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e08);
auto const rel = std::vector<uint32_t>(1, 0x3834);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3834);
auto const rel = std::vector<uint32_t>(1, 0x3835);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3835);
auto const rel = std::vector<uint32_t>(1, 0x3836);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3836);
auto const rel = std::vector<uint32_t>(1, 0x5e74);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e74);
auto const rel = std::vector<uint32_t>(1, 0x5e75);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e75);
auto const rel = std::vector<uint32_t>(1, 0x5e76);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e76);
auto const rel = std::vector<uint32_t>(1, 0x5e84);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e84);
auto const rel = std::vector<uint32_t>(1, 0x5e85);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e85);
auto const rel = std::vector<uint32_t>(1, 0x5e86);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e86);
auto const rel = std::vector<uint32_t>(1, 0x5ef5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ef5);
auto const rel = std::vector<uint32_t>(1, 0x5f02);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f02);
auto const rel = std::vector<uint32_t>(1, 0x5f0e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f0e);
auto const rel = std::vector<uint32_t>(1, 0x5f0f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f0f);
auto const rel = std::vector<uint32_t>(1, 0x5f10);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f10);
auto const rel = std::vector<uint32_t>(1, 0x5f19);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f19);
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, 0x5f1b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f1b);
auto const rel = std::vector<uint32_t>(1, 0x5f1c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f1c);
auto const rel = std::vector<uint32_t>(1, 0x5f53);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f53);
auto const rel = std::vector<uint32_t>(1, 0x5f74);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f74);
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, 0x224c1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x224c1);
auto const rel = std::vector<uint32_t>(1, 0x5fc8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fc8);
auto const rel = std::vector<uint32_t>(1, 0x5fcb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fcb);
auto const rel = std::vector<uint32_t>(1, 0x5fcf);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fcf);
auto const rel = std::vector<uint32_t>(1, 0x5fd3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fd3);
auto const rel = std::vector<uint32_t>(1, 0x5fd4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fd4);
auto const rel = std::vector<uint32_t>(1, 0x5fd5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fd5);
auto const rel = std::vector<uint32_t>(1, 0x5fd6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fd6);
auto const rel = std::vector<uint32_t>(1, 0x5fd9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fd9);
auto const rel = std::vector<uint32_t>(1, 0x5fda);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fda);
auto const rel = std::vector<uint32_t>(1, 0x5fdb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fdb);
auto const rel = std::vector<uint32_t>(1, 0x225be);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x225be);
auto const rel = std::vector<uint32_t>(1, 0x620c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x620c);
auto const rel = std::vector<uint32_t>(1, 0x620d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x620d);
auto const rel = std::vector<uint32_t>(1, 0x620e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x620e);
auto const rel = std::vector<uint32_t>(1, 0x620f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x620f);
auto const rel = std::vector<uint32_t>(1, 0x6210);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6210);
auto const rel = std::vector<uint32_t>(1, 0x6257);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6257);
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, 0x6259);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6259);
auto const rel = std::vector<uint32_t>(1, 0x625a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_004)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x625a);
auto const rel = std::vector<uint32_t>(1, 0x625b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x625b);
auto const rel = std::vector<uint32_t>(1, 0x625c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x625c);
auto const rel = std::vector<uint32_t>(1, 0x625d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x625d);
auto const rel = std::vector<uint32_t>(1, 0x625e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x625e);
auto const rel = std::vector<uint32_t>(1, 0x6260);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6260);
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, 0x6262);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6262);
auto const rel = std::vector<uint32_t>(1, 0x6263);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6263);
auto const rel = std::vector<uint32_t>(1, 0x6264);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6264);
auto const rel = std::vector<uint32_t>(1, 0x6265);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6265);
auto const rel = std::vector<uint32_t>(1, 0x6266);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6266);
auto const rel = std::vector<uint32_t>(1, 0x6267);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6267);
auto const rel = std::vector<uint32_t>(1, 0x6268);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6268);
auto const rel = std::vector<uint32_t>(1, 0x6269);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6269);
auto const rel = std::vector<uint32_t>(1, 0x626a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x626a);
auto const rel = std::vector<uint32_t>(1, 0x626b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x626b);
auto const rel = std::vector<uint32_t>(1, 0x626c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x626c);
auto const rel = std::vector<uint32_t>(1, 0x625f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x625f);
auto const rel = std::vector<uint32_t>(1, 0x6530);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6530);
auto const rel = std::vector<uint32_t>(1, 0x6536);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6536);
auto const rel = std::vector<uint32_t>(1, 0x6537);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6537);
auto const rel = std::vector<uint32_t>(1, 0x65e8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65e8);
auto const rel = std::vector<uint32_t>(1, 0x65e9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65e9);
auto const rel = std::vector<uint32_t>(1, 0x65ea);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65ea);
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, 0x65ec);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65ec);
auto const rel = std::vector<uint32_t>(1, 0x65ed);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65ed);
auto const rel = std::vector<uint32_t>(1, 0x65ee);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65ee);
auto const rel = std::vector<uint32_t>(1, 0x65ef);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65ef);
auto const rel = std::vector<uint32_t>(1, 0x66f2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x66f2);
auto const rel = std::vector<uint32_t>(1, 0x66f3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x66f3);
auto const rel = std::vector<uint32_t>(1, 0x3b30);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3b30);
auto const rel = std::vector<uint32_t>(1, 0x6709);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6709);
auto const rel = std::vector<uint32_t>(1, 0x6731);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6731);
auto const rel = std::vector<uint32_t>(1, 0x6732);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6732);
auto const rel = std::vector<uint32_t>(1, 0x6733);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6733);
auto const rel = std::vector<uint32_t>(1, 0x6734);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6734);
auto const rel = std::vector<uint32_t>(1, 0x6735);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6735);
auto const rel = std::vector<uint32_t>(1, 0x6736);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6736);
auto const rel = std::vector<uint32_t>(1, 0x6737);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6737);
auto const rel = std::vector<uint32_t>(1, 0x6738);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6738);
auto const rel = std::vector<uint32_t>(1, 0x6739);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6739);
auto const rel = std::vector<uint32_t>(1, 0x673a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x673a);
auto const rel = std::vector<uint32_t>(1, 0x673b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x673b);
auto const rel = std::vector<uint32_t>(1, 0x673c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x673c);
auto const rel = std::vector<uint32_t>(1, 0x673d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x673d);
auto const rel = std::vector<uint32_t>(1, 0x673e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x673e);
auto const rel = std::vector<uint32_t>(1, 0x673f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x673f);
auto const rel = std::vector<uint32_t>(1, 0x6740);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6740);
auto const rel = std::vector<uint32_t>(1, 0x6741);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6741);
auto const rel = std::vector<uint32_t>(1, 0x6742);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_005)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6742);
auto const rel = std::vector<uint32_t>(1, 0x6743);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6743);
auto const rel = std::vector<uint32_t>(1, 0x3b41);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3b41);
auto const rel = std::vector<uint32_t>(1, 0x6b21);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6b21);
auto const rel = std::vector<uint32_t>(1, 0x6b22);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6b22);
auto const rel = std::vector<uint32_t>(1, 0x6b64);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6b64);
auto const rel = std::vector<uint32_t>(1, 0x6b7b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6b7b);
auto const rel = std::vector<uint32_t>(1, 0x6bce);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6bce);
auto const rel = std::vector<uint32_t>(1, 0x6bd5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6bd5);
auto const rel = std::vector<uint32_t>(1, 0x6c12);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c12);
auto const rel = std::vector<uint32_t>(1, 0x6c16);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c16);
auto const rel = std::vector<uint32_t>(1, 0x6c17);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c17);
auto const rel = std::vector<uint32_t>(1, 0x6c18);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c18);
auto const rel = std::vector<uint32_t>(1, 0x6c3c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c3c);
auto const rel = std::vector<uint32_t>(1, 0x6c46);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c46);
auto const rel = std::vector<uint32_t>(1, 0x6c4a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c4a);
auto const rel = std::vector<uint32_t>(1, 0x6c4b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c4b);
auto const rel = std::vector<uint32_t>(1, 0x6c4c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c4c);
auto const rel = std::vector<uint32_t>(1, 0x6c4d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c4d);
auto const rel = std::vector<uint32_t>(1, 0x6c4e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c4e);
auto const rel = std::vector<uint32_t>(1, 0x6c4f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c4f);
auto const rel = std::vector<uint32_t>(1, 0x6c50);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c50);
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, 0x6c52);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c52);
auto const rel = std::vector<uint32_t>(1, 0x6c53);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c53);
auto const rel = std::vector<uint32_t>(1, 0x6c54);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c54);
auto const rel = std::vector<uint32_t>(1, 0x6c55);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c55);
auto const rel = std::vector<uint32_t>(1, 0x6c57);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c57);
auto const rel = std::vector<uint32_t>(1, 0x6c58);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c58);
auto const rel = std::vector<uint32_t>(1, 0x6c59);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c59);
auto const rel = std::vector<uint32_t>(1, 0x6c5a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c5a);
auto const rel = std::vector<uint32_t>(1, 0x6c5b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c5b);
auto const rel = std::vector<uint32_t>(1, 0x6c5c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c5c);
auto const rel = std::vector<uint32_t>(1, 0x6c5d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c5d);
auto const rel = std::vector<uint32_t>(1, 0x6c5f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c5f);
auto const rel = std::vector<uint32_t>(1, 0x6c60);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c60);
auto const rel = std::vector<uint32_t>(1, 0x6c61);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c61);
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, 0x6c63);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c63);
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, 0x6c77);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6c77);
auto const rel = std::vector<uint32_t>(1, 0x706e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x706e);
auto const rel = std::vector<uint32_t>(1, 0x706f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x706f);
auto const rel = std::vector<uint32_t>(1, 0x7070);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7070);
auto const rel = std::vector<uint32_t>(1, 0x7071);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7071);
auto const rel = std::vector<uint32_t>(1, 0x7072);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7072);
auto const rel = std::vector<uint32_t>(1, 0x7073);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7073);
auto const rel = std::vector<uint32_t>(1, 0x7237);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7237);
auto const rel = std::vector<uint32_t>(1, 0x725d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x725d);
auto const rel = std::vector<uint32_t>(1, 0x725e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x725e);
auto const rel = std::vector<uint32_t>(1, 0x725f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x725f);
auto const rel = std::vector<uint32_t>(1, 0x72b1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_006)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x72b1);
auto const rel = std::vector<uint32_t>(1, 0x72b2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x72b2);
auto const rel = std::vector<uint32_t>(1, 0x72b3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x72b3);
auto const rel = std::vector<uint32_t>(1, 0x72b4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x72b4);
auto const rel = std::vector<uint32_t>(1, 0x72b5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x72b5);
auto const rel = std::vector<uint32_t>(1, 0x72b7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x72b7);
auto const rel = std::vector<uint32_t>(1, 0x72b8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x72b8);
auto const rel = std::vector<uint32_t>(1, 0x24725);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x24725);
auto const rel = std::vector<uint32_t>(1, 0x738e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x738e);
auto const rel = std::vector<uint32_t>(1, 0x738f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x738f);
auto const rel = std::vector<uint32_t>(1, 0x7390);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7390);
auto const rel = std::vector<uint32_t>(1, 0x7391);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7391);
auto const rel = std::vector<uint32_t>(1, 0x3ea8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3ea8);
auto const rel = std::vector<uint32_t>(1, 0x3ea9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3ea9);
auto const rel = std::vector<uint32_t>(1, 0x3eaa);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3eaa);
auto const rel = std::vector<uint32_t>(1, 0x752a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x752a);
auto const rel = std::vector<uint32_t>(1, 0x7536);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7536);
auto const rel = std::vector<uint32_t>(1, 0x767e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x767e);
auto const rel = std::vector<uint32_t>(1, 0x767f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x767f);
auto const rel = std::vector<uint32_t>(1, 0x2eae);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x2eae);
auto const rel = std::vector<uint32_t>(1, 0x793c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x793c);
auto const rel = std::vector<uint32_t>(1, 0x7a75);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7a75);
auto const rel = std::vector<uint32_t>(1, 0x7af9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7af9);
auto const rel = std::vector<uint32_t>(1, 0x7c73);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7c73);
auto const rel = std::vector<uint32_t>(1, 0x7cf8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7cf8);
auto const rel = std::vector<uint32_t>(1, 0x7cf9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7cf9);
auto const rel = std::vector<uint32_t>(1, 0x7ea1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea1);
auto const rel = std::vector<uint32_t>(1, 0x7ea2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea2);
auto const rel = std::vector<uint32_t>(1, 0x7ea3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea3);
auto const rel = std::vector<uint32_t>(1, 0x7ea4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea4);
auto const rel = std::vector<uint32_t>(1, 0x7ea5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea5);
auto const rel = std::vector<uint32_t>(1, 0x7ea6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea6);
auto const rel = std::vector<uint32_t>(1, 0x7ea7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea7);
auto const rel = std::vector<uint32_t>(1, 0x7ea8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea8);
auto const rel = std::vector<uint32_t>(1, 0x7ea9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7ea9);
auto const rel = std::vector<uint32_t>(1, 0x7eaa);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7eaa);
auto const rel = std::vector<uint32_t>(1, 0x7eab);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7eab);
auto const rel = std::vector<uint32_t>(1, 0x7f36);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7f36);
auto const rel = std::vector<uint32_t>(1, 0x7f51);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7f51);
auto const rel = std::vector<uint32_t>(1, 0x7f8a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7f8a);
auto const rel = std::vector<uint32_t>(1, 0x2634b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x2634b);
auto const rel = std::vector<uint32_t>(1, 0x2eb6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x2eb6);
auto const rel = std::vector<uint32_t>(1, 0x2634c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x2634c);
auto const rel = std::vector<uint32_t>(1, 0x7fbd);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x7fbd);
auto const rel = std::vector<uint32_t>(1, 0x8001);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8001);
auto const rel = std::vector<uint32_t>(1, 0x8003);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8003);
auto const rel = std::vector<uint32_t>(1, 0x800c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x800c);
auto const rel = std::vector<uint32_t>(1, 0x8012);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8012);
auto const rel = std::vector<uint32_t>(1, 0x8033);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8033);
auto const rel = std::vector<uint32_t>(1, 0x807f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x807f);
auto const rel = std::vector<uint32_t>(1, 0x26612);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x26612);
auto const rel = std::vector<uint32_t>(1, 0x8089);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_007)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8089);
auto const rel = std::vector<uint32_t>(1, 0x808b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x808b);
auto const rel = std::vector<uint32_t>(1, 0x808c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x808c);
auto const rel = std::vector<uint32_t>(1, 0x808d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x808d);
auto const rel = std::vector<uint32_t>(1, 0x808e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x808e);
auto const rel = std::vector<uint32_t>(1, 0x81e3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x81e3);
auto const rel = std::vector<uint32_t>(1, 0x81ea);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x81ea);
auto const rel = std::vector<uint32_t>(1, 0x81f3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x81f3);
auto const rel = std::vector<uint32_t>(1, 0x81fc);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x81fc);
auto const rel = std::vector<uint32_t>(1, 0x26951);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x26951);
auto const rel = std::vector<uint32_t>(1, 0x820c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x820c);
auto const rel = std::vector<uint32_t>(1, 0x821b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x821b);
auto const rel = std::vector<uint32_t>(1, 0x821f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x821f);
auto const rel = std::vector<uint32_t>(1, 0x826e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x826e);
auto const rel = std::vector<uint32_t>(1, 0x8272);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8272);
auto const rel = std::vector<uint32_t>(1, 0x8278);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8278);
auto const rel = std::vector<uint32_t>(1, 0x4491);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4491);
auto const rel = std::vector<uint32_t>(1, 0x827b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x827b);
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, 0x827d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x827d);
auto const rel = std::vector<uint32_t>(1, 0x827e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x827e);
auto const rel = std::vector<uint32_t>(1, 0x827f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x827f);
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, 0x8281);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8281);
auto const rel = std::vector<uint32_t>(1, 0x8282);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8282);
auto const rel = std::vector<uint32_t>(1, 0x864d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x864d);
auto const rel = std::vector<uint32_t>(1, 0x866b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x866b);
auto const rel = std::vector<uint32_t>(1, 0x8840);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8840);
auto const rel = std::vector<uint32_t>(1, 0x884c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x884c);
auto const rel = std::vector<uint32_t>(1, 0x8863);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8863);
auto const rel = std::vector<uint32_t>(1, 0x897e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x897e);
auto const rel = std::vector<uint32_t>(1, 0x897f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x897f);
auto const rel = std::vector<uint32_t>(1, 0x8980);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8980);
auto const rel = std::vector<uint32_t>(1, 0x89c2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x89c2);
auto const rel = std::vector<uint32_t>(1, 0x8bb2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bb2);
auto const rel = std::vector<uint32_t>(1, 0x8bb3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bb3);
auto const rel = std::vector<uint32_t>(1, 0x8bb4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bb4);
auto const rel = std::vector<uint32_t>(1, 0x8bb5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bb5);
auto const rel = std::vector<uint32_t>(1, 0x8bb6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bb6);
auto const rel = std::vector<uint32_t>(1, 0x8bb7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bb7);
auto const rel = std::vector<uint32_t>(1, 0x8bb8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bb8);
auto const rel = std::vector<uint32_t>(1, 0x8bb9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bb9);
auto const rel = std::vector<uint32_t>(1, 0x8bba);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bba);
auto const rel = std::vector<uint32_t>(1, 0x8bbb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bbb);
auto const rel = std::vector<uint32_t>(1, 0x8bbc);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bbc);
auto const rel = std::vector<uint32_t>(1, 0x8bbd);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bbd);
auto const rel = std::vector<uint32_t>(1, 0x8bbe);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bbe);
auto const rel = std::vector<uint32_t>(1, 0x8bbf);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bbf);
auto const rel = std::vector<uint32_t>(1, 0x8bc0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8bc0);
auto const rel = std::vector<uint32_t>(1, 0x8d1e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8d1e);
auto const rel = std::vector<uint32_t>(1, 0x8d1f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8d1f);
auto const rel = std::vector<uint32_t>(1, 0x8d20);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_008)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8d20);
auto const rel = std::vector<uint32_t>(1, 0x8d71);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8d71);
auto const rel = std::vector<uint32_t>(1, 0x8f68);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8f68);
auto const rel = std::vector<uint32_t>(1, 0x8fb8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8fb8);
auto const rel = std::vector<uint32_t>(1, 0x8fb9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8fb9);
auto const rel = std::vector<uint32_t>(1, 0x8fba);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8fba);
auto const rel = std::vector<uint32_t>(1, 0x8fbb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8fbb);
auto const rel = std::vector<uint32_t>(1, 0x8fbc);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8fbc);
auto const rel = std::vector<uint32_t>(1, 0x8fbd);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x8fbd);
auto const rel = std::vector<uint32_t>(1, 0x9094);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9094);
auto const rel = std::vector<uint32_t>(1, 0x9096);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9096);
auto const rel = std::vector<uint32_t>(1, 0x9097);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9097);
auto const rel = std::vector<uint32_t>(1, 0x9098);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9098);
auto const rel = std::vector<uint32_t>(1, 0x9099);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9099);
auto const rel = std::vector<uint32_t>(1, 0x909a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x909a);
auto const rel = std::vector<uint32_t>(1, 0x909b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x909b);
auto const rel = std::vector<uint32_t>(1, 0x909c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x909c);
auto const rel = std::vector<uint32_t>(1, 0x909d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x909d);
auto const rel = std::vector<uint32_t>(1, 0x9486);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9486);
auto const rel = std::vector<uint32_t>(1, 0x9487);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9487);
auto const rel = std::vector<uint32_t>(1, 0x95eb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x95eb);
auto const rel = std::vector<uint32_t>(1, 0x95ec);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x95ec);
auto const rel = std::vector<uint32_t>(1, 0x95ed);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x95ed);
auto const rel = std::vector<uint32_t>(1, 0x95ee);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x95ee);
auto const rel = std::vector<uint32_t>(1, 0x95ef);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x95ef);
auto const rel = std::vector<uint32_t>(1, 0x9620);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9620);
auto const rel = std::vector<uint32_t>(1, 0x9621);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9621);
auto const rel = std::vector<uint32_t>(1, 0x9622);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9622);
auto const rel = std::vector<uint32_t>(1, 0x9623);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9623);
auto const rel = std::vector<uint32_t>(1, 0x9624);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9624);
auto const rel = std::vector<uint32_t>(1, 0x9875);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9875);
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, 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, 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, 0x9a6f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9a6f);
auto const rel = std::vector<uint32_t>(1, 0x9a70);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9a70);
auto const rel = std::vector<uint32_t>(1, 0x9f50);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9f50);
auto const rel = std::vector<uint32_t>{0xfdd0, 0x2807};
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.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, 0x2807};
auto const rel = std::vector<uint32_t>(1, 0x4e23);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e23);
auto const rel = std::vector<uint32_t>(1, 0x4e24);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e24);
auto const rel = std::vector<uint32_t>(1, 0x4e25);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e25);
auto const rel = std::vector<uint32_t>(1, 0x4e3d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e3d);
auto const rel = std::vector<uint32_t>(1, 0x20021);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20021);
auto const rel = std::vector<uint32_t>(1, 0x4e32);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e32);
auto const rel = std::vector<uint32_t>(1, 0x20068);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20068);
auto const rel = std::vector<uint32_t>(1, 0x4e55);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e55);
auto const rel = std::vector<uint32_t>(1, 0x4e71);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e71);
auto const rel = std::vector<uint32_t>(1, 0x4e72);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e72);
auto const rel = std::vector<uint32_t>(1, 0x4e8a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e8a);
auto const rel = std::vector<uint32_t>(1, 0x20118);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20118);
auto const rel = std::vector<uint32_t>(1, 0x4e9c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4e9c);
auto const rel = std::vector<uint32_t>(1, 0x4ea8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_009)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4ea8);
auto const rel = std::vector<uint32_t>(1, 0x4ea9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4ea9);
auto const rel = std::vector<uint32_t>(1, 0x4eaa);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4eaa);
auto const rel = std::vector<uint32_t>(1, 0x4f2d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f2d);
auto const rel = std::vector<uint32_t>(1, 0x4f2e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f2e);
auto const rel = std::vector<uint32_t>(1, 0x4f2f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f2f);
auto const rel = std::vector<uint32_t>(1, 0x4f30);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f30);
auto const rel = std::vector<uint32_t>(1, 0x4f31);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f31);
auto const rel = std::vector<uint32_t>(1, 0x4f32);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f32);
auto const rel = std::vector<uint32_t>(1, 0x4f33);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f33);
auto const rel = std::vector<uint32_t>(1, 0x4f34);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f34);
auto const rel = std::vector<uint32_t>(1, 0x4f35);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f35);
auto const rel = std::vector<uint32_t>(1, 0x4f36);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f36);
auto const rel = std::vector<uint32_t>(1, 0x4f37);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f37);
auto const rel = std::vector<uint32_t>(1, 0x4f38);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f38);
auto const rel = std::vector<uint32_t>(1, 0x4f39);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f39);
auto const rel = std::vector<uint32_t>(1, 0x4f3a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f3a);
auto const rel = std::vector<uint32_t>(1, 0x4f3b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f3b);
auto const rel = std::vector<uint32_t>(1, 0x4f3c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f3c);
auto const rel = std::vector<uint32_t>(1, 0x4f3d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f3d);
auto const rel = std::vector<uint32_t>(1, 0x4f3e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f3e);
auto const rel = std::vector<uint32_t>(1, 0x4f3f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f3f);
auto const rel = std::vector<uint32_t>(1, 0x4f40);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f40);
auto const rel = std::vector<uint32_t>(1, 0x4f41);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f41);
auto const rel = std::vector<uint32_t>(1, 0x4f42);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f42);
auto const rel = std::vector<uint32_t>(1, 0x4f43);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f43);
auto const rel = std::vector<uint32_t>(1, 0x4f44);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f44);
auto const rel = std::vector<uint32_t>(1, 0x4f45);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f45);
auto const rel = std::vector<uint32_t>(1, 0x4f46);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f46);
auto const rel = std::vector<uint32_t>(1, 0x4f47);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f47);
auto const rel = std::vector<uint32_t>(1, 0x4f48);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f48);
auto const rel = std::vector<uint32_t>(1, 0x4f49);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f49);
auto const rel = std::vector<uint32_t>(1, 0x4f4a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f4a);
auto const rel = std::vector<uint32_t>(1, 0x4f4b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f4b);
auto const rel = std::vector<uint32_t>(1, 0x4f4d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f4d);
auto const rel = std::vector<uint32_t>(1, 0x4f4e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f4e);
auto const rel = std::vector<uint32_t>(1, 0x4f4f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f4f);
auto const rel = std::vector<uint32_t>(1, 0x4f50);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f50);
auto const rel = std::vector<uint32_t>(1, 0x4f51);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f51);
auto const rel = std::vector<uint32_t>(1, 0x4f52);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f52);
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, 0x4f54);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f54);
auto const rel = std::vector<uint32_t>(1, 0x4f55);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f55);
auto const rel = std::vector<uint32_t>(1, 0x4f56);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f56);
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, 0x4f58);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f58);
auto const rel = std::vector<uint32_t>(1, 0x4f59);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f59);
auto const rel = std::vector<uint32_t>(1, 0x4f5a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f5a);
auto const rel = std::vector<uint32_t>(1, 0x4f5b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f5b);
auto const rel = std::vector<uint32_t>(1, 0x4f5c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f5c);
auto const rel = std::vector<uint32_t>(1, 0x4f5d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f5d);
auto const rel = std::vector<uint32_t>(1, 0x4f5e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_010)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f5e);
auto const rel = std::vector<uint32_t>(1, 0x4f5f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f5f);
auto const rel = std::vector<uint32_t>(1, 0x4f60);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f60);
auto const rel = std::vector<uint32_t>(1, 0x4f61);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f61);
auto const rel = std::vector<uint32_t>(1, 0x4f62);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f62);
auto const rel = std::vector<uint32_t>(1, 0x4f63);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f63);
auto const rel = std::vector<uint32_t>(1, 0x4f65);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f65);
auto const rel = std::vector<uint32_t>(1, 0x4f66);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f66);
auto const rel = std::vector<uint32_t>(1, 0x4f67);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f67);
auto const rel = std::vector<uint32_t>(1, 0x4f68);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x4f68);
auto const rel = std::vector<uint32_t>(1, 0x3446);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3446);
auto const rel = std::vector<uint32_t>(1, 0x201f2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x201f2);
auto const rel = std::vector<uint32_t>(1, 0x514b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x514b);
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, 0x514d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x514d);
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, 0x514f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x514f);
auto const rel = std::vector<uint32_t>(1, 0x5150);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5150);
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, 0x34b3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x34b3);
auto const rel = std::vector<uint32_t>(1, 0x5175);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5175);
auto const rel = std::vector<uint32_t>(1, 0x518f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x518f);
auto const rel = std::vector<uint32_t>(1, 0x519d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x519d);
auto const rel = std::vector<uint32_t>(1, 0x51b5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x51b5);
auto const rel = std::vector<uint32_t>(1, 0x51b6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x51b6);
auto const rel = std::vector<uint32_t>(1, 0x51b7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x51b7);
auto const rel = std::vector<uint32_t>(1, 0x51b8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x51b8);
auto const rel = std::vector<uint32_t>(1, 0x51b9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x51b9);
auto const rel = std::vector<uint32_t>(1, 0x51ba);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x51ba);
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, 0x34c8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x34c8);
auto const rel = std::vector<uint32_t>(1, 0x51ec);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x51ec);
auto const rel = std::vector<uint32_t>(1, 0x521c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x521c);
auto const rel = std::vector<uint32_t>(1, 0x521d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x521d);
auto const rel = std::vector<uint32_t>(1, 0x521e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x521e);
auto const rel = std::vector<uint32_t>(1, 0x521f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x521f);
auto const rel = std::vector<uint32_t>(1, 0x5220);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5220);
auto const rel = std::vector<uint32_t>(1, 0x5221);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5221);
auto const rel = std::vector<uint32_t>(1, 0x5222);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5222);
auto const rel = std::vector<uint32_t>(1, 0x5223);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5223);
auto const rel = std::vector<uint32_t>(1, 0x5224);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5224);
auto const rel = std::vector<uint32_t>(1, 0x5225);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5225);
auto const rel = std::vector<uint32_t>(1, 0x5226);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5226);
auto const rel = std::vector<uint32_t>(1, 0x5227);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5227);
auto const rel = std::vector<uint32_t>(1, 0x5228);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5228);
auto const rel = std::vector<uint32_t>(1, 0x5229);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5229);
auto const rel = std::vector<uint32_t>(1, 0x522a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x522a);
auto const rel = std::vector<uint32_t>(1, 0x522b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x522b);
auto const rel = std::vector<uint32_t>(1, 0x522c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x522c);
auto const rel = std::vector<uint32_t>(1, 0x522d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x522d);
auto const rel = std::vector<uint32_t>(1, 0x34df);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x34df);
auto const rel = std::vector<uint32_t>(1, 0x52a9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_011)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52a9);
auto const rel = std::vector<uint32_t>(1, 0x52aa);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52aa);
auto const rel = std::vector<uint32_t>(1, 0x52ab);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52ab);
auto const rel = std::vector<uint32_t>(1, 0x52ac);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52ac);
auto const rel = std::vector<uint32_t>(1, 0x52ad);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52ad);
auto const rel = std::vector<uint32_t>(1, 0x52ae);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52ae);
auto const rel = std::vector<uint32_t>(1, 0x52af);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52af);
auto const rel = std::vector<uint32_t>(1, 0x52b0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52b0);
auto const rel = std::vector<uint32_t>(1, 0x52b1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52b1);
auto const rel = std::vector<uint32_t>(1, 0x52b2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52b2);
auto const rel = std::vector<uint32_t>(1, 0x52b3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52b3);
auto const rel = std::vector<uint32_t>(1, 0x52b4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x52b4);
auto const rel = std::vector<uint32_t>(1, 0x5309);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5309);
auto const rel = std::vector<uint32_t>(1, 0x208d5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x208d5);
auto const rel = std::vector<uint32_t>(1, 0x5323);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5323);
auto const rel = std::vector<uint32_t>(1, 0x5324);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5324);
auto const rel = std::vector<uint32_t>(1, 0x5325);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5325);
auto const rel = std::vector<uint32_t>(1, 0x3530);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3530);
auto const rel = std::vector<uint32_t>(1, 0x533b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x533b);
auto const rel = std::vector<uint32_t>(1, 0x3537);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3537);
auto const rel = std::vector<uint32_t>(1, 0x5363);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5363);
auto const rel = std::vector<uint32_t>(1, 0x5364);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5364);
auto const rel = std::vector<uint32_t>(1, 0x5372);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5372);
auto const rel = std::vector<uint32_t>(1, 0x5373);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5373);
auto const rel = std::vector<uint32_t>(1, 0x5374);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5374);
auto const rel = std::vector<uint32_t>(1, 0x5375);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5375);
auto const rel = std::vector<uint32_t>(1, 0x538e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x538e);
auto const rel = std::vector<uint32_t>(1, 0x538f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x538f);
auto const rel = std::vector<uint32_t>(1, 0x5390);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5390);
auto const rel = std::vector<uint32_t>(1, 0x5391);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5391);
auto const rel = std::vector<uint32_t>(1, 0x53bf);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x53bf);
auto const rel = std::vector<uint32_t>(1, 0x53d3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x53d3);
auto const rel = std::vector<uint32_t>(1, 0x5418);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5418);
auto const rel = std::vector<uint32_t>(1, 0x5419);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5419);
auto const rel = std::vector<uint32_t>(1, 0x541a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x541a);
auto const rel = std::vector<uint32_t>(1, 0x541b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x541b);
auto const rel = std::vector<uint32_t>(1, 0x541c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x541c);
auto const rel = std::vector<uint32_t>(1, 0x541d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x541d);
auto const rel = std::vector<uint32_t>(1, 0x541e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x541e);
auto const rel = std::vector<uint32_t>(1, 0x541f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x541f);
auto const rel = std::vector<uint32_t>(1, 0x5420);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5420);
auto const rel = std::vector<uint32_t>(1, 0x5421);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5421);
auto const rel = std::vector<uint32_t>(1, 0x5422);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5422);
auto const rel = std::vector<uint32_t>(1, 0x5423);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5423);
auto const rel = std::vector<uint32_t>(1, 0x5424);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5424);
auto const rel = std::vector<uint32_t>(1, 0x5425);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5425);
auto const rel = std::vector<uint32_t>(1, 0x5426);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5426);
auto const rel = std::vector<uint32_t>(1, 0x5427);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5427);
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, 0x5429);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5429);
auto const rel = std::vector<uint32_t>(1, 0x542a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x542a);
auto const rel = std::vector<uint32_t>(1, 0x542b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_012)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x542b);
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, 0x542d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x542d);
auto const rel = std::vector<uint32_t>(1, 0x542e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x542e);
auto const rel = std::vector<uint32_t>(1, 0x542f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x542f);
auto const rel = std::vector<uint32_t>(1, 0x5430);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5430);
auto const rel = std::vector<uint32_t>(1, 0x5431);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5431);
auto const rel = std::vector<uint32_t>(1, 0x5432);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5432);
auto const rel = std::vector<uint32_t>(1, 0x5433);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5433);
auto const rel = std::vector<uint32_t>(1, 0x5434);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5434);
auto const rel = std::vector<uint32_t>(1, 0x5435);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5435);
auto const rel = std::vector<uint32_t>(1, 0x5436);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5436);
auto const rel = std::vector<uint32_t>(1, 0x5437);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5437);
auto const rel = std::vector<uint32_t>(1, 0x5438);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5438);
auto const rel = std::vector<uint32_t>(1, 0x5439);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5439);
auto const rel = std::vector<uint32_t>(1, 0x543a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x543a);
auto const rel = std::vector<uint32_t>(1, 0x543b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x543b);
auto const rel = std::vector<uint32_t>(1, 0x543c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x543c);
auto const rel = std::vector<uint32_t>(1, 0x543d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x543d);
auto const rel = std::vector<uint32_t>(1, 0x543e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x543e);
auto const rel = std::vector<uint32_t>(1, 0x543f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x543f);
auto const rel = std::vector<uint32_t>(1, 0x5440);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5440);
auto const rel = std::vector<uint32_t>(1, 0x5441);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5441);
auto const rel = std::vector<uint32_t>(1, 0x5442);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5442);
auto const rel = std::vector<uint32_t>(1, 0x5443);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5443);
auto const rel = std::vector<uint32_t>(1, 0x5444);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5444);
auto const rel = std::vector<uint32_t>(1, 0x5445);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5445);
auto const rel = std::vector<uint32_t>(1, 0x5446);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5446);
auto const rel = std::vector<uint32_t>(1, 0x5447);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5447);
auto const rel = std::vector<uint32_t>(1, 0x5448);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5448);
auto const rel = std::vector<uint32_t>(1, 0x5449);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5449);
auto const rel = std::vector<uint32_t>(1, 0x544a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x544a);
auto const rel = std::vector<uint32_t>(1, 0x544b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x544b);
auto const rel = std::vector<uint32_t>(1, 0x544c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x544c);
auto const rel = std::vector<uint32_t>(1, 0x544d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x544d);
auto const rel = std::vector<uint32_t>(1, 0x544e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x544e);
auto const rel = std::vector<uint32_t>(1, 0x544f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x544f);
auto const rel = std::vector<uint32_t>(1, 0x5450);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5450);
auto const rel = std::vector<uint32_t>(1, 0x5451);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5451);
auto const rel = std::vector<uint32_t>(1, 0x5452);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5452);
auto const rel = std::vector<uint32_t>(1, 0x5453);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5453);
auto const rel = std::vector<uint32_t>(1, 0x5454);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5454);
auto const rel = std::vector<uint32_t>(1, 0x5455);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5455);
auto const rel = std::vector<uint32_t>(1, 0x5456);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5456);
auto const rel = std::vector<uint32_t>(1, 0x5457);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5457);
auto const rel = std::vector<uint32_t>(1, 0x5458);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5458);
auto const rel = std::vector<uint32_t>(1, 0x5459);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5459);
auto const rel = std::vector<uint32_t>(1, 0x545a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x545a);
auto const rel = std::vector<uint32_t>(1, 0x545b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x545b);
auto const rel = std::vector<uint32_t>(1, 0x545c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x545c);
auto const rel = std::vector<uint32_t>(1, 0x356d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x356d);
auto const rel = std::vector<uint32_t>(1, 0x3570);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_013)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3570);
auto const rel = std::vector<uint32_t>(1, 0x3572);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3572);
auto const rel = std::vector<uint32_t>(1, 0x20bcb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20bcb);
auto const rel = std::vector<uint32_t>(1, 0x20be2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20be2);
auto const rel = std::vector<uint32_t>(1, 0x20beb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20beb);
auto const rel = std::vector<uint32_t>(1, 0x20bfb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20bfb);
auto const rel = std::vector<uint32_t>(1, 0x20bff);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x20bff);
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, 0x56e5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e5);
auto const rel = std::vector<uint32_t>(1, 0x56e6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e6);
auto const rel = std::vector<uint32_t>(1, 0x56e7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e7);
auto const rel = std::vector<uint32_t>(1, 0x56e8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e8);
auto const rel = std::vector<uint32_t>(1, 0x56e9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56e9);
auto const rel = std::vector<uint32_t>(1, 0x56ea);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56ea);
auto const rel = std::vector<uint32_t>(1, 0x56eb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56eb);
auto const rel = std::vector<uint32_t>(1, 0x56ec);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56ec);
auto const rel = std::vector<uint32_t>(1, 0x56ed);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56ed);
auto const rel = std::vector<uint32_t>(1, 0x56ee);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56ee);
auto const rel = std::vector<uint32_t>(1, 0x56ef);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56ef);
auto const rel = std::vector<uint32_t>(1, 0x56f0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56f0);
auto const rel = std::vector<uint32_t>(1, 0x56f1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56f1);
auto const rel = std::vector<uint32_t>(1, 0x56f2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56f2);
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, 0x56f4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56f4);
auto const rel = std::vector<uint32_t>(1, 0x56f5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x56f5);
auto const rel = std::vector<uint32_t>(1, 0x573b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x573b);
auto const rel = std::vector<uint32_t>(1, 0x573c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x573c);
auto const rel = std::vector<uint32_t>(1, 0x573d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x573d);
auto const rel = std::vector<uint32_t>(1, 0x573e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x573e);
auto const rel = std::vector<uint32_t>(1, 0x573f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x573f);
auto const rel = std::vector<uint32_t>(1, 0x5740);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5740);
auto const rel = std::vector<uint32_t>(1, 0x5741);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5741);
auto const rel = std::vector<uint32_t>(1, 0x5742);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5742);
auto const rel = std::vector<uint32_t>(1, 0x5743);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5743);
auto const rel = std::vector<uint32_t>(1, 0x5744);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5744);
auto const rel = std::vector<uint32_t>(1, 0x5745);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5745);
auto const rel = std::vector<uint32_t>(1, 0x5746);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5746);
auto const rel = std::vector<uint32_t>(1, 0x5747);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5747);
auto const rel = std::vector<uint32_t>(1, 0x5748);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5748);
auto const rel = std::vector<uint32_t>(1, 0x5749);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5749);
auto const rel = std::vector<uint32_t>(1, 0x574a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x574a);
auto const rel = std::vector<uint32_t>(1, 0x574b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x574b);
auto const rel = std::vector<uint32_t>(1, 0x574c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x574c);
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, 0x574e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x574e);
auto const rel = std::vector<uint32_t>(1, 0x574f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x574f);
auto const rel = std::vector<uint32_t>(1, 0x5750);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5750);
auto const rel = std::vector<uint32_t>(1, 0x5751);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5751);
auto const rel = std::vector<uint32_t>(1, 0x5752);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5752);
auto const rel = std::vector<uint32_t>(1, 0x5753);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5753);
auto const rel = std::vector<uint32_t>(1, 0x5754);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5754);
auto const rel = std::vector<uint32_t>(1, 0x5755);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_014)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5755);
auto const rel = std::vector<uint32_t>(1, 0x5756);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5756);
auto const rel = std::vector<uint32_t>(1, 0x5757);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5757);
auto const rel = std::vector<uint32_t>(1, 0x5758);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5758);
auto const rel = std::vector<uint32_t>(1, 0x5759);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5759);
auto const rel = std::vector<uint32_t>(1, 0x575a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x575a);
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, 0x575c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x575c);
auto const rel = std::vector<uint32_t>(1, 0x575d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x575d);
auto const rel = std::vector<uint32_t>(1, 0x575e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x575e);
auto const rel = std::vector<uint32_t>(1, 0x575f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x575f);
auto const rel = std::vector<uint32_t>(1, 0x5760);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5760);
auto const rel = std::vector<uint32_t>(1, 0x3629);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3629);
auto const rel = std::vector<uint32_t>(1, 0x362b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x362b);
auto const rel = std::vector<uint32_t>(1, 0x362d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x362d);
auto const rel = std::vector<uint32_t>(1, 0x362e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x362e);
auto const rel = std::vector<uint32_t>(1, 0x3630);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3630);
auto const rel = std::vector<uint32_t>(1, 0x2127c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x2127c);
auto const rel = std::vector<uint32_t>(1, 0x58ef);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x58ef);
auto const rel = std::vector<uint32_t>(1, 0x58f0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x58f0);
auto const rel = std::vector<uint32_t>(1, 0x58f1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x58f1);
auto const rel = std::vector<uint32_t>(1, 0x58f2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x58f2);
auto const rel = std::vector<uint32_t>(1, 0x58f3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x58f3);
auto const rel = std::vector<uint32_t>(1, 0x5906);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5906);
auto const rel = std::vector<uint32_t>(1, 0x590b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x590b);
auto const rel = std::vector<uint32_t>(1, 0x593d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x593d);
auto const rel = std::vector<uint32_t>(1, 0x593e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x593e);
auto const rel = std::vector<uint32_t>(1, 0x593f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x593f);
auto const rel = std::vector<uint32_t>(1, 0x5940);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5940);
auto const rel = std::vector<uint32_t>(1, 0x5941);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5941);
auto const rel = std::vector<uint32_t>(1, 0x5942);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5942);
auto const rel = std::vector<uint32_t>(1, 0x5989);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5989);
auto const rel = std::vector<uint32_t>(1, 0x598a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x598a);
auto const rel = std::vector<uint32_t>(1, 0x598b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x598b);
auto const rel = std::vector<uint32_t>(1, 0x598c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x598c);
auto const rel = std::vector<uint32_t>(1, 0x598e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x598e);
auto const rel = std::vector<uint32_t>(1, 0x598f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x598f);
auto const rel = std::vector<uint32_t>(1, 0x5990);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5990);
auto const rel = std::vector<uint32_t>(1, 0x5991);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5991);
auto const rel = std::vector<uint32_t>(1, 0x5992);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5992);
auto const rel = std::vector<uint32_t>(1, 0x5993);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5993);
auto const rel = std::vector<uint32_t>(1, 0x5994);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5994);
auto const rel = std::vector<uint32_t>(1, 0x5995);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5995);
auto const rel = std::vector<uint32_t>(1, 0x5996);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5996);
auto const rel = std::vector<uint32_t>(1, 0x5997);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5997);
auto const rel = std::vector<uint32_t>(1, 0x5998);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5998);
auto const rel = std::vector<uint32_t>(1, 0x5999);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5999);
auto const rel = std::vector<uint32_t>(1, 0x599a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x599a);
auto const rel = std::vector<uint32_t>(1, 0x599b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x599b);
auto const rel = std::vector<uint32_t>(1, 0x599c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x599c);
auto const rel = std::vector<uint32_t>(1, 0x599d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x599d);
auto const rel = std::vector<uint32_t>(1, 0x599e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_015)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x599e);
auto const rel = std::vector<uint32_t>(1, 0x599f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x599f);
auto const rel = std::vector<uint32_t>(1, 0x59a0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a0);
auto const rel = std::vector<uint32_t>(1, 0x59a1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a1);
auto const rel = std::vector<uint32_t>(1, 0x59a2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a2);
auto const rel = std::vector<uint32_t>(1, 0x59a3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a3);
auto const rel = std::vector<uint32_t>(1, 0x59a4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a4);
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, 0x59a6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a6);
auto const rel = std::vector<uint32_t>(1, 0x59a7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a7);
auto const rel = std::vector<uint32_t>(1, 0x59a8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a8);
auto const rel = std::vector<uint32_t>(1, 0x59a9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59a9);
auto const rel = std::vector<uint32_t>(1, 0x59aa);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59aa);
auto const rel = std::vector<uint32_t>(1, 0x59ab);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x59ab);
auto const rel = std::vector<uint32_t>(1, 0x36aa);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x36aa);
auto const rel = std::vector<uint32_t>(1, 0x36ac);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x36ac);
auto const rel = std::vector<uint32_t>(1, 0x216c0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x216c0);
auto const rel = std::vector<uint32_t>(1, 0x216c1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x216c1);
auto const rel = std::vector<uint32_t>(1, 0x216c2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x216c2);
auto const rel = std::vector<uint32_t>(1, 0x216d3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x216d3);
auto const rel = std::vector<uint32_t>(1, 0x216d5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x216d5);
auto const rel = std::vector<uint32_t>(1, 0x5b5a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b5a);
auto const rel = std::vector<uint32_t>(1, 0x5b5b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b5b);
auto const rel = std::vector<uint32_t>(1, 0x5b5c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b5c);
auto const rel = std::vector<uint32_t>(1, 0x5b5d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b5d);
auto const rel = std::vector<uint32_t>(1, 0x5b5e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b5e);
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, 0x5b8b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b8b);
auto const rel = std::vector<uint32_t>(1, 0x5b8c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b8c);
auto const rel = std::vector<uint32_t>(1, 0x5b8d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b8d);
auto const rel = std::vector<uint32_t>(1, 0x5b8e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b8e);
auto const rel = std::vector<uint32_t>(1, 0x5b8f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b8f);
auto const rel = std::vector<uint32_t>(1, 0x5b90);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b90);
auto const rel = std::vector<uint32_t>(1, 0x5b91);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b91);
auto const rel = std::vector<uint32_t>(1, 0x5b92);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5b92);
auto const rel = std::vector<uint32_t>(1, 0x5bfd);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5bfd);
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, 0x5bff);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5bff);
auto const rel = std::vector<uint32_t>(1, 0x5c28);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c28);
auto const rel = std::vector<uint32_t>(1, 0x5c29);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c29);
auto const rel = std::vector<uint32_t>(1, 0x5c2a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c2a);
auto const rel = std::vector<uint32_t>(1, 0x5c2b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c2b);
auto const rel = std::vector<uint32_t>(1, 0x5c2c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c2c);
auto const rel = std::vector<uint32_t>(1, 0x5c3e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c3e);
auto const rel = std::vector<uint32_t>(1, 0x5c3f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c3f);
auto const rel = std::vector<uint32_t>(1, 0x5c40);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c40);
auto const rel = std::vector<uint32_t>(1, 0x5c41);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c41);
auto const rel = std::vector<uint32_t>(1, 0x5c42);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c42);
auto const rel = std::vector<uint32_t>(1, 0x5c43);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c43);
auto const rel = std::vector<uint32_t>(1, 0x5c84);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c84);
auto const rel = std::vector<uint32_t>(1, 0x5c85);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c85);
auto const rel = std::vector<uint32_t>(1, 0x5c86);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_016)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c86);
auto const rel = std::vector<uint32_t>(1, 0x5c87);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c87);
auto const rel = std::vector<uint32_t>(1, 0x5c88);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c88);
auto const rel = std::vector<uint32_t>(1, 0x5c89);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c89);
auto const rel = std::vector<uint32_t>(1, 0x5c8a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c8a);
auto const rel = std::vector<uint32_t>(1, 0x5c8b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c8b);
auto const rel = std::vector<uint32_t>(1, 0x5c8c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c8c);
auto const rel = std::vector<uint32_t>(1, 0x5c8e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c8e);
auto const rel = std::vector<uint32_t>(1, 0x5c8f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c8f);
auto const rel = std::vector<uint32_t>(1, 0x5c90);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c90);
auto const rel = std::vector<uint32_t>(1, 0x5c91);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c91);
auto const rel = std::vector<uint32_t>(1, 0x5c92);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c92);
auto const rel = std::vector<uint32_t>(1, 0x5c93);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c93);
auto const rel = std::vector<uint32_t>(1, 0x5c94);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c94);
auto const rel = std::vector<uint32_t>(1, 0x5c95);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c95);
auto const rel = std::vector<uint32_t>(1, 0x5c96);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c96);
auto const rel = std::vector<uint32_t>(1, 0x5c97);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c97);
auto const rel = std::vector<uint32_t>(1, 0x5c98);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c98);
auto const rel = std::vector<uint32_t>(1, 0x5c99);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c99);
auto const rel = std::vector<uint32_t>(1, 0x5c9a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c9a);
auto const rel = std::vector<uint32_t>(1, 0x5c9b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c9b);
auto const rel = std::vector<uint32_t>(1, 0x5c9c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c9c);
auto const rel = std::vector<uint32_t>(1, 0x21d53);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x21d53);
auto const rel = std::vector<uint32_t>(1, 0x21d5e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x21d5e);
auto const rel = std::vector<uint32_t>(1, 0x5c8d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5c8d);
auto const rel = std::vector<uint32_t>(1, 0x5de0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5de0);
auto const rel = std::vector<uint32_t>(1, 0x5deb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5deb);
auto const rel = std::vector<uint32_t>(1, 0x5df5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5df5);
auto const rel = std::vector<uint32_t>(1, 0x5e09);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e09);
auto const rel = std::vector<uint32_t>(1, 0x5e0a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e0a);
auto const rel = std::vector<uint32_t>(1, 0x5e0b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e0b);
auto const rel = std::vector<uint32_t>(1, 0x5e0c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e0c);
auto const rel = std::vector<uint32_t>(1, 0x5e0d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e0d);
auto const rel = std::vector<uint32_t>(1, 0x5e0e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e0e);
auto const rel = std::vector<uint32_t>(1, 0x5e0f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e0f);
auto const rel = std::vector<uint32_t>(1, 0x5e10);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e10);
auto const rel = std::vector<uint32_t>(1, 0x3837);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3837);
auto const rel = std::vector<uint32_t>(1, 0x3838);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3838);
auto const rel = std::vector<uint32_t>(1, 0x3839);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3839);
auto const rel = std::vector<uint32_t>(1, 0x383b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x383b);
auto const rel = std::vector<uint32_t>(1, 0x5e87);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e87);
auto const rel = std::vector<uint32_t>(1, 0x5e88);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e88);
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, 0x5e8a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e8a);
auto const rel = std::vector<uint32_t>(1, 0x5e8b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e8b);
auto const rel = std::vector<uint32_t>(1, 0x5e8c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e8c);
auto const rel = std::vector<uint32_t>(1, 0x5e8d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e8d);
auto const rel = std::vector<uint32_t>(1, 0x5e8e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e8e);
auto const rel = std::vector<uint32_t>(1, 0x5e8f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e8f);
auto const rel = std::vector<uint32_t>(1, 0x5e90);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e90);
auto const rel = std::vector<uint32_t>(1, 0x5e91);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e91);
auto const rel = std::vector<uint32_t>(1, 0x5e92);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_017)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e92);
auto const rel = std::vector<uint32_t>(1, 0x5e93);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e93);
auto const rel = std::vector<uint32_t>(1, 0x5e94);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5e94);
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, 0x5f03);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f03);
auto const rel = std::vector<uint32_t>(1, 0x5f04);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f04);
auto const rel = std::vector<uint32_t>(1, 0x5f05);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f05);
auto const rel = std::vector<uint32_t>(1, 0x5f1d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f1d);
auto const rel = std::vector<uint32_t>(1, 0x5f1e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f1e);
auto const rel = std::vector<uint32_t>(1, 0x5f1f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f1f);
auto const rel = std::vector<uint32_t>(1, 0x5f20);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f20);
auto const rel = std::vector<uint32_t>(1, 0x223bd);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x223bd);
auto const rel = std::vector<uint32_t>(1, 0x5f62);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f62);
auto const rel = std::vector<uint32_t>(1, 0x5f63);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f63);
auto const rel = std::vector<uint32_t>(1, 0x5f64);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f64);
auto const rel = std::vector<uint32_t>(1, 0x5f76);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f76);
auto const rel = std::vector<uint32_t>(1, 0x5f77);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f77);
auto const rel = std::vector<uint32_t>(1, 0x5f78);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f78);
auto const rel = std::vector<uint32_t>(1, 0x5f79);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f79);
auto const rel = std::vector<uint32_t>(1, 0x5f7a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f7a);
auto const rel = std::vector<uint32_t>(1, 0x5f7b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5f7b);
auto const rel = std::vector<uint32_t>(1, 0x9fc8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9fc8);
auto const rel = std::vector<uint32_t>(1, 0x9fc9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x9fc9);
auto const rel = std::vector<uint32_t>(1, 0x224c9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x224c9);
auto const rel = std::vector<uint32_t>(1, 0x224cc);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x224cc);
auto const rel = std::vector<uint32_t>(1, 0x5fcc);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fcc);
auto const rel = std::vector<uint32_t>(1, 0x5fcd);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fcd);
auto const rel = std::vector<uint32_t>(1, 0x5fce);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fce);
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, 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);
}
{
// 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, 0x5fd7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fd7);
auto const rel = std::vector<uint32_t>(1, 0x5fd8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fd8);
auto const rel = std::vector<uint32_t>(1, 0x5fdc);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fdc);
auto const rel = std::vector<uint32_t>(1, 0x3900);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3900);
auto const rel = std::vector<uint32_t>(1, 0x5fdf);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fdf);
auto const rel = std::vector<uint32_t>(1, 0x5fe1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fe1);
auto const rel = std::vector<uint32_t>(1, 0x5fe3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fe3);
auto const rel = std::vector<uint32_t>(1, 0x5fe4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fe4);
auto const rel = std::vector<uint32_t>(1, 0x5fe6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fe6);
auto const rel = std::vector<uint32_t>(1, 0x5fe7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fe7);
auto const rel = std::vector<uint32_t>(1, 0x5fe8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fe8);
auto const rel = std::vector<uint32_t>(1, 0x5fea);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fea);
auto const rel = std::vector<uint32_t>(1, 0x5feb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5feb);
auto const rel = std::vector<uint32_t>(1, 0x5fec);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fec);
auto const rel = std::vector<uint32_t>(1, 0x5fed);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fed);
auto const rel = std::vector<uint32_t>(1, 0x5fee);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fee);
auto const rel = std::vector<uint32_t>(1, 0x5fef);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5fef);
auto const rel = std::vector<uint32_t>(1, 0x5ff0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ff0);
auto const rel = std::vector<uint32_t>(1, 0x5ff1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ff1);
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, 0x5ff3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_018)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ff3);
auto const rel = std::vector<uint32_t>(1, 0x5ff4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ff4);
auto const rel = std::vector<uint32_t>(1, 0x5ff6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ff6);
auto const rel = std::vector<uint32_t>(1, 0x5ff7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ff7);
auto const rel = std::vector<uint32_t>(1, 0x5ff8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ff8);
auto const rel = std::vector<uint32_t>(1, 0x5ff9);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ff9);
auto const rel = std::vector<uint32_t>(1, 0x5ffa);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ffa);
auto const rel = std::vector<uint32_t>(1, 0x5ffb);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ffb);
auto const rel = std::vector<uint32_t>(1, 0x5ffc);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ffc);
auto const rel = std::vector<uint32_t>(1, 0x5ffe);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x5ffe);
auto const rel = std::vector<uint32_t>(1, 0x6000);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6000);
auto const rel = std::vector<uint32_t>(1, 0x6003);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6003);
auto const rel = std::vector<uint32_t>(1, 0x6004);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6004);
auto const rel = std::vector<uint32_t>(1, 0x6005);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6005);
auto const rel = std::vector<uint32_t>(1, 0x6006);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6006);
auto const rel = std::vector<uint32_t>(1, 0x3908);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x3908);
auto const rel = std::vector<uint32_t>(1, 0x6211);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6211);
auto const rel = std::vector<uint32_t>(1, 0x6212);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6212);
auto const rel = std::vector<uint32_t>(1, 0x6213);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6213);
auto const rel = std::vector<uint32_t>(1, 0x22993);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x22993);
auto const rel = std::vector<uint32_t>(1, 0x623a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x623a);
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, 0x623c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x623c);
auto const rel = std::vector<uint32_t>(1, 0x626d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x626d);
auto const rel = std::vector<uint32_t>(1, 0x626e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x626e);
auto const rel = std::vector<uint32_t>(1, 0x626f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x626f);
auto const rel = std::vector<uint32_t>(1, 0x6270);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6270);
auto const rel = std::vector<uint32_t>(1, 0x6271);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6271);
auto const rel = std::vector<uint32_t>(1, 0x6272);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6272);
auto const rel = std::vector<uint32_t>(1, 0x6273);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6273);
auto const rel = std::vector<uint32_t>(1, 0x6274);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6274);
auto const rel = std::vector<uint32_t>(1, 0x6275);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6275);
auto const rel = std::vector<uint32_t>(1, 0x6276);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6276);
auto const rel = std::vector<uint32_t>(1, 0x6277);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6277);
auto const rel = std::vector<uint32_t>(1, 0x6279);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6279);
auto const rel = std::vector<uint32_t>(1, 0x627a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x627a);
auto const rel = std::vector<uint32_t>(1, 0x627b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x627b);
auto const rel = std::vector<uint32_t>(1, 0x627c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x627c);
auto const rel = std::vector<uint32_t>(1, 0x627d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x627d);
auto const rel = std::vector<uint32_t>(1, 0x627e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x627e);
auto const rel = std::vector<uint32_t>(1, 0x6280);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6280);
auto const rel = std::vector<uint32_t>(1, 0x6281);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6281);
auto const rel = std::vector<uint32_t>(1, 0x6282);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6282);
auto const rel = std::vector<uint32_t>(1, 0x6283);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6283);
auto const rel = std::vector<uint32_t>(1, 0x6284);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6284);
auto const rel = std::vector<uint32_t>(1, 0x6285);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6285);
auto const rel = std::vector<uint32_t>(1, 0x6286);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6286);
auto const rel = std::vector<uint32_t>(1, 0x6287);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6287);
auto const rel = std::vector<uint32_t>(1, 0x6288);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6288);
auto const rel = std::vector<uint32_t>(1, 0x6289);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6289);
auto const rel = std::vector<uint32_t>(1, 0x628a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x628a);
auto const rel = std::vector<uint32_t>(1, 0x628b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), 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_stroke_001_019)
{
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x628b);
auto const rel = std::vector<uint32_t>(1, 0x628c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x628c);
auto const rel = std::vector<uint32_t>(1, 0x628d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x628d);
auto const rel = std::vector<uint32_t>(1, 0x628e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x628e);
auto const rel = std::vector<uint32_t>(1, 0x628f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x628f);
auto const rel = std::vector<uint32_t>(1, 0x6290);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6290);
auto const rel = std::vector<uint32_t>(1, 0x6291);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6291);
auto const rel = std::vector<uint32_t>(1, 0x6292);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6292);
auto const rel = std::vector<uint32_t>(1, 0x6293);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6293);
auto const rel = std::vector<uint32_t>(1, 0x6294);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6294);
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, 0x6296);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6296);
auto const rel = std::vector<uint32_t>(1, 0x6297);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6297);
auto const rel = std::vector<uint32_t>(1, 0x6298);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6298);
auto const rel = std::vector<uint32_t>(1, 0x6299);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6299);
auto const rel = std::vector<uint32_t>(1, 0x629a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x629a);
auto const rel = std::vector<uint32_t>(1, 0x629b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x629b);
auto const rel = std::vector<uint32_t>(1, 0x629c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x629c);
auto const rel = std::vector<uint32_t>(1, 0x629d);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x629d);
auto const rel = std::vector<uint32_t>(1, 0x629e);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x629e);
auto const rel = std::vector<uint32_t>(1, 0x629f);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x629f);
auto const rel = std::vector<uint32_t>(1, 0x62a0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x62a0);
auto const rel = std::vector<uint32_t>(1, 0x62a1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x62a1);
auto const rel = std::vector<uint32_t>(1, 0x62a2);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x62a2);
auto const rel = std::vector<uint32_t>(1, 0x62a3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x62a3);
auto const rel = std::vector<uint32_t>(1, 0x62a4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x62a4);
auto const rel = std::vector<uint32_t>(1, 0x62a5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x62a5);
auto const rel = std::vector<uint32_t>(1, 0x39d1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x39d1);
auto const rel = std::vector<uint32_t>(1, 0x6278);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6278);
auto const rel = std::vector<uint32_t>(1, 0x6538);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6538);
auto const rel = std::vector<uint32_t>(1, 0x6539);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6539);
auto const rel = std::vector<uint32_t>(1, 0x653a);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x653a);
auto const rel = std::vector<uint32_t>(1, 0x653b);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x653b);
auto const rel = std::vector<uint32_t>(1, 0x653c);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x653c);
auto const rel = std::vector<uint32_t>(1, 0x22eef);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x22eef);
auto const rel = std::vector<uint32_t>(1, 0x6588);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6588);
auto const rel = std::vector<uint32_t>(1, 0x6598);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6598);
auto const rel = std::vector<uint32_t>(1, 0x65f0);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65f0);
auto const rel = std::vector<uint32_t>(1, 0x65f1);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65f1);
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, 0x65f3);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65f3);
auto const rel = std::vector<uint32_t>(1, 0x65f4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65f4);
auto const rel = std::vector<uint32_t>(1, 0x65f5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65f5);
auto const rel = std::vector<uint32_t>(1, 0x65f6);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65f6);
auto const rel = std::vector<uint32_t>(1, 0x65f7);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65f7);
auto const rel = std::vector<uint32_t>(1, 0x65f8);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x65f8);
auto const rel = std::vector<uint32_t>(1, 0x66f4);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x66f4);
auto const rel = std::vector<uint32_t>(1, 0x66f5);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x66f5);
auto const rel = std::vector<uint32_t>(1, 0x6744);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6744);
auto const rel = std::vector<uint32_t>(1, 0x6745);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6745);
auto const rel = std::vector<uint32_t>(1, 0x6746);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
{
// greater than (or equal to, for =) preceeding cps
auto const res = std::vector<uint32_t>(1, 0x6746);
auto const rel = std::vector<uint32_t>(1, 0x6747);
std::string const res_str = to_string(res);
std::string const rel_str = to_string(rel);
auto const res_view = as_utf32(res);
auto const rel_view = as_utf32(rel);
EXPECT_EQ(collate(
res.begin(), res.end(),
rel.begin(), rel.end(),
table(), collation_strength::primary),
-1);
EXPECT_EQ(collate(
res_view.begin(), res_view.end(),
rel_view.begin(), rel_view.end(),
table(), collation_strength::primary),
-1);
}
}
|
// EightQueens.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <bitset>
using namespace std;
#define NUM_ROWS_COLS 8
typedef struct _attacked_t {
bitset<NUM_ROWS_COLS> rows;
bitset<NUM_ROWS_COLS> cols;
bitset<NUM_ROWS_COLS * 2 - 1> slashes;
bitset<NUM_ROWS_COLS * 2 - 1> backslashes;
} attacked_t;
bool isRowAttacked(int y);
bool isColAttacked(int x);
bool isSlashAttacked(int x, int y);
bool isBackSlashAttacked(int x, int y);
void attackRow(int y);
void attackCol(int x);
void attackSlash(int x, int y);
void attackBackSlash(int x, int y);
void unAttackRow(int y);
void unAttackCol(int x);
void unAttackSlash(int x, int y);
void unAttackBackSlash(int x, int y);
void printChessBoard();
attacked_t attacked = { 0,0,0,0 };
char chessBoard[NUM_ROWS_COLS][NUM_ROWS_COLS] = { ' ' };
int placeQueen(int row);
void attackQueen(int x, int y);
void unAttackQueen(int x, int y);
int numChessBoards = 0;
int main()
{
placeQueen(0);
cout << endl << "Number of solutions for " << NUM_ROWS_COLS << "x" << NUM_ROWS_COLS << " board: " << numChessBoards << endl;
}
int placeQueen(int row) {
if (row == NUM_ROWS_COLS) {
numChessBoards++;
printChessBoard();
cout << endl << endl;
return 0;
}
for (int y = row; y < NUM_ROWS_COLS; y++) {
for (int x = 0; x < NUM_ROWS_COLS; x++) {
if (!isRowAttacked(y) && !isColAttacked(x) && !isSlashAttacked(x,y) && !isBackSlashAttacked(x,y)) {
attackQueen(x, y);
//printChessBoard();
placeQueen(y + 1);
unAttackQueen(x, y);
}
}
return 1;
}
}
void attackQueen(int x, int y) {
chessBoard[y][x] = 'Q';
attackRow(y);
attackCol(x);
attackSlash(x, y);
attackBackSlash(x, y);
}
void unAttackQueen(int x, int y) {
chessBoard[y][x] = ' ';
unAttackRow(y);
unAttackCol(x);
unAttackSlash(x, y);
unAttackBackSlash(x, y);
}
void printChessBoard() {
cout << "-";
for (int a = 0; a < NUM_ROWS_COLS; a++) {
cout << "----";
}
cout << endl;
//cout << "| Q | | | | | | | |";
for (int y = 0; y < NUM_ROWS_COLS; y++) {
cout << "|";
for (int x = 0; x < NUM_ROWS_COLS; x++) {
if (chessBoard[y][x] == 'Q') {
cout << " Q |";
}
else if (isColAttacked(x) || isRowAttacked(y) || isSlashAttacked(x,y) || isBackSlashAttacked(x,y)) {
chessBoard[y][x] = '*';
cout << " |";
}
else {
cout << " |";
}
}
cout << endl;
cout << "-";
for (int a = 0; a < NUM_ROWS_COLS; a++) {
cout << "----";
}
cout << endl;
}
}
bool isRowAttacked(int y) {
return attacked.rows[y];
}
bool isColAttacked(int x) {
return attacked.cols[x];
}
bool isSlashAttacked(int x, int y) {
return attacked.slashes[x + y];// &(1 << (x + y)));
}
bool isBackSlashAttacked(int x, int y) {
return attacked.backslashes[x - y + NUM_ROWS_COLS - 1];
}
void attackRow(int y) {
attacked.rows[y] = true;
}
void attackCol(int x) {
attacked.cols[x] = true;
}
void attackSlash(int x, int y) {
attacked.slashes[x + y] = true;
}
void attackBackSlash(int x, int y) {
attacked.backslashes[x - y + NUM_ROWS_COLS - 1] = true;
}
void unAttackRow(int y) {
attacked.rows[y] = false;
}
void unAttackCol(int x) {
attacked.cols[x] = false;
}
void unAttackSlash(int x, int y) {
attacked.slashes[x + y] = false;
}
void unAttackBackSlash(int x, int y) {
attacked.backslashes[x - y + NUM_ROWS_COLS - 1] = false;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
|
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "experimental/graphite/src/UniformCache.h"
#include "experimental/graphite/src/ContextUtils.h"
#include "src/core/SkOpts.h"
namespace skgpu {
size_t UniformCache::Hash::operator()(sk_sp<UniformData> ud) const {
return SkOpts::hash_fn(ud->data(), ud->dataSize(), 0);
}
bool UniformCache::Eq::operator()(sk_sp<UniformData> a, sk_sp<UniformData> b) const {
if (a->count() != b->count() ||
a->uniforms() != b->uniforms() ||
a->dataSize() != b->dataSize()) {
return false;
}
return !memcmp(a->data(), b->data(), a->dataSize()) &&
!memcmp(a->offsets(), b->offsets(), a->count()*sizeof(uint32_t));
};
UniformCache::UniformCache() {
// kInvalidUniformID (aka 0) is reserved
fUniformDataVector.push_back(nullptr);
}
sk_sp<UniformData> UniformCache::findOrCreate(sk_sp<UniformData> ud) {
auto iter = fUniformDataHash.find(ud);
if (iter != fUniformDataHash.end()) {
SkASSERT((*iter)->id() != UniformData::kInvalidUniformID);
return *iter;
}
ud->setID(fNextUniqueID++);
fUniformDataHash.insert(ud);
fUniformDataVector.push_back(ud);
SkASSERT(fUniformDataVector[ud->id()] == ud);
return ud;
}
sk_sp<UniformData> UniformCache::lookup(uint32_t uniqueID) {
SkASSERT(uniqueID < fUniformDataVector.size());
return fUniformDataVector[uniqueID];
}
} // namespace skgpu
|
#pragma once
#include <cassert>
#include "gl_1_5.h"
#define YKS_CHECK_GL assert(glGetError() == GL_NO_ERROR)
#ifdef _DEBUG
#define YKS_CHECK_GL_PARANOID assert(glGetError() == GL_NO_ERROR)
#else
#define YKS_CHECK_GL_PARANOID
#endif
|
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2017-2018 The Carypto Coin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "masternode-helpers.h"
#include "init.h"
#include "main.h"
#include "masternodeman.h"
#include "activemasternode.h"
#include "masternode-payments.h"
#include "swifttx.h"
// A helper object for signing messages from Masternodes
CMasternodeSigner masternodeSigner;
void ThreadMasternodePool()
{
if (fLiteMode) return; //disable all Masternode related functionality
// Make this thread recognisable
RenameThread("caryptocoin-mnpool");
unsigned int c = 0;
while (true) {
MilliSleep(1000);
// try to sync from all available nodes, one step at a time
masternodeSync.Process();
if (masternodeSync.IsBlockchainSynced()) {
c++;
// check if we should activate or ping every few minutes,
// start right after sync is considered to be done
if (c % MASTERNODE_PING_SECONDS == 0) activeMasternode.ManageStatus();
if (c % 60 == 0) {
mnodeman.CheckAndRemove();
masternodePayments.CleanPaymentList();
CleanTransactionLocksList();
}
}
}
}
bool CMasternodeSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey)
{
CScript payee2;
payee2 = GetScriptForDestination(pubkey.GetID());
CTransaction txVin;
uint256 hash;
if (GetTransaction(vin.prevout.hash, txVin, hash, true)) {
BOOST_FOREACH (CTxOut out, txVin.vout) {
if (out.nValue == MASTERNODE_COLLATERAL * COIN) {
if (out.scriptPubKey == payee2) return true;
}
}
}
return false;
}
bool CMasternodeSigner::SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey)
{
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strSecret);
if (!fGood) {
errorMessage = _("Invalid private key.");
return false;
}
key = vchSecret.GetKey();
pubkey = key.GetPubKey();
return true;
}
bool CMasternodeSigner::GetKeysFromSecret(std::string strSecret, CKey& keyRet, CPubKey& pubkeyRet)
{
CBitcoinSecret vchSecret;
if (!vchSecret.SetString(strSecret)) return false;
keyRet = vchSecret.GetKey();
pubkeyRet = keyRet.GetPubKey();
return true;
}
bool CMasternodeSigner::SignMessage(std::string strMessage, std::string& errorMessage, vector<unsigned char>& vchSig, CKey key)
{
CHashWriter ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;
if (!key.SignCompact(ss.GetHash(), vchSig)) {
errorMessage = _("Signing failed.");
return false;
}
return true;
}
bool CMasternodeSigner::VerifyMessage(CPubKey pubkey, vector<unsigned char>& vchSig, std::string strMessage, std::string& errorMessage)
{
CHashWriter ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;
CPubKey pubkey2;
if (!pubkey2.RecoverCompact(ss.GetHash(), vchSig)) {
errorMessage = _("Error recovering public key.");
return false;
}
if (fDebug && pubkey2.GetID() != pubkey.GetID())
LogPrintf("CMasternodeSigner::VerifyMessage -- keys don't match: %s %s\n", pubkey2.GetID().ToString(), pubkey.GetID().ToString());
return (pubkey2.GetID() == pubkey.GetID());
}
bool CMasternodeSigner::SetCollateralAddress(std::string strAddress)
{
CBitcoinAddress address;
if (!address.SetString(strAddress)) {
LogPrintf("CMasternodeSigner::SetCollateralAddress - Invalid collateral address\n");
return false;
}
collateralPubKey = GetScriptForDestination(address.Get());
return true;
}
|
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <unordered_map>
#include <functional>
#include <chrono>
using namespace std::chrono;
using namespace std;
void bitAdd(int a, int b, int& result, int& carry)
{
result = a ^ b;
carry = a & b;
}
void bitAdd(int a, int b, int c, int& result, int& carry)
{
int ab_sum, ab_carry;
bitAdd(a, b, ab_sum, ab_carry);
int abc_sum, abc_carry;
bitAdd(ab_sum, c, abc_sum, abc_carry);
result = abc_sum;
carry = ab_carry | abc_carry;
}
int toBit(int number)
{
return number & 1;
}
void shift(int &number)
{
number = number >> 1;
}
int add(int a, int b)
{
int results[32], carries[32];
//peform add
bitAdd(toBit(a), toBit(b), results[0], carries[0]);
for (int i = 1; i < 32; i++)
{
shift(a);
shift(b);
bitAdd(toBit(a), toBit(b), carries[i - 1], results[i], carries[i]);
}
//convert to int
int result = 0;
for (int i = 31; i > -1; i--)
{
result = result << 1;
result = result | results[i];
}
return result;
}
int main(void)
{
int result, carry;
add(123, 456);
return 0;
}
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on
* the source.
*/
/*
* $Logfile: /Freespace2/code/GlobalIncs/version.cpp $
* $Revision: 307 $
* $Date: 2010-02-08 09:09:13 +0100 (Mon, 08 Feb 2010) $
* $Author: taylor $
*
*
* $Log$
* Revision 1.3 2002/06/09 04:41:17 relnev
* added copyright header
*
* Revision 1.2 2002/05/07 03:16:45 theoddone33
* The Great Newline Fix
*
* Revision 1.1.1.1 2002/05/03 03:28:09 root
* Initial import.
*
*
* 4 8/09/99 2:21p Andsager
* Fix patching from multiplayer direct to launcher update tab.
*
* 3 8/06/99 3:32p Andsager
* Handle update when no registry is set
*
* 2 5/19/99 4:07p Dave
* Moved versioning code into a nice isolated common place. Fixed up
* updating code on the pxo screen. Fixed several stub problems.
*
* 1 5/18/99 4:28p Dave
*
* $NoKeywords: $
*/
#include <stdio.h>
#include <string.h>
#include "version.h"
#include "osregistry.h"
// ----------------------------------------------------------------------------------------------------------------
// VERSION DEFINES/VARS
//
// Defines
#define VER(major, minor, build) (100*100*major+100*minor+build)
#define MAX_LINE_LENGTH 512
// ----------------------------------------------------------------------------------------------------------------
// VERSION FUNCTIONS
//
// compare version against the passed version file
// returns -1 on error
// 0 if we are an earlier version
// 1 if same version
// 2 if higher version
// fills in user version and latest version values if non-NULL
int version_compare(const char *filename, int *u_major, int *u_minor, int *u_build, int *l_major, int *l_minor, int *l_build)
{
int usr_major, usr_minor, usr_build;
int latest_major, latest_minor, latest_build;
// open file and try backup, if needed
FILE *f = fopen(filename, "rt");
if (f == NULL) {
return -1;
}
// grab the last line in file which isn't empty and isn't a comment
char buffer[MAX_LINE_LENGTH+1], verbuffer[MAX_LINE_LENGTH+1];
strcpy(verbuffer,"");
strcpy(buffer,"");
while ( !feof(f) ) {
// Read the line into a temporary buffer
fgets(buffer, MAX_LINE_LENGTH, f);
// take the \n off the end of it
if (strlen(buffer)>0 && buffer[strlen(buffer) - 1] == '\n')
buffer[strlen(buffer) - 1] = 0;
// If the line is empty, go get another one
if (strlen(buffer) == 0) continue;
// If the line is a comment, go get another one
if (buffer[0] == VERSION_FILE_COMMENT_CHAR) continue;
// Line is a good one, so save it...
strcpy(verbuffer, buffer);
}
fclose(f);
// Make sure a version line was found
if (strlen(verbuffer) == 0) {
// MessageBox(XSTR("Couldn't parse Version file!", 1205), XSTR("Error!", 1185), MB_OK|MB_ICONERROR);
return -1;
}
// Get the most up to date Version number
latest_major = 0;
latest_minor = 0;
latest_build = 0;
if (sscanf(verbuffer, "%i %i %i", &latest_major, &latest_minor, &latest_build) != 3) {
// MessageBox(XSTR("Couldn't parse Version file!", 1205), XSTR("Error!", 1185), MB_OK|MB_ICONERROR);
return -1;
}
// retrieve the user's current version
usr_major = os_config_read_uint("Version", "Major", 0);
usr_minor = os_config_read_uint("Version", "Minor", 0);
usr_build = os_config_read_uint("Version", "Build", 0);
// Make sure the user's Version was found!
if ( VER(usr_major, usr_minor, usr_build) == 0 ) {
// MessageBox(XSTR("The Freespace 2 Auto-Update program could not find your current game Version in the system registry.\n\nThis should be corrected by starting up the game, exiting the game, and then running the Auto-Update program.", 1206), XSTR("Unable to Determine User's Version", 1207), MB_OK|MB_ICONERROR);
return NO_VERSION_IN_REGISTRY;
}
// stuff outgoing values
if(u_major != NULL){
*u_major = usr_major;
}
if(u_minor != NULL){
*u_minor = usr_minor;
}
if(u_build != NULL){
*u_build = usr_build;
}
if(l_major != NULL){
*l_major = latest_major;
}
if(l_minor != NULL){
*l_minor = latest_minor;
}
if(l_build != NULL){
*l_build = latest_build;
}
// check to see if the user's version is up to date
if (VER(usr_major, usr_minor, usr_build) < VER(latest_major, latest_minor, latest_build)) {
return 0;
}
// same version
return 1;
}
|
#include "brick.hpp"
#include "gtest/gtest.h"
using AST = brick::AST::AST;
using std::unique_ptr;
using std::make_unique;
TEST(ConstructionFromParse, Case1) {
unique_ptr<AST> ast = brick::AST::parse("3+4");
AST correct(make_unique<brick::AST::addition_node>());
correct.add_child(make_unique<brick::AST::number_node>(3));
correct.add_child(make_unique<brick::AST::number_node>(4));
ASSERT_TRUE(*ast == correct);
}
TEST(ConstructionFromParse, Case2) {
unique_ptr<AST> ast = brick::AST::parse("cos(x)");
AST correct(make_unique<brick::AST::cos_function_node>());
correct.add_child(make_unique<brick::AST::id_node>("x"));
ASSERT_TRUE(*ast == correct);
}
TEST(ConstructionFromParse, Case3) {
unique_ptr<AST> ast = brick::AST::parse("");
ASSERT_TRUE(ast == nullptr);
}
TEST(ConstructionFromParse, Case4) {
unique_ptr<AST> ast = brick::AST::parse("cos()");
AST correct(make_unique<brick::AST::cos_function_node>());
ASSERT_TRUE(*ast == correct);
}
TEST(ConstructionFromParse, Case5) {
unique_ptr<AST> ast = brick::AST::parse("([3+4]*12)-6");
AST correct(make_unique<brick::AST::subtraction_node>());
auto parens = correct.add_child(make_unique<brick::AST::parens_node>());
correct.add_child(make_unique<brick::AST::number_node>(6));
auto mul = parens->add_child(make_unique<brick::AST::multiplication_node>());
auto brackets = mul->add_child(make_unique<brick::AST::brackets_node>());
mul->add_child(make_unique<brick::AST::number_node>(12));
auto add = brackets->add_child(make_unique<brick::AST::addition_node>());
add->add_child(make_unique<brick::AST::number_node>(3));
add->add_child(make_unique<brick::AST::number_node>(4));
ASSERT_TRUE(*ast == correct);
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <utility>
int main()
{
std::map<std::string, std::vector<std::pair<std::string, std::string>>> fam;
std::string forename, surname, dob;
std::cout << "Enter surname: " << std::flush;
while (std::cin >> surname) {
std::cout << "Enter first name and DOB; enter `q` for new surname: "
<< std::flush;
while (std::cin >> forename >> dob && forename != "q") {
fam[surname].push_back({forename, dob});
std::cout << "Enter first name and DOB: " << std::flush;
}
std::cout << "Enter surname: " << std::flush;
}
std::cout << std::endl;
for (auto &f : fam) {
for (auto &p : f.second) {
std::cout << p.first << " " << f.first << ", born "
<< p.second << std::endl;
}
}
}
|
/**
* Copyright (c) 2021 OceanBase
* OceanBase Database Proxy(ODP) is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* 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 PubL v2 for more details.
*/
#define USING_LOG_PREFIX PROXY
#include "optimizer/ob_sharding_select_log_plan.h"
#include "engine/ob_proxy_operator_sort.h"
#include "engine/ob_proxy_operator_agg.h"
#include "engine/ob_proxy_operator_table_scan.h"
#include "engine/ob_proxy_operator_projection.h"
#include "obutils/ob_proxy_stmt.h"
using namespace oceanbase::obproxy::engine;
using namespace oceanbase::common;
using namespace oceanbase::obproxy::obutils;
namespace oceanbase
{
namespace obproxy
{
namespace optimizer
{
template <typename O, typename I>
int create_operator_and_input(ObIAllocator *allocator, O *&op, I *&input)
{
int ret = OB_SUCCESS;
void *ptr = NULL;
op = NULL;
input = NULL;
if (NULL == (ptr = allocator->alloc(sizeof(I)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc input failed", K(ret));
} else {
input = new (ptr) I();
}
if (OB_SUCC(ret) && (NULL == (ptr = allocator->alloc(sizeof(O))))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc operator failed", K(ret));
} else {
op = new (ptr) O(input, *allocator);
}
if (OB_SUCC(ret)) {
if (OB_FAIL(op->init())) {
LOG_WARN("op init failed", K(ret));
}
}
return ret;
}
ObShardingSelectLogPlan::ObShardingSelectLogPlan(obutils::ObSqlParseResult &parse_result,
ObIAllocator *allocator,
ObIArray<ObString> &physical_table_name_array)
: parse_result_(parse_result), allocator_(allocator), plan_root_(NULL),
shard_connector_array_(ObModIds::OB_PROXY_SHARDING_OPTIMIZER, OB_MALLOC_NORMAL_BLOCK_SIZE),
physical_table_name_array_(physical_table_name_array),
table_scan_(NULL), output_expr_array_(ObModIds::OB_PROXY_SHARDING_OPTIMIZER, OB_MALLOC_NORMAL_BLOCK_SIZE)
{
}
ObShardingSelectLogPlan::~ObShardingSelectLogPlan() {
if (NULL != plan_root_) {
plan_root_->~ObProxyOperator();
}
plan_root_ = NULL;
table_scan_ = NULL;
}
int ObShardingSelectLogPlan::generate_plan()
{
int ret = OB_SUCCESS;
LOG_DEBUG("begin to generate plan");
if (OB_FAIL(analyze_from_clause())) {
LOG_WARN("analyze from clause failed", K(ret));
} else if (OB_FAIL(analyze_where_clause())) {
LOG_WARN("analyze where clause failed", K(ret));
} else if (OB_FAIL(analyze_group_by_clause())) {
LOG_WARN("analyze group by clause failed", K(ret));
} else if (OB_FAIL(analyze_order_by_clause())) {
LOG_WARN("analyze order by clause failed", K(ret));
} else if (OB_FAIL(analyze_select_clause())) {
LOG_WARN("analyze select clause failed", K(ret));
}
if (OB_SUCC(ret)) {
if (OB_FAIL(add_projection_operator())) {
LOG_WARN("add projection operator failed", K(ret));
} else if (OB_FAIL(traverse_plan_tree(plan_root_))) {
LOG_WARN("traverse plan tree failed", K(ret));
} else {
print_plan_info();
}
}
return ret;
}
int ObShardingSelectLogPlan::analyze_from_clause()
{
int ret = OB_SUCCESS;
ObProxySelectStmt *select_stmt = static_cast<ObProxySelectStmt*>(parse_result_.get_proxy_stmt());
// generate table scan operator
ObProxyTableScanOp *table_scan_op = NULL;
ObProxyTableScanInput *table_scan_input = NULL;
if (OB_FAIL(create_operator_and_input(allocator_, table_scan_op, table_scan_input))) {
LOG_WARN("create operator and input failed", K(ret));
} else {
table_scan_ = table_scan_op;
table_scan_input->set_logical_table_name(parse_result_.get_origin_table_name());
table_scan_input->set_logical_database_name(parse_result_.get_origin_database_name());
table_scan_input->set_db_key_names(shard_connector_array_);
table_scan_input->set_phy_db_table_names(physical_table_name_array_);
table_scan_input->set_hint_string(select_stmt->hint_string_);
plan_root_ = table_scan_op;
}
return ret;
}
int ObShardingSelectLogPlan::analyze_where_clause() {
int ret = OB_SUCCESS;
ObProxySelectStmt *select_stmt = static_cast<ObProxySelectStmt*>(parse_result_.get_proxy_stmt());
ObIArray<ObProxyExpr*> &condition_expr_array = select_stmt->condition_exprs_;
if (condition_expr_array.count() > 0) {
if (1 != condition_expr_array.count()) {
ret = OB_ERR_UNEXPECTED;
} else {
ObProxyExpr* condition_expr = condition_expr_array.at(0);
if (condition_expr->has_agg()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("where expr has agg unexpected", K(ret));
} else {
ObProxyTableScanInput *table_scan_input = static_cast<ObProxyTableScanInput*>(table_scan_->get_input());
if (OB_FAIL(table_scan_input->get_condition_exprs().push_back(condition_expr))) {
LOG_WARN("push back condition expr failed", K(ret));
}
}
}
}
return ret;
}
int ObShardingSelectLogPlan::analyze_group_by_clause()
{
int ret = OB_SUCCESS;
ObProxySelectStmt *select_stmt = static_cast<ObProxySelectStmt*>(parse_result_.get_proxy_stmt());
ObIArray<ObProxyExpr*> &group_by_expr_array = select_stmt->group_by_exprs_;
bool has_agg = false;
ObProxyAggOp *agg_op = NULL;
ObProxyAggInput *agg_input = NULL;
if (group_by_expr_array.count() > 0) {
has_agg = true;
ObProxyMergeAggOp *merge_agg = NULL;
if (OB_FAIL(create_operator_and_input(allocator_, merge_agg, agg_input))) {
LOG_WARN("create operator and input for agg failed", K(ret));
} else {
agg_op = merge_agg;
ObProxyTableScanInput *table_scan_input = static_cast<ObProxyTableScanInput*>(table_scan_->get_input());
for (int64_t i = 0; OB_SUCC(ret) && i < group_by_expr_array.count(); i++) {
ObProxyExpr* expr = group_by_expr_array.at(i);
// group by must not follow agg func
if (expr->has_agg()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("group by expr is agg unexpected", K(ret));
} else if (expr->has_alias()) {
if (!expr->is_alias()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("has alias but alias is a sub expr", K(ret));
} else if (OB_FAIL(table_scan_input->get_group_by_exprs().push_back(expr))) {
LOG_WARN("table scan add group by expr failed", K(ret));
} else if (OB_FAIL(agg_input->get_group_by_exprs().push_back(expr))) {
LOG_WARN("agg add group by expr failed", K(ret));
} else {
//expr->set_index();
//do nothing, expr->index will be updated in ObProxyAggOp::init_group_by_columns
}
} else if (OB_FAIL(output_expr_array_.push_back(expr))) {
LOG_WARN("output expr array push back failed", K(ret));
} else if (OB_FAIL(table_scan_input->get_group_by_exprs().push_back(expr))) {
LOG_WARN("table scan add group by expr failed", K(ret));
} else if (OB_FAIL(agg_input->get_group_by_exprs().push_back(expr))) {
LOG_WARN("agg add group by expr failed", K(ret));
} else {
expr->set_index(output_expr_array_.count() - 1);
}
}
}
} else {
for (int64_t i = 0; !has_agg && i < select_stmt->order_by_exprs_.count(); i++) {
if (select_stmt->order_by_exprs_.at(i)->has_agg()) {
has_agg = true;
}
}
for (int64_t i = 0; !has_agg && i < select_stmt->select_exprs_.count(); i++) {
if (select_stmt->select_exprs_.at(i)->has_agg()) {
has_agg = true;
}
}
if (has_agg && OB_FAIL(create_operator_and_input(allocator_, agg_op, agg_input))) {
LOG_WARN("create operator and input for agg failed", K(ret));
}
}
if (OB_SUCC(ret) && has_agg) {
if (OB_FAIL(agg_op->set_child(0, plan_root_))) {
LOG_WARN("set child failed", K(ret));
} else {
plan_root_ = agg_op;
}
}
return ret;
}
int ObShardingSelectLogPlan::handle_avg_expr(opsql::ObProxyExprAvg *agg_expr)
{
int ret = OB_SUCCESS;
ObProxyExprSum *sum_expr = NULL;
void *ptr = NULL;
if (OB_ISNULL(ptr = allocator_->alloc(sizeof(ObProxyExprSum)))) {
ret = common::OB_ALLOCATE_MEMORY_FAILED;
} else {
sum_expr = new (ptr) ObProxyExprSum();
sum_expr->set_expr_type(OB_PROXY_EXPR_TYPE_FUNC_SUM);
sum_expr->set_param_array(agg_expr->get_param_array());
sum_expr->has_agg_ = 1;
if (OB_FAIL(output_expr_array_.push_back(sum_expr))) {
LOG_WARN("output expr push back failed", K(ret));
} else {
agg_expr->set_sum_index(output_expr_array_.count() - 1);
sum_expr->set_index(output_expr_array_.count() - 1);
}
}
if (OB_SUCC(ret))
{
ObProxyExprCount *count_expr = NULL;
void *ptr = allocator_->alloc(sizeof(ObProxyExprCount));
if (OB_UNLIKELY(NULL == ptr)) {
ret = common::OB_ALLOCATE_MEMORY_FAILED;
} else {
count_expr = new (ptr) ObProxyExprCount();
count_expr->set_expr_type(OB_PROXY_EXPR_TYPE_FUNC_COUNT);
count_expr->set_param_array(agg_expr->get_param_array());
count_expr->has_agg_ = 1;
if (OB_FAIL(output_expr_array_.push_back(count_expr))) {
LOG_WARN("output expr push back failed", K(ret));
} else {
agg_expr->set_count_index(output_expr_array_.count() - 1);
count_expr->set_index(output_expr_array_.count() - 1);
}
}
}
return ret;
}
int ObShardingSelectLogPlan::analyze_order_by_clause()
{
int ret = OB_SUCCESS;
ObProxySelectStmt *select_stmt = static_cast<ObProxySelectStmt*>(parse_result_.get_proxy_stmt());
ObIArray<ObProxyOrderItem*> *order_by_expr_array = &select_stmt->order_by_exprs_;
ObProxyOperator *sort_op = NULL;
ObProxySortInput *sort_input = NULL;
ObProxyTableScanInput *table_scan_input = static_cast<ObProxyTableScanInput*>(table_scan_->get_input());
if (order_by_expr_array->count() > 0) {
if (select_stmt->limit_start_ > 0) {
ObProxyTopKOp *topK = NULL;
if (OB_FAIL(create_operator_and_input(allocator_, topK, sort_input))) {
LOG_WARN("create operator and input for topk failed", K(ret));
} else {
sort_op = topK;
}
} else {
ObProxyMemSortOp *mem_sort = NULL;
if (OB_FAIL(create_operator_and_input(allocator_, mem_sort, sort_input))) {
LOG_WARN("create operator and input for mem sort failed", K(ret));
} else {
sort_op = mem_sort;
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(sort_op->set_child(0, plan_root_))) {
LOG_WARN("set child failed", K(ret));
} else {
plan_root_ = sort_op;
}
}
for (int64_t i = 0; OB_SUCC(ret) && i < order_by_expr_array->count(); i++) {
ObProxyOrderItem *order_item = order_by_expr_array->at(i);
ObProxyExpr *expr = order_item->expr_;
if ((!expr->has_agg() && !expr->has_alias()) || expr->is_agg()) {
if (OB_FAIL(output_expr_array_.push_back(expr))) {
LOG_WARN("output expr push failed", K(ret));
} else if (OB_FAIL(sort_input->get_order_by_expr().push_back(order_item))) {
LOG_WARN("add order by expr failed", K(ret));
} else if (OB_FAIL(table_scan_input->get_order_by_exprs().push_back(order_item))) {
LOG_WARN("table scan add order by expr failed", K(ret));
} else {
expr->set_index(output_expr_array_.count() - 1);
}
} else if (expr->is_alias()) {
if (expr->has_agg() && !expr->is_agg()) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("has agg not support", K(ret), K(expr));
} else if (OB_FAIL(sort_input->get_order_by_expr().push_back(order_item))) {
LOG_WARN("add order by expr failed", K(ret));
} else if (OB_FAIL(table_scan_input->get_order_by_exprs().push_back(order_item))) {
LOG_WARN("table scan add order by expr failed", K(ret));
}
} else {
ret = OB_NOT_SUPPORTED;
ObProxyExpr::print_proxy_expr(expr);
LOG_WARN("not support", K(ret), K(*expr));
}
}
}
return ret;
}
int ObShardingSelectLogPlan::analyze_select_clause()
{
int ret = OB_SUCCESS;
ObProxySelectStmt *select_stmt = static_cast<ObProxySelectStmt*>(parse_result_.get_proxy_stmt());
ObIArray<ObProxyExpr*> &select_expr_array = select_stmt->select_exprs_;
for (int64_t i = 0; OB_SUCC(ret) && i < select_expr_array.count(); i++) {
ObProxyExpr *expr = select_expr_array.at(i);
if (expr->has_agg()) {
ObSEArray<ObProxyExpr*, 4> agg_expr_array;
if (OB_FAIL(get_agg_related_expr(expr, agg_expr_array))) {
LOG_WARN("get agg related expr failed", K(ret), K(expr));
} else {
for (int64_t j = 0; OB_SUCC(ret) && j < agg_expr_array.count(); j++) {
ObProxyExpr *agg_expr = agg_expr_array.at(j);
if (OB_PROXY_EXPR_TYPE_FUNC_AVG == agg_expr->get_expr_type()) {
if (OB_FAIL(handle_avg_expr(static_cast<ObProxyExprAvg *>(agg_expr)))) {
LOG_WARN("handle avg expr failed", K(ret));
}
} else {
if (OB_FAIL(output_expr_array_.push_back(agg_expr))) {
LOG_WARN("output expr push back failed", K(ret));
} else {
agg_expr->set_index(output_expr_array_.count() - 1);
}
}
}
}
}
}
for (int64_t i = select_expr_array.count() - 1; OB_SUCC(ret) && i >=0; i--) {
ObProxyExpr *expr = select_expr_array.at(i);
if (OB_FAIL(output_expr_array_.push_back(expr))) {
LOG_WARN("output expr push failed", K(ret));
} else if (!expr->has_agg() && !expr->is_star_expr()) {
expr->set_index(output_expr_array_.count() - 1);
}
if (expr->is_star_expr() && i != 0) {
ret = OB_ERR_PARSER_SYNTAX;
LOG_WARN("* is not fisrt expr in select", K(ret));
}
}
for (int64_t i = 0, j = output_expr_array_.count() - 1; OB_SUCC(ret) && i < j; i++, j--) {
ObProxyExpr *tmp_expr = output_expr_array_.at(i);
output_expr_array_.at(i) = output_expr_array_.at(j);
output_expr_array_.at(j) = tmp_expr;
}
return ret;
}
int ObShardingSelectLogPlan::add_projection_operator() {
int ret = OB_SUCCESS;
ObProxySelectStmt *select_stmt = static_cast<ObProxySelectStmt*>(parse_result_.get_proxy_stmt());
ObProxyProOp *op = NULL;
ObProxyProInput *input = NULL;
if (OB_FAIL(create_operator_and_input(allocator_, op, input))) {
LOG_WARN("create projection failed", K(ret));
} else {
input->set_select_exprs(select_stmt->select_exprs_);
if (OB_FAIL(op->set_child(0, plan_root_))) {
LOG_WARN("set child failed", K(ret));
} else {
plan_root_ = op;
}
}
return ret;
}
int ObShardingSelectLogPlan::get_agg_related_expr(ObProxyExpr* expr, ObIArray<ObProxyExpr*> &array)
{
int ret = OB_SUCCESS;
if (NULL != expr && OB_SUCC(ret)) {
if (expr->is_alias()) {
ObProxyExprShardingConst *const_expr = static_cast<ObProxyExprShardingConst*>(expr);
if (OB_FAIL(get_agg_related_expr(const_expr->expr_, array))) {
LOG_WARN("get agg related expr failed", K(ret));
}
} else if (!expr->has_agg() || expr->is_agg()) {
if(OB_FAIL(array.push_back(expr))) {
LOG_WARN("push back expr failed", K(ret));
}
} else if (!expr->is_func_expr()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected error", K(ret), K(*expr));
} else {
ObProxyFuncExpr *func_expr = static_cast<ObProxyFuncExpr*>(expr);
int64_t count = func_expr->get_param_array().count();
if (OB_PROXY_EXPR_TYPE_SHARDING_ALIAS == func_expr->get_expr_type()) {
count--;
}
for (int64_t i = 0; OB_SUCC(ret) && i < count; i++) {
ObProxyExpr* param_expr = func_expr->get_param_array().at(i);
if (OB_FAIL(get_agg_related_expr(param_expr, array))) {
LOG_WARN("get agg related expr failed", K(ret));
}
}
}
}
return ret;
}
int ObShardingSelectLogPlan::traverse_plan_tree(ObProxyOperator *op)
{
int ret = OB_SUCCESS;
if (NULL != op) {
ObProxySelectStmt *select_stmt = static_cast<ObProxySelectStmt *>(parse_result_.get_proxy_stmt());
ObProxyOpInput* input = op->get_input();
input->set_op_limit(select_stmt->limit_start_, select_stmt->limit_offset_);
input->set_select_exprs(output_expr_array_);
input->set_added_row_count(output_expr_array_.count() - select_stmt->select_exprs_.count());
if (OB_FAIL(traverse_plan_tree(op->get_child(0)))) {
LOG_WARN("traverse plan tree failed", K(ret));
}
}
return ret;
}
void ObShardingSelectLogPlan::print_plan_info()
{
LOG_DEBUG("plan output info", K(output_expr_array_.count()));
for (int64_t i = 0; i < output_expr_array_.count(); i++) {
ObProxyExpr::print_proxy_expr(output_expr_array_.at(i));
}
ObProxyOperator::print_execute_plan_info(plan_root_);
}
int ObShardingSelectLogPlan::set_shard_connector_array(const ObIArray<dbconfig::ObShardConnector*> & array)
{
int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < array.count(); i++) {
dbconfig::ObShardConnector *connector = array.at(i);
if (OB_FAIL(shard_connector_array_.push_back(connector))) {
LOG_WARN("shard connector push back failed", K(ret));
}
}
return ret;
}
} // end optimizer
} // end obproxy
} // end oceanbase
|
#ifndef _ML_TERMINAL_HPP_
#define _ML_TERMINAL_HPP_
#include <modus_core/gui/TextLog.hpp>
namespace ml::ImGuiExt
{
// TERMINAL
struct ML_NODISCARD Terminal final : non_copyable, trackable
{
public:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
using allocator_type = typename pmr::polymorphic_allocator<byte>;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
struct ML_NODISCARD CommandData final
{
string name;
list<string> info;
method<void(string &&)> proc;
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
string UserName, HostName, PathName, ModeName; // info
array<char, 256> Input; // input
TextLog Output; // output
TextLog::Printer Printer;
list<CommandData> Commands; // commands
list<string> History; // history
int32 HistoryPos; // history pos
// colors
struct ML_NODISCARD {
color
Delimeter { colors::white },
UserName { colors::aqua },
HostName { colors::magenta },
PathName { colors::cyan },
ModeName { colors::fuchsia };
} Colors;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Terminal(allocator_type alloc = {}) noexcept
: UserName { alloc }
, HostName { alloc }
, PathName { alloc }
, ModeName { alloc }
, Input {}
, Output { alloc }
, Printer {}
, Commands { alloc }
, History { alloc }
, HistoryPos{ -1 }
, Colors {}
{
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void DrawPrefixOptions()
{
// USER
char username[32]{}; std::strcpy(username, UserName.c_str());
ImGui::TextDisabled("user"); ImGui::SameLine();
if (ImGui::InputText("##username", username, ML_arraysize(username), ImGuiInputTextFlags_EnterReturnsTrue)) {
UserName = username;
} ImGui::SameLine();
ImGui::ColorEdit4("##usercolor", Colors.UserName, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
// HOST
char hostname[32]{}; std::strcpy(hostname, HostName.c_str());
ImGui::TextDisabled("host"); ImGui::SameLine();
if (ImGui::InputText("##hostname", hostname, ML_arraysize(hostname), ImGuiInputTextFlags_EnterReturnsTrue)) {
HostName = hostname;
} ImGui::SameLine();
ImGui::ColorEdit4("##hostcolor", Colors.HostName, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
// PATH
char pathname[32]{}; std::strcpy(pathname, PathName.c_str());
ImGui::TextDisabled("path"); ImGui::SameLine();
if (ImGui::InputText("##pathname", pathname, ML_arraysize(pathname), ImGuiInputTextFlags_EnterReturnsTrue)) {
PathName = pathname;
} ImGui::SameLine();
ImGui::ColorEdit4("##pathcolor", Colors.PathName, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
// MODE
char modename[32]{}; std::strcpy(modename, ModeName.c_str());
ImGui::TextDisabled("mode"); ImGui::SameLine();
if (ImGui::InputText("##modename", modename, ML_arraysize(modename), ImGuiInputTextFlags_EnterReturnsTrue)) {
ModeName = modename;
} ImGui::SameLine();
ImGui::ColorEdit4("##modecolor", Colors.ModeName, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
}
void DrawPrefix()
{
// PREFIX user@host:path$ /mode
ImGui::BeginGroup();
ImGui::AlignTextToFramePadding();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 0, 0 });
ImGui::PushStyleColor(ImGuiCol_Text, Colors.Delimeter);
if (!UserName.empty()) {
ImGui::PushStyleColor(ImGuiCol_Text, Colors.UserName);
ImGui::Text("%.*s", UserName.size(), UserName.data());
ImGui::PopStyleColor(); ImGui::SameLine();
}
ImGui::Text("@"); ImGui::SameLine();
if (!HostName.empty()) {
ImGui::PushStyleColor(ImGuiCol_Text, Colors.HostName);
ImGui::Text("%.*s", HostName.size(), HostName.data());
ImGui::PopStyleColor(); ImGui::SameLine();
}
ImGui::Text(":"); ImGui::SameLine();
if (!PathName.empty()) {
ImGui::PushStyleColor(ImGuiCol_Text, Colors.PathName);
ImGui::Text("%.*s", PathName.size(), PathName.data());
ImGui::PopStyleColor(); ImGui::SameLine();
}
ImGui::Text("$"); ImGui::SameLine();
if (!ModeName.empty()) {
ImGui::Text(" /"); ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, Colors.ModeName);
ImGui::Text("%.*s", ModeName.size(), ModeName.data());
ImGui::PopStyleColor(); ImGui::SameLine();
}
ImGui::PopStyleColor();
ImGui::PopStyleVar();
ImGui::EndGroup();
}
void DrawInput()
{
ImGui::BeginGroup(); ML_defer(&) { ImGui::EndGroup(); };
ImGui::AlignTextToFramePadding();
bool reclaim_focus{};
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
if (ImGui::InputText
(
"##input_text",
Input.data(),
Input.max_size(),
ImGuiInputTextFlags_EnterReturnsTrue |
ImGuiInputTextFlags_CallbackCompletion |
ImGuiInputTextFlags_CallbackHistory,
[](auto u) { return ((Terminal *)u->UserData)->InputTextCallbackStub(u); },
this
))
{
if (Input) {
Execute(Input.data());
Output.ScrollToBottom = true;
}
std::strcpy(Input, "");
reclaim_focus = true;
}
ImGui::PopItemWidth();
ImGui::SetItemDefaultFocus(); // focus on window apparition
if (reclaim_focus) { ImGui::SetKeyboardFocusHere(-1); } // focus previous widget
}
void DrawOutput(TextLog::Printer const & printer = {})
{
Output.Draw(printer);
}
bool Draw(cstring title, bool * p_open = NULL, ImGuiWindowFlags flags = ImGuiWindowFlags_MenuBar)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 4, 4 });
bool const is_open{ ImGui::Begin(title, p_open, flags) };
ImGui::PopStyleVar(1);
if (is_open)
{
// menubar
if (ImGui::BeginMenuBar()) {
ImGui::TextDisabled("filter"); ImGui::SameLine();
Output.Filter.Draw("##filter", 256);
ImGui::Separator();
if (ImGui::BeginMenu("options")) {
ImGui::Checkbox("auto scroll", &Output.AutoScroll);
ImGui::Separator();
DrawPrefixOptions();
ImGui::EndMenu();
}
ImGui::Separator();
if (ImGui::MenuItem("clear")) { Output.Lines.clear(); }
ImGui::Separator();
ImGui::EndMenuBar();
}
// output
if (ImGui::BeginChild("##output", { 0, -ImGui::GetFrameHeightWithSpacing() }, false, ImGuiWindowFlags_HorizontalScrollbar)) {
DrawOutput(Printer);
}
ImGui::EndChild();
// input
if (ImGui::BeginChild("##input", {}, false, ImGuiWindowFlags_NoScrollbar)) {
DrawPrefix(); ImGui::SameLine();
DrawInput();
}
ImGui::EndChild();
}
ImGui::End();
return is_open;
}
int32 Execute(string line)
{
// empty check
if (util::trim(line).empty()) { return debug::fail(); }
// add to history
Output.Printf("# %s\n", line.c_str());
HistoryPos = -1;
if (auto const it{ std::find(History.begin(), History.end(), line) }
; it != History.end()) {
History.erase(it);
} History.push_back(line);
// validate format
if ((line.front() != '/' && ModeName.empty()) || util::trim_front(line, [
](char c) { return c == '/' || util::is_whitespace(c); }).empty()) {
return debug::fail();
}
// process command
string name;
if (!ModeName.empty()) {
name = ModeName;
}
else if (size_t const i{ line.find_first_of(' ') }; i != line.npos) {
name = line.substr(0, i);
line = line.substr(i + 1);
}
else {
name = line;
line.clear();
}
// execute procedure
if (auto const it{ std::find_if(Commands.begin(), Commands.end(), [&](CommandData const & e) {
return name == e.name;
}) }; it != Commands.end())
{
std::invoke(it->proc, std::move(line));
return true;
}
else
{
return debug::fail("unknown command: {0} {1}", name, line);
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
private:
int32 InputTextCallbackStub(ImGuiInputTextCallbackData * data)
{
switch (data->EventFlag)
{
// COMPLETION
case ImGuiInputTextFlags_CallbackCompletion: {
// locate beginning of current word
cstring last{ data->Buf + data->CursorPos }, first{ last };
while (first > data->Buf)
{
if (char const c{ first[-1] }
; util::is_whitespace(c) || c == ',' || c == ';' || c == '/')
{
break;
}
first--;
}
// build list of candidates
list<cstring> candidates{};
for (auto const & e : this->Commands)
{
cstring name{ e.name.c_str() };
if (!std::strncmp(name, first, (size_t)(last - first)))
{
candidates.push_back(name);
}
}
// no matches
if (candidates.empty())
{
Output.Printf("# %.*s\n", (size_t)(last - first), first);
}
// single match
else if (candidates.size() == 1)
{
// entirely replace beginning of word
data->DeleteChars((int32)(first - data->Buf), (int32)(last - first));
data->InsertChars(data->CursorPos, candidates[0]);
data->InsertChars(data->CursorPos, " ");
}
// multiple matches
else
{
// complete as much as we can
auto match_len{ (size_t)(last - first) };
for (;;)
{
size_t c{};
bool all_match{ true };
for (size_t i = 0; i < candidates.size() && all_match; ++i)
{
if (!i) { c = std::toupper(candidates[i][match_len]); }
else if (c == 0 || c != std::toupper(candidates[i][match_len])) {
all_match = false;
}
}
if (!all_match) {
break;
}
match_len++;
}
if (match_len > 0) {
data->DeleteChars((int32)(first - data->Buf), (int32)(last - first));
data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len);
}
// display suggestions
Output.Printf("suggestions:\n");
for (size_t i = 0; i < candidates.size(); ++i)
{
Output.Printf("- %s\n", candidates[i]);
}
}
} break;
// HISTORY
case ImGuiInputTextFlags_CallbackHistory: {
int32 const prev_pos{ HistoryPos };
if (data->EventKey == ImGuiKey_UpArrow)
{
if (HistoryPos == -1)
{
HistoryPos = (int32)History.size() - 1;
}
else if (HistoryPos > 0)
{
HistoryPos--;
}
}
else if (data->EventKey == ImGuiKey_DownArrow)
{
if (HistoryPos != -1 && (++HistoryPos >= (int32)History.size()))
{
HistoryPos = -1;
}
}
if (prev_pos != HistoryPos)
{
auto history_str{ (HistoryPos >= 0) ? History[HistoryPos].c_str() : "" };
data->DeleteChars(0, data->BufTextLen);
data->InsertChars(0, history_str);
}
} break;
}
return 0;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
};
}
#endif // !_ML_TERMINAL_HPP_
|
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////
#pragma once
#include <functional>
#include <future>
#include <thread>
#include "jsc_init.hpp"
#include "concurrent_deque.hpp"
#include "json.hpp"
#include "js_network_transport.hpp"
namespace realm {
class ObjectSchema;
namespace rpc {
using json = nlohmann::json;
using RPCObjectID = u_int64_t;
using RPCRequest = std::function<json(const json)>;
using NetworkTransportFactory = typename js::JavaScriptNetworkTransport<jsc::Types>::NetworkTransportFactory;
class RPCWorker {
public:
RPCWorker();
~RPCWorker();
template<typename Fn>
json add_task(Fn&&);
void invoke_callback(json);
json resolve_callback(json args);
std::future<json> add_promise();
bool try_run_task();
void stop();
json try_pop_callback();
bool should_stop();
private:
bool m_stop = false;
int m_depth = 0;
#if __APPLE__
std::thread m_thread;
CFRunLoopRef m_loop;
#endif
ConcurrentDeque<std::function<void()>> m_tasks;
ConcurrentDeque<std::promise<json>> m_promises;
ConcurrentDeque<json> m_callbacks;
};
class RPCServer {
public:
RPCServer();
~RPCServer();
json perform_request(std::string const& name, json&& args);
bool try_run_task();
private:
JSGlobalContextRef m_context;
std::mutex m_request_mutex;
std::map<std::string, RPCRequest> m_requests;
std::map<RPCObjectID, js::Protected<JSObjectRef>> m_objects;
std::map<RPCObjectID, js::Protected<JSObjectRef>> m_callbacks;
// The key here is the same as the value in m_callbacks. We use the raw pointer as a key here,
// because protecting the value in m_callbacks pins the function object and prevents it from being moved
// by the garbage collector upon compaction.
std::map<JSObjectRef, RPCObjectID> m_callback_ids;
RPCObjectID m_session_id;
RPCWorker m_worker;
u_int64_t m_callback_call_counter;
uint64_t m_reset_counter = 0;
std::mutex m_pending_callbacks_mutex;
std::map<std::pair<uint64_t, uint64_t>, std::promise<json>> m_pending_callbacks;
NetworkTransportFactory previous_transport_generator;
static JSValueRef run_callback(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef *exception);
RPCObjectID store_object(JSObjectRef object);
JSObjectRef get_object(RPCObjectID) const;
JSObjectRef get_realm_constructor() const;
json serialize_json_value(JSValueRef value);
JSValueRef deserialize_json_value(const json dict);
};
} // rpc
} // realm
|
/*
* Copyright 2010-2017 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 <aws/iot/model/GetStatisticsRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::IoT::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
GetStatisticsRequest::GetStatisticsRequest() :
m_indexNameHasBeenSet(false),
m_queryStringHasBeenSet(false),
m_aggregationFieldHasBeenSet(false),
m_queryVersionHasBeenSet(false)
{
}
Aws::String GetStatisticsRequest::SerializePayload() const
{
JsonValue payload;
if(m_indexNameHasBeenSet)
{
payload.WithString("indexName", m_indexName);
}
if(m_queryStringHasBeenSet)
{
payload.WithString("queryString", m_queryString);
}
if(m_aggregationFieldHasBeenSet)
{
payload.WithString("aggregationField", m_aggregationField);
}
if(m_queryVersionHasBeenSet)
{
payload.WithString("queryVersion", m_queryVersion);
}
return payload.View().WriteReadable();
}
|
/*
* Copyright © 2016 Mozilla Foundation
*
* This program is made available under an ISC-style license. See the
* accompanying file LICENSE for details.
*/
#define NOMINMAX
#include "cubeb_log.h"
#include "cubeb_ringbuffer.h"
#include <cstdarg>
#ifdef _WIN32
#include <windows.h>
#else
#include <time.h>
#endif
cubeb_log_level g_cubeb_log_level;
cubeb_log_callback g_cubeb_log_callback;
/** The maximum size of a log message, after having been formatted. */
const size_t CUBEB_LOG_MESSAGE_MAX_SIZE = 256;
/** The maximum number of log messages that can be queued before dropping
* messages. */
const size_t CUBEB_LOG_MESSAGE_QUEUE_DEPTH = 40;
/** Number of milliseconds to wait before dequeuing log messages. */
#define CUBEB_LOG_BATCH_PRINT_INTERVAL_MS 10
/**
* This wraps an inline buffer, that represents a log message, that must be
* null-terminated.
* This class should not use system calls or other potentially blocking code.
*/
class cubeb_log_message {
public:
cubeb_log_message() { *storage = '\0'; }
cubeb_log_message(char const str[CUBEB_LOG_MESSAGE_MAX_SIZE])
{
size_t length = strlen(str);
/* paranoia against malformed message */
assert(length < CUBEB_LOG_MESSAGE_MAX_SIZE);
if (length > CUBEB_LOG_MESSAGE_MAX_SIZE - 1) {
return;
}
PodCopy(storage, str, length);
storage[length] = '\0';
}
char const * get() { return storage; }
private:
char storage[CUBEB_LOG_MESSAGE_MAX_SIZE];
};
/** Lock-free asynchronous logger, made so that logging from a
* real-time audio callback does not block the audio thread. */
class cubeb_async_logger {
public:
/* This is thread-safe since C++11 */
static cubeb_async_logger & get()
{
static cubeb_async_logger instance;
return instance;
}
void push(char const str[CUBEB_LOG_MESSAGE_MAX_SIZE])
{
cubeb_log_message msg(str);
msg_queue.enqueue(msg);
}
void run()
{
std::thread([this]() {
while (true) {
cubeb_log_message msg;
while (msg_queue.dequeue(&msg, 1)) {
LOGV("%s", msg.get());
}
#ifdef _WIN32
Sleep(CUBEB_LOG_BATCH_PRINT_INTERVAL_MS);
#else
timespec sleep_duration = sleep_for;
timespec remainder;
do {
if (nanosleep(&sleep_duration, &remainder) == 0 || errno != EINTR) {
break;
}
sleep_duration = remainder;
} while (remainder.tv_sec || remainder.tv_nsec);
#endif
}
}).detach();
}
// Tell the underlying queue the producer thread has changed, so it does not
// assert in debug. This should be called with the thread stopped.
void reset_producer_thread() { msg_queue.reset_thread_ids(); }
private:
#ifndef _WIN32
const struct timespec sleep_for = {
CUBEB_LOG_BATCH_PRINT_INTERVAL_MS / 1000,
(CUBEB_LOG_BATCH_PRINT_INTERVAL_MS % 1000) * 1000 * 1000};
#endif
cubeb_async_logger() : msg_queue(CUBEB_LOG_MESSAGE_QUEUE_DEPTH) { run(); }
/** This is quite a big data structure, but is only instantiated if the
* asynchronous logger is used.*/
lock_free_queue<cubeb_log_message> msg_queue;
};
void
cubeb_async_log(char const * fmt, ...)
{
if (!g_cubeb_log_callback) {
return;
}
// This is going to copy a 256 bytes array around, which is fine.
// We don't want to allocate memory here, because this is made to
// be called from a real-time callback.
va_list args;
va_start(args, fmt);
char msg[CUBEB_LOG_MESSAGE_MAX_SIZE];
vsnprintf(msg, CUBEB_LOG_MESSAGE_MAX_SIZE, fmt, args);
cubeb_async_logger::get().push(msg);
va_end(args);
}
void
cubeb_async_log_reset_threads()
{
if (!g_cubeb_log_callback) {
return;
}
cubeb_async_logger::get().reset_producer_thread();
}
|
// Copyright (c) 2019 The Zel developers
// Copyright (c) 2019 The Zcash developers
// Original code from: https://gist.github.com/laanwj/0e689cfa37b52bcbbb44
/*
To set up a new alert system
----------------------------
Create a new alert key pair:
openssl ecparam -name secp256k1 -genkey -param_enc explicit -outform PEM -out data.pem
Get the private key in hex:
openssl ec -in data.pem -outform DER | tail -c 279 | xxd -p -c 279
Get the public key in hex:
openssl ec -in data.pem -pubout -outform DER | tail -c 65 | xxd -p -c 65
Update the public keys found in chainparams.cpp.
To send an alert message
------------------------
Copy the private keys into alertkeys.h.
Modify the alert parameters, id and message found in this file.
Build and run with -sendalert or -printalert.
./zelcashd -printtoconsole -sendalert
One minute after starting up, the alert will be broadcast. It is then
flooded through the network until the nRelayUntil time, and will be
active until nExpiration OR the alert is cancelled.
If you make a mistake, send another alert with nCancel set to cancel
the bad alert.
*/
#include "main.h"
#include "net.h"
#include "alert.h"
#include "init.h"
#include "util.h"
#include "utiltime.h"
#include "key.h"
#include "clientversion.h"
#include "chainparams.h"
#include "alertkeys.h"
static const int64_t DAYS = 24 * 60 * 60;
void ThreadSendAlert()
{
if (!mapArgs.count("-sendalert") && !mapArgs.count("-printalert"))
return;
MilliSleep(60*1000); // Wait a minute so we get connected
//
// Alerts are relayed around the network until nRelayUntil, flood
// filling to every node.
// After the relay time is past, new nodes are told about alerts
// when they connect to peers, until either nExpiration or
// the alert is cancelled by a newer alert.
// Nodes never save alerts to disk, they are in-memory-only.
//
CAlert alert;
alert.nRelayUntil = GetTime() + 15 * 60;
alert.nExpiration = GetTime() + 12 * 30 * 24 * 60 * 60;
alert.nID = 1006; // use https://github.com/zelcash/zelcash/wiki/specification#assigned-numbers to keep track of alert IDs
alert.nCancel = 1005; // cancels previous messages up to this ID number
// These versions are protocol versions
// 170002 : 1.0.0
// 170006 : 1.1.2
// 170007 : 2.0.0
// 170009 : 3.0.0
// 170010 : 3.1.0
// 170011 : 3.1.1
// 170012 : 3.2.0
// 170013 : 3.3.0
// 170016 : 4.0.0
// 170017 : 5.0.0
alert.nMinVer = 170002;
alert.nMaxVer = 170016;
//
// main.cpp:
// 1000 for Misc warnings like out of disk space and clock is wrong
// 2000 for longer invalid proof-of-work chain
// Higher numbers mean higher priority
// 4000 or higher will put the RPC into safe mode
alert.nPriority = 5000;
alert.strComment = "";
alert.strStatusBar = "Your client is outdated. Please update to the most recent version of ZelCash (5.0.0 or later).";
alert.strRPCError = alert.strStatusBar;
// Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done:
// alert.setSubVer.insert(std::string("/MagicBean:0.7.2/"));
const std::vector<std::string> useragents = {}; //"MagicBean", "BeanStalk", "AppleSeed", "EleosZelcash"};
BOOST_FOREACH(const std::string& useragent, useragents) {
}
// Sanity check
assert(alert.strComment.length() <= 65536); // max length in alert.h
assert(alert.strStatusBar.length() <= 256);
assert(alert.strRPCError.length() <= 256);
// Sign
const CChainParams& chainparams = Params();
std::string networkID = chainparams.NetworkIDString();
bool fIsTestNet = networkID.compare("test") == 0;
std::vector<unsigned char> vchTmp(ParseHex(fIsTestNet ? pszTestNetPrivKey : pszPrivKey));
CPrivKey vchPrivKey(vchTmp.begin(), vchTmp.end());
CDataStream sMsg(SER_NETWORK, CLIENT_VERSION);
sMsg << *(CUnsignedAlert*)&alert;
alert.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());
CKey key;
if (!key.SetPrivKey(vchPrivKey, false))
{
printf("ThreadSendAlert() : key.SetPrivKey failed\n");
return;
}
if (!key.Sign(Hash(alert.vchMsg.begin(), alert.vchMsg.end()), alert.vchSig))
{
printf("ThreadSendAlert() : key.Sign failed\n");
return;
}
// Test
CDataStream sBuffer(SER_NETWORK, CLIENT_VERSION);
sBuffer << alert;
CAlert alert2;
sBuffer >> alert2;
if (!alert2.CheckSignature(chainparams.AlertKey()))
{
printf("ThreadSendAlert() : CheckSignature failed\n");
return;
}
assert(alert2.vchMsg == alert.vchMsg);
assert(alert2.vchSig == alert.vchSig);
alert.SetNull();
printf("\nThreadSendAlert:\n");
printf("hash=%s\n", alert2.GetHash().ToString().c_str());
printf("%s\n", alert2.ToString().c_str());
printf("vchMsg=%s\n", HexStr(alert2.vchMsg).c_str());
printf("vchSig=%s\n", HexStr(alert2.vchSig).c_str());
// Confirm
if (!mapArgs.count("-sendalert"))
return;
while (vNodes.size() < 1 && !ShutdownRequested())
MilliSleep(500);
if (ShutdownRequested())
return;
// Send
printf("ThreadSendAlert() : Sending alert\n");
int nSent = 0;
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
if (alert2.RelayTo(pnode))
{
printf("ThreadSendAlert() : Sent alert to %s\n", pnode->addr.ToString().c_str());
nSent++;
}
}
}
printf("ThreadSendAlert() : Alert sent to %d nodes\n", nSent);
}
|
/**
* Copyright (c) 2007-2012, Timothy Stack
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Timothy Stack 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 REGENTS 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 REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include "yajlpp.hh"
#include "sql_util.hh"
#include "log_format.hh"
#include "log_vtab_impl.hh"
using namespace std;
/*
* Supported formats:
* generic
* syslog
* apache
* tcpdump
* strace
* vstrace
* csv (?)
* file system (?)
* plugins
* vmstat
* iostat
*/
string_attr_type logline::L_PREFIX;
string_attr_type logline::L_TIMESTAMP;
string_attr_type logline::L_FILE;
string_attr_type logline::L_PARTITION;
const char *logline::level_names[LEVEL__MAX + 1] = {
"unknown",
"trace",
"debug",
"info",
"warning",
"error",
"critical",
"fatal",
NULL
};
static int strncasestr_i(const char *s1, const char *s2, size_t len)
{
return strcasestr(s1, s2) == NULL;
}
logline::level_t logline::string2level(const char *levelstr, size_t len, bool exact)
{
logline::level_t retval = logline::LEVEL_UNKNOWN;
int (*cmpfunc)(const char *, const char *, size_t);
require(len == (size_t)-1 || (len != (size_t)-1 && exact));
if (len == (size_t)-1)
len = strlen(levelstr);
if (exact) {
cmpfunc = strncasecmp;
}
else{
cmpfunc = strncasestr_i;
}
if (((len == 1) || ((len > 1) && (levelstr[1] == ' '))) &&
(retval = abbrev2level(levelstr, len)) != LEVEL_UNKNOWN) {
return retval;
}
if (cmpfunc(levelstr, "TRACE", len) == 0) {
retval = logline::LEVEL_TRACE;
}
else if (cmpfunc(levelstr, "VERBOSE", len) == 0) {
retval = logline::LEVEL_DEBUG;
}
else if (cmpfunc(levelstr, "DEBUG", len) == 0) {
retval = logline::LEVEL_DEBUG;
}
else if (cmpfunc(levelstr, "INFO", len) == 0) {
retval = logline::LEVEL_INFO;
}
else if (cmpfunc(levelstr, "WARNING", len) == 0) {
retval = logline::LEVEL_WARNING;
}
else if (cmpfunc(levelstr, "ERROR", len) == 0) {
retval = logline::LEVEL_ERROR;
}
else if (cmpfunc(levelstr, "CRITICAL", len) == 0) {
retval = logline::LEVEL_CRITICAL;
}
else if (cmpfunc(levelstr, "FATAL", len) == 0) {
retval = logline::LEVEL_FATAL;
}
return retval;
}
logline::level_t logline::abbrev2level(const char *levelstr, size_t len)
{
if (len == -1) {
len = strlen(levelstr);
}
if (len == 0) {
return LEVEL_UNKNOWN;
}
switch (toupper(levelstr[0])) {
case 'T':
return LEVEL_TRACE;
case 'D':
return LEVEL_DEBUG;
case 'I':
return LEVEL_INFO;
case 'W':
return LEVEL_WARNING;
case 'E':
return LEVEL_ERROR;
case 'C':
return LEVEL_CRITICAL;
case 'F':
return LEVEL_FATAL;
}
return LEVEL_UNKNOWN;
}
int logline::levelcmp(const char *l1, size_t l1_len, const char *l2, size_t l2_len)
{
return abbrev2level(l1, l1_len) - abbrev2level(l2, l2_len);
}
const char *logline_value::value_names[VALUE__MAX] = {
"null",
"text",
"int",
"float",
"bool"
};
logline_value::kind_t logline_value::string2kind(const char *kindstr)
{
if (strcmp(kindstr, "string") == 0) {
return VALUE_TEXT;
}
else if (strcmp(kindstr, "integer") == 0) {
return VALUE_INTEGER;
}
else if (strcmp(kindstr, "float") == 0) {
return VALUE_FLOAT;
}
else if (strcmp(kindstr, "boolean") == 0) {
return VALUE_BOOLEAN;
}
return VALUE_UNKNOWN;
}
vector<log_format *> log_format::lf_root_formats;
vector<log_format *> &log_format::get_root_formats(void)
{
return lf_root_formats;
}
static bool next_format(const std::vector<external_log_format::pattern *> &patterns,
int &index,
int &locked_index)
{
bool retval = true;
if (locked_index == -1) {
index += 1;
if (index >= (int)patterns.size()) {
retval = false;
}
}
else if (index == locked_index) {
retval = false;
}
else {
index = locked_index;
}
return retval;
}
const char *log_format::log_scanf(const char *line,
const char *fmt[],
int expected_matches,
const char *time_fmt[],
char *time_dest,
struct tm *tm_out,
struct timeval &tv_out,
...)
{
int curr_fmt = -1;
const char * retval = NULL;
va_list args;
while (next_format(fmt, curr_fmt, this->lf_fmt_lock)) {
va_start(args, tv_out);
int matches;
time_dest[0] = '\0';
matches = vsscanf(line, fmt[curr_fmt], args);
if (matches < expected_matches) {
retval = NULL;
continue;
}
if (time_dest[0] == '\0') {
retval = NULL;
}
else {
retval = this->lf_date_time.scan(time_dest, time_fmt, tm_out, tv_out);
if (retval) {
this->lf_fmt_lock = curr_fmt;
break;
}
}
va_end(args);
}
return retval;
}
void log_format::check_for_new_year(std::vector<logline> &dst,
const struct timeval &log_tv)
{
if (dst.empty()) {
return;
}
time_t diff = dst.back().get_time() - log_tv.tv_sec;
if (diff > (5 * 60)) {
int off_year = 0, off_month = 0, off_day = 0, off_hour = 0;
std::vector<logline>::iterator iter;
if (diff > (60 * 24 * 60 * 60)) {
off_year = 1;
} else if (diff > (15 * 24 * 60 * 60)) {
off_month = 1;
} else if (diff > (12 * 60 * 60)) {
off_day = 1;
} else {
off_hour = 1;
}
for (iter = dst.begin(); iter != dst.end(); iter++) {
time_t ot = iter->get_time();
struct tm *otm;
otm = gmtime(&ot);
otm->tm_year -= off_year;
otm->tm_mon -= off_month;
otm->tm_yday -= off_day;
otm->tm_hour -= off_hour;
iter->set_time(tm2sec(otm));
}
}
}
/*
* XXX This needs some cleanup.
*/
struct json_log_userdata {
json_log_userdata() : jlu_sub_line_count(1) { };
external_log_format *jlu_format;
const logline *jlu_line;
logline *jlu_base_line;
int jlu_sub_line_count;
yajl_handle jlu_handle;
const char *jlu_line_value;
size_t jlu_sub_start;
};
struct json_field_cmp {
json_field_cmp(external_log_format::json_log_field type,
const std::string &name)
: jfc_type(type), jfc_field_name(name) {
};
bool operator()(const external_log_format::json_format_element &jfe) const {
return (this->jfc_type == jfe.jfe_type &&
this->jfc_field_name == jfe.jfe_value);
};
external_log_format::json_log_field jfc_type;
const std::string &jfc_field_name;
};
static int read_json_field(yajlpp_parse_context *ypc, const unsigned char *str, size_t len);
static int read_json_null(yajlpp_parse_context *ypc)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
vector<external_log_format::json_format_element> &line_format =
jlu->jlu_format->jlf_line_format;
string field_name = ypc->get_path_fragment(0);
if (find_if(line_format.begin(), line_format.end(),
json_field_cmp(external_log_format::JLF_VARIABLE,
field_name)) == line_format.end()) {
jlu->jlu_sub_line_count += 1;
}
return 1;
}
static int read_json_bool(yajlpp_parse_context *ypc, int val)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
vector<external_log_format::json_format_element> &line_format =
jlu->jlu_format->jlf_line_format;
string field_name = ypc->get_path_fragment(0);
if (find_if(line_format.begin(), line_format.end(),
json_field_cmp(external_log_format::JLF_VARIABLE,
field_name)) == line_format.end()) {
jlu->jlu_sub_line_count += 1;
}
return 1;
}
static int read_json_int(yajlpp_parse_context *ypc, long long val)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
vector<external_log_format::json_format_element> &line_format =
jlu->jlu_format->jlf_line_format;
string field_name = ypc->get_path_fragment(0);
if (field_name == jlu->jlu_format->lf_timestamp_field) {
long long divisor = jlu->jlu_format->elf_timestamp_divisor;
struct timeval tv;
tv.tv_sec = val / divisor;
tv.tv_usec = (val % divisor) * (1000000.0 / divisor);
jlu->jlu_base_line->set_time(tv);
}
else if (find_if(line_format.begin(), line_format.end(),
json_field_cmp(external_log_format::JLF_VARIABLE,
field_name)) == line_format.end()) {
jlu->jlu_sub_line_count += 1;
}
return 1;
}
static int read_json_double(yajlpp_parse_context *ypc, double val)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
vector<external_log_format::json_format_element> &line_format =
jlu->jlu_format->jlf_line_format;
string field_name = ypc->get_path_fragment(0);
if (field_name == jlu->jlu_format->lf_timestamp_field) {
double divisor = jlu->jlu_format->elf_timestamp_divisor;
struct timeval tv;
tv.tv_sec = val / divisor;
tv.tv_usec = fmod(val, divisor) * (1000000.0 / divisor);
jlu->jlu_base_line->set_time(tv);
}
else if (find_if(line_format.begin(), line_format.end(),
json_field_cmp(external_log_format::JLF_VARIABLE,
field_name)) == line_format.end()) {
jlu->jlu_sub_line_count += 1;
}
return 1;
}
static int json_array_start(void *ctx)
{
yajlpp_parse_context *ypc = (yajlpp_parse_context *)ctx;
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
vector<external_log_format::json_format_element> &line_format =
jlu->jlu_format->jlf_line_format;
if (ypc->ypc_path_index_stack.size() == 2) {
string field_name = ypc->get_path_fragment(0);
if (find_if(line_format.begin(), line_format.end(),
json_field_cmp(external_log_format::JLF_VARIABLE,
field_name)) == line_format.end()) {
jlu->jlu_sub_line_count += 1;
}
jlu->jlu_sub_start = yajl_get_bytes_consumed(jlu->jlu_handle) - 1;
}
return 1;
}
static int json_array_end(void *ctx)
{
yajlpp_parse_context *ypc = (yajlpp_parse_context *)ctx;
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
if (ypc->ypc_path_index_stack.size() == 1) {
string field_name = ypc->get_path_fragment(0);
size_t sub_end = yajl_get_bytes_consumed(jlu->jlu_handle);
tmp_shared_buffer tsb(&jlu->jlu_line_value[jlu->jlu_sub_start],
sub_end - jlu->jlu_sub_start);
jlu->jlu_format->jlf_line_values.push_back(
logline_value(field_name, tsb.tsb_ref));
}
return 1;
}
static struct json_path_handler json_log_handlers[] = {
json_path_handler("^/\\w+$").
add_cb(read_json_null).
add_cb(read_json_bool).
add_cb(read_json_int).
add_cb(read_json_double).
add_cb(read_json_field),
json_path_handler()
};
static int rewrite_json_field(yajlpp_parse_context *ypc, const unsigned char *str, size_t len);
static int rewrite_json_null(yajlpp_parse_context *ypc)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
string field_name = ypc->get_path_fragment(0);
jlu->jlu_format->jlf_line_values.push_back(logline_value(field_name));
return 1;
}
static int rewrite_json_bool(yajlpp_parse_context *ypc, int val)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
string field_name = ypc->get_path_fragment(0);
jlu->jlu_format->jlf_line_values.push_back(logline_value(field_name, (bool)val));
return 1;
}
static int rewrite_json_int(yajlpp_parse_context *ypc, long long val)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
string field_name = ypc->get_path_fragment(0);
jlu->jlu_format->jlf_line_values.push_back(logline_value(field_name, (int64_t)val));
return 1;
}
static int rewrite_json_double(yajlpp_parse_context *ypc, double val)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
string field_name = ypc->get_path_fragment(0);
jlu->jlu_format->jlf_line_values.push_back(logline_value(field_name, val));
return 1;
}
static struct json_path_handler json_log_rewrite_handlers[] = {
json_path_handler("^/\\w+$").
add_cb(rewrite_json_null).
add_cb(rewrite_json_bool).
add_cb(rewrite_json_int).
add_cb(rewrite_json_double).
add_cb(rewrite_json_field),
json_path_handler()
};
bool external_log_format::scan(std::vector<logline> &dst,
off_t offset,
char *prefix,
int len)
{
if (this->jlf_json) {
auto_mem<yajl_handle_t> handle(yajl_free);
yajlpp_parse_context &ypc = *(this->jlf_parse_context);
logline ll(offset, 0, 0, logline::LEVEL_INFO);
json_log_userdata jlu;
bool retval = false;
handle = yajl_alloc(&this->jlf_parse_context->ypc_callbacks,
NULL,
this->jlf_parse_context.get());
ypc.reset(json_log_handlers);
ypc.ypc_userdata = &jlu;
ypc.ypc_ignore_unused = true;
ypc.ypc_alt_callbacks.yajl_start_array = json_array_start;
ypc.ypc_alt_callbacks.yajl_start_map = json_array_start;
jlu.jlu_format = this;
jlu.jlu_base_line = ≪
jlu.jlu_line_value = prefix;
jlu.jlu_handle = handle;
if (yajl_parse(handle.in(),
(const unsigned char *)prefix, len) == yajl_status_ok &&
yajl_complete_parse(handle.in()) == yajl_status_ok) {
for (int lpc = 0; lpc < jlu.jlu_sub_line_count; lpc++) {
ll.set_sub_offset(lpc);
if (lpc > 0) {
ll.set_level((logline::level_t) (ll.get_level() |
logline::LEVEL_CONTINUED));
}
dst.push_back(ll);
}
retval = true;
}
return retval;
}
pcre_input pi(prefix, 0, len);
pcre_context_static<128> pc;
bool retval = false;
int curr_fmt = -1;
while (next_format(this->elf_pattern_order, curr_fmt, this->lf_fmt_lock)) {
pcrepp *pat = this->elf_pattern_order[curr_fmt]->p_pcre;
if (!pat->match(pc, pi)) {
continue;
}
if (this->lf_fmt_lock == -1) {
this->lf_timestamp_field_index = pat->name_index(
this->lf_timestamp_field);
this->elf_level_field_index = pat->name_index(
this->elf_level_field);
}
pcre_context::capture_t *ts = pc[this->lf_timestamp_field_index];
pcre_context::capture_t *level_cap = pc[this->elf_level_field_index];
const char *ts_str = pi.get_substr_start(ts);
const char *last;
struct tm log_time_tm;
struct timeval log_tv;
logline::level_t level = logline::LEVEL_INFO;
if ((last = this->lf_date_time.scan(ts_str,
NULL,
&log_time_tm,
log_tv)) == NULL) {
continue;
}
if (level_cap != NULL && level_cap->c_begin != -1) {
pcre_context_static<128> pc_level;
pcre_input pi_level(pi.get_substr_start(level_cap),
0,
level_cap->length());
for (std::map<logline::level_t, level_pattern>::iterator iter = this->elf_level_patterns.begin();
iter != this->elf_level_patterns.end();
++iter) {
if (iter->second.lp_pcre->match(pc_level, pi_level)) {
level = iter->first;
break;
}
}
}
this->check_for_new_year(dst, log_tv);
dst.push_back(logline(offset, log_tv, level));
this->lf_fmt_lock = curr_fmt;
retval = true;
break;
}
return retval;
}
void external_log_format::annotate(shared_buffer_ref &line,
string_attrs_t &sa,
std::vector<logline_value> &values) const
{
pcre_context_static<128> pc;
pcre_input pi(line.get_data(), 0, line.length());
struct line_range lr;
pcre_context::capture_t *cap;
if (this->jlf_json) {
values = this->jlf_line_values;
sa = this->jlf_line_attrs;
return;
}
pattern &pat = *this->elf_pattern_order[this->lf_fmt_lock];
if (!pat.p_pcre->match(pc, pi)) {
return;
}
cap = pc[this->lf_timestamp_field_index];
lr.lr_start = cap->c_begin;
lr.lr_end = cap->c_end;
sa.push_back(string_attr(lr, &logline::L_TIMESTAMP));
cap = pc[this->elf_body_field_index];
if (cap != NULL && cap->c_begin != -1) {
lr.lr_start = cap->c_begin;
lr.lr_end = cap->c_end;
}
else {
lr.lr_start = line.length();
lr.lr_end = line.length();
}
sa.push_back(string_attr(lr, &textview_curses::SA_BODY));
view_colors &vc = view_colors::singleton();
for (size_t lpc = 0; lpc < pat.p_value_by_index.size(); lpc++) {
const value_def &vd = pat.p_value_by_index[lpc];
const struct scaling_factor *scaling = NULL;
pcre_context::capture_t *cap = pc[vd.vd_index];
shared_buffer_ref field;
if (vd.vd_unit_field_index >= 0) {
pcre_context::iterator unit_cap = pc[vd.vd_unit_field_index];
if (unit_cap != NULL && unit_cap->c_begin != -1) {
std::string unit_val = pi.get_substr(unit_cap);
std::map<string, scaling_factor>::const_iterator unit_iter;
unit_iter = vd.vd_unit_scaling.find(unit_val);
if (unit_iter != vd.vd_unit_scaling.end()) {
const struct scaling_factor &sf = unit_iter->second;
scaling = &sf;
}
}
}
field.subset(line, cap->c_begin, cap->length());
values.push_back(logline_value(vd.vd_name,
vd.vd_kind,
field,
vd.vd_identifier,
scaling,
vd.vd_column,
cap->c_begin,
cap->c_end));
if (pc[vd.vd_index]->c_begin != -1 && vd.vd_identifier) {
lr.lr_start = pc[vd.vd_index]->c_begin;
lr.lr_end = pc[vd.vd_index]->c_end;
sa.push_back(string_attr(lr, &view_curses::VC_STYLE,
vc.attrs_for_ident(pi.get_substr_start(pc[vd.vd_index]), lr.length())));
}
}
}
static int read_json_field(yajlpp_parse_context *ypc, const unsigned char *str, size_t len)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
vector<external_log_format::json_format_element> &line_format =
jlu->jlu_format->jlf_line_format;
string field_name = ypc->get_path_fragment(0);
struct tm tm_out;
struct timeval tv_out;
if (field_name == jlu->jlu_format->lf_timestamp_field) {
jlu->jlu_format->lf_date_time.scan((const char *)str, NULL, &tm_out, tv_out);
jlu->jlu_base_line->set_time(tv_out);
}
else if (field_name == jlu->jlu_format->elf_level_field) {
jlu->jlu_base_line->set_level(logline::string2level((const char *)str, len, true));
}
else {
if (find_if(line_format.begin(), line_format.end(),
json_field_cmp(external_log_format::JLF_VARIABLE,
field_name)) == line_format.end()) {
jlu->jlu_sub_line_count += 1;
}
for (size_t lpc = 0; lpc < len; lpc++) {
if (str[lpc] == '\n') {
jlu->jlu_sub_line_count += 1;
}
}
}
return 1;
}
static int rewrite_json_field(yajlpp_parse_context *ypc, const unsigned char *str, size_t len)
{
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
string field_name = ypc->get_path_fragment(0);
if (field_name == jlu->jlu_format->lf_timestamp_field) {
char time_buf[64];
sql_strftime(time_buf, sizeof(time_buf),
jlu->jlu_line->get_timeval(), 'T');
tmp_shared_buffer tsb(time_buf);
jlu->jlu_format->jlf_line_values.push_back(logline_value(field_name, tsb.tsb_ref));
}
else {
tmp_shared_buffer tsb((const char *)str, len);
if (field_name == jlu->jlu_format->elf_body_field) {
jlu->jlu_format->jlf_line_values.push_back(logline_value("body", tsb.tsb_ref));
}
jlu->jlu_format->jlf_line_values.push_back(logline_value(field_name, tsb.tsb_ref));
}
return 1;
}
void external_log_format::get_subline(const logline &ll, shared_buffer_ref &sbr)
{
if (!this->jlf_json) {
return;
}
if (this->jlf_cached_offset != ll.get_offset()) {
auto_mem<yajl_handle_t> handle(yajl_free);
yajlpp_parse_context &ypc = *(this->jlf_parse_context);
view_colors &vc = view_colors::singleton();
json_log_userdata jlu;
this->jlf_share_manager.invalidate_refs();
this->jlf_cached_line.clear();
this->jlf_line_values.clear();
this->jlf_line_offsets.clear();
this->jlf_line_attrs.clear();
handle = yajl_alloc(&this->jlf_parse_context->ypc_callbacks,
NULL,
this->jlf_parse_context.get());
ypc.reset(json_log_rewrite_handlers);
ypc.ypc_userdata = &jlu;
ypc.ypc_ignore_unused = true;
ypc.ypc_alt_callbacks.yajl_start_array = json_array_start;
ypc.ypc_alt_callbacks.yajl_end_array = json_array_end;
ypc.ypc_alt_callbacks.yajl_start_map = json_array_start;
ypc.ypc_alt_callbacks.yajl_end_map = json_array_end;
jlu.jlu_format = this;
jlu.jlu_line = ≪
jlu.jlu_handle = handle;
jlu.jlu_line_value = sbr.get_data();
yajl_status parse_status = yajl_parse(handle.in(),
(const unsigned char *)sbr.get_data(), sbr.length());
if (parse_status == yajl_status_ok &&
yajl_complete_parse(handle.in()) == yajl_status_ok) {
std::vector<logline_value>::iterator lv_iter;
std::vector<json_format_element>::iterator iter;
bool used_values[this->jlf_line_values.size()];
struct line_range lr;
ostringstream lines;
memset(used_values, 0, sizeof(used_values));
for (lv_iter = this->jlf_line_values.begin();
lv_iter != this->jlf_line_values.end();
++lv_iter) {
map<string, external_log_format::value_def>::iterator vd_iter;
vd_iter = this->elf_value_defs.find(lv_iter->lv_name);
if (vd_iter != this->elf_value_defs.end()) {
lv_iter->lv_identifier = vd_iter->second.vd_identifier;
lv_iter->lv_column = vd_iter->second.vd_column;
}
}
for (iter = this->jlf_line_format.begin();
iter != this->jlf_line_format.end();
++iter) {
switch (iter->jfe_type) {
case JLF_CONSTANT:
lines << iter->jfe_default_value;
break;
case JLF_VARIABLE:
lv_iter = find_if(this->jlf_line_values.begin(),
this->jlf_line_values.end(),
logline_value_cmp(&iter->jfe_value));
if (lv_iter != this->jlf_line_values.end()) {
string str = lv_iter->to_string();
size_t nl_pos = str.find('\n');
lr.lr_start = lines.tellp();
lines << str;
if (nl_pos == string::npos)
lr.lr_end = lines.tellp();
else
lr.lr_end = lr.lr_start + nl_pos;
if (lv_iter->lv_name == this->lf_timestamp_field) {
this->jlf_line_attrs.push_back(
string_attr(lr, &logline::L_TIMESTAMP));
}
else if (lv_iter->lv_name == this->elf_body_field) {
this->jlf_line_attrs.push_back(
string_attr(lr, &textview_curses::SA_BODY));
}
else if (lv_iter->lv_identifier) {
this->jlf_line_attrs.push_back(
string_attr(lr, &view_curses::VC_STYLE,
vc.attrs_for_ident(str.c_str(), lr.length())));
}
lv_iter->lv_origin = lr;
used_values[distance(this->jlf_line_values.begin(),
lv_iter)] = true;
}
else if (iter->jfe_value == "__timestamp__") {
struct line_range lr;
char ts[64];
sql_strftime(ts, sizeof(ts), ll.get_timeval(), 'T');
lr.lr_start = lines.tellp();
lines << ts;
lr.lr_end = lines.tellp();
this->jlf_line_attrs.push_back(
string_attr(lr, &logline::L_TIMESTAMP));
}
else {
lines << iter->jfe_default_value;
}
break;
}
}
lines << endl;
for (size_t lpc = 0; lpc < this->jlf_line_values.size(); lpc++) {
logline_value &lv = this->jlf_line_values[lpc];
if (used_values[lpc] ||
lv.lv_name == this->lf_timestamp_field ||
lv.lv_name == "body" ||
lv.lv_name == this->elf_level_field) {
continue;
}
const std::string str = lv.to_string();
size_t curr_pos = 0, nl_pos, line_len = -1;
lv.lv_origin.lr_start = lines.tellp();
do {
nl_pos = str.find('\n', curr_pos);
if (nl_pos != std::string::npos) {
line_len = nl_pos - curr_pos;
}
lines << " "
<< lv.lv_name
<< ": "
<< str.substr(curr_pos, line_len)
<< endl;
curr_pos = nl_pos + 1;
line_len = -1;
} while (nl_pos != std::string::npos &&
nl_pos < str.size());
lv.lv_origin.lr_end = lines.tellp();
}
this->jlf_cached_line = lines.str();
this->jlf_line_offsets.push_back(0);
for (size_t lpc = 0; lpc < this->jlf_cached_line.size(); lpc++) {
if (this->jlf_cached_line[lpc] == '\n') {
this->jlf_line_offsets.push_back(lpc);
}
}
this->jlf_line_offsets.push_back(this->jlf_cached_line.size());
}
this->jlf_cached_offset = ll.get_offset();
}
off_t this_off, next_off;
this_off = this->jlf_line_offsets[ll.get_sub_offset()];
if (this->jlf_cached_line[this_off] == '\n')
this_off += 1;
next_off = this->jlf_line_offsets[ll.get_sub_offset() + 1];
sbr.share(this->jlf_share_manager,
(char *)this->jlf_cached_line.c_str() + this_off,
next_off - this_off);
}
void external_log_format::build(std::vector<std::string> &errors)
{
try {
this->elf_filename_pcre = new pcrepp(this->elf_file_pattern.c_str());
}
catch (const pcrepp::error &e) {
errors.push_back("error:" +
this->elf_name + ".file-pattern:" +
e.what());
}
for (std::map<string, pattern>::iterator iter = this->elf_patterns.begin();
iter != this->elf_patterns.end();
++iter) {
try {
iter->second.p_pcre = new pcrepp(iter->second.p_string.c_str());
}
catch (const pcrepp::error &e) {
errors.push_back("error:" +
this->elf_name + ".regex[]" +
":" +
e.what());
continue;
}
for (pcre_named_capture::iterator name_iter = iter->second.p_pcre->named_begin();
name_iter != iter->second.p_pcre->named_end();
++name_iter) {
std::map<std::string, value_def>::iterator value_iter;
value_iter = this->elf_value_defs.find(std::string(name_iter->pnc_name));
if (value_iter != this->elf_value_defs.end()) {
value_def &vd = value_iter->second;
vd.vd_index = name_iter->index();
vd.vd_unit_field_index = iter->second.p_pcre->name_index(vd.vd_unit_field.c_str());
if (vd.vd_column == -1) {
vd.vd_column = this->elf_column_count++;
}
iter->second.p_value_by_index.push_back(vd);
}
}
stable_sort(iter->second.p_value_by_index.begin(),
iter->second.p_value_by_index.end());
this->elf_pattern_order.push_back(&iter->second);
}
if (this->jlf_json) {
if (!this->elf_patterns.empty()) {
errors.push_back("error:" +
this->elf_name +
": JSON logs cannot have regexes");
}
if (this->jlf_json) {
this->jlf_parse_context.reset(new yajlpp_parse_context(this->elf_name));
}
}
else {
if (this->elf_patterns.empty()) {
errors.push_back("error:" +
this->elf_name +
": no regexes specified for format");
}
}
for (std::map<logline::level_t, level_pattern>::iterator iter = this->elf_level_patterns.begin();
iter != this->elf_level_patterns.end();
++iter) {
try {
iter->second.lp_pcre = new pcrepp(iter->second.lp_regex.c_str());
}
catch (const pcrepp::error &e) {
errors.push_back("error:" +
this->elf_name + ".level:" + e.what());
}
}
for (std::map<string, value_def>::iterator iter = this->elf_value_defs.begin();
iter != this->elf_value_defs.end();
++iter) {
std::vector<std::string>::iterator act_iter;
if (iter->second.vd_column == -1) {
iter->second.vd_column = this->elf_column_count++;
}
for (act_iter = iter->second.vd_action_list.begin();
act_iter != iter->second.vd_action_list.end();
++act_iter) {
if (this->lf_action_defs.find(*act_iter) ==
this->lf_action_defs.end()) {
errors.push_back("error:" +
this->elf_name + ":" + iter->first +
": cannot find action -- " + (*act_iter));
}
}
}
if (!this->jlf_json && this->elf_samples.empty()) {
errors.push_back("error:" +
this->elf_name +
":no sample logs provided, all formats must have samples");
}
for (std::vector<sample>::iterator iter = this->elf_samples.begin();
iter != this->elf_samples.end();
++iter) {
pcre_context_static<128> pc;
pcre_input pi(iter->s_line);
bool found = false;
for (std::vector<pattern *>::iterator pat_iter = this->elf_pattern_order.begin();
pat_iter != this->elf_pattern_order.end() && !found;
++pat_iter) {
pattern &pat = *(*pat_iter);
if (!pat.p_pcre)
continue;
if (pat.p_pcre->name_index(this->lf_timestamp_field) < 0) {
errors.push_back("error:" +
this->elf_name +
":timestamp field '" +
this->lf_timestamp_field +
"' not found in pattern -- " +
pat.p_string);
continue;
}
if (pat.p_pcre->match(pc, pi)) {
const char *ts = pi.get_substr_start(
pc[this->lf_timestamp_field]);
date_time_scanner dts;
struct timeval tv;
struct tm tm;
found = true;
if (dts.scan(ts, NULL, &tm, tv) == NULL) {
errors.push_back("error:" +
this->elf_name +
":invalid sample -- " +
iter->s_line);
errors.push_back("error:" +
this->elf_name +
":unrecognized timestamp format");
}
}
}
if (!found) {
errors.push_back("error:" +
this->elf_name +
":invalid sample -- " +
iter->s_line);
for (std::vector<pattern *>::iterator pat_iter = this->elf_pattern_order.begin();
pat_iter != this->elf_pattern_order.end();
++pat_iter) {
pattern &pat = *(*pat_iter);
if (!pat.p_pcre)
continue;
std::string line_partial = iter->s_line;
while (!line_partial.empty()) {
pcre_input pi_partial(line_partial);
if (pat.p_pcre->match(pc, pi_partial, PCRE_PARTIAL)) {
errors.push_back("error:" +
this->elf_name +
":partial sample matched -- " +
line_partial);
break;
}
line_partial = line_partial.substr(0, line_partial.size() - 1);
}
if (line_partial.empty()) {
errors.push_back("error:" +
this->elf_name +
":no partial match found");
}
}
}
}
}
class external_log_table : public log_vtab_impl {
public:
external_log_table(const external_log_format &elf) :
log_vtab_impl(elf.get_name()), elt_format(elf) {
};
void get_columns(vector<vtab_column> &cols) {
std::map<string, external_log_format::value_def>::const_iterator iter;
const external_log_format &elf = this->elt_format;
cols.resize(elf.elf_value_defs.size());
for (iter = elf.elf_value_defs.begin();
iter != elf.elf_value_defs.end();
++iter) {
const external_log_format::value_def &vd = iter->second;
int type;
switch (vd.vd_kind) {
case logline_value::VALUE_NULL:
case logline_value::VALUE_TEXT:
type = SQLITE3_TEXT;
break;
case logline_value::VALUE_FLOAT:
type = SQLITE_FLOAT;
break;
case logline_value::VALUE_BOOLEAN:
case logline_value::VALUE_INTEGER:
type = SQLITE_INTEGER;
break;
case logline_value::VALUE_UNKNOWN:
case logline_value::VALUE__MAX:
ensure(0);
break;
}
cols[vd.vd_column].vc_name = vd.vd_name.c_str();
cols[vd.vd_column].vc_type = type;
cols[vd.vd_column].vc_collator = vd.vd_collate.c_str();
}
};
void get_foreign_keys(std::vector<std::string> &keys_inout)
{
std::map<std::string, external_log_format::value_def>::const_iterator iter;
log_vtab_impl::get_foreign_keys(keys_inout);
for (iter = this->elt_format.elf_value_defs.begin();
iter != this->elt_format.elf_value_defs.end();
++iter) {
if (iter->second.vd_foreign_key) {
keys_inout.push_back(iter->first);
}
}
};
const external_log_format &elt_format;
};
log_vtab_impl *external_log_format::get_vtab_impl(void) const
{
return new external_log_table(*this);
}
/* XXX */
#include "log_format_impls.cc"
|
//-*****************************************************************************
//
// Copyright (c) 2009-2011,
// Sony Pictures Imageworks, Inc. and
// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Sony Pictures Imageworks, nor
// Industrial Light & Magic nor the names of their contributors may be used
// to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//-*****************************************************************************
#include "util.h"
#include "CameraHelper.h"
#include "NodeIteratorVisitorHelper.h"
#include <maya/MFnCamera.h>
#include <maya/MFnAttribute.h>
#include <maya/MFnNumericData.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MGlobal.h>
#include <maya/MTime.h>
#include <maya/MVector.h>
#include <maya/MDagModifier.h>
void read(double iFrame, Alembic::AbcGeom::ICamera & iCamera,
std::vector<double> & oArray)
{
oArray.resize(18);
// set some optional scale values
oArray[13] = 1.0;
oArray[16] = 1.0;
oArray[17] = 1.0;
Alembic::AbcGeom::ICameraSchema schema = iCamera.getSchema();
Alembic::AbcCoreAbstract::index_t index, ceilIndex;
double alpha = getWeightAndIndex(iFrame,
schema.getTimeSampling(), schema.getNumSamples(), index, ceilIndex);
if (alpha != 0.0)
{
Alembic::AbcGeom::CameraSample samp, ceilSamp;
schema.get(samp, index);
schema.get(ceilSamp, ceilIndex);
oArray[0] = simpleLerp<double>(alpha, samp.getFocalLength(),
ceilSamp.getFocalLength());
oArray[1] = simpleLerp<double>(alpha, samp.getLensSqueezeRatio(),
ceilSamp.getLensSqueezeRatio());
oArray[2] = simpleLerp<double>(alpha, samp.getHorizontalAperture(),
ceilSamp.getHorizontalAperture()) / 2.54;
oArray[3] = simpleLerp<double>(alpha, samp.getVerticalAperture(),
ceilSamp.getVerticalAperture()) / 2.54;
oArray[4] = simpleLerp<double>(alpha,
samp.getHorizontalFilmOffset(),
ceilSamp.getHorizontalFilmOffset()) / 2.54;
oArray[5] = simpleLerp<double>(alpha,
samp.getVerticalFilmOffset(),
ceilSamp.getVerticalFilmOffset()) / 2.54;
if (samp.getOverScanLeft() == samp.getOverScanRight() &&
samp.getOverScanTop() == samp.getOverScanBottom() &&
samp.getOverScanLeft() == samp.getOverScanTop() &&
ceilSamp.getOverScanLeft() == ceilSamp.getOverScanRight() &&
ceilSamp.getOverScanTop() == ceilSamp.getOverScanBottom() &&
ceilSamp.getOverScanLeft() == ceilSamp.getOverScanTop())
{
oArray[6] = simpleLerp<double>(alpha,
samp.getOverScanLeft() + 1.0,
ceilSamp.getOverScanLeft() + 1.0);
}
else
{
oArray[6] = 1.0;
}
oArray[7] = simpleLerp<double>(alpha, samp.getNearClippingPlane(),
ceilSamp.getNearClippingPlane());
oArray[8] = simpleLerp<double>(alpha, samp.getFarClippingPlane(),
ceilSamp.getFarClippingPlane());
oArray[9] = simpleLerp<double>(alpha, samp.getFStop(),
ceilSamp.getFStop());
oArray[10] = simpleLerp<double>(alpha, samp.getFocusDistance(),
ceilSamp.getFocusDistance());
double shutterClose = simpleLerp<double>(alpha, samp.getShutterClose(),
ceilSamp.getShutterClose());
double shutterOpen = simpleLerp<double>(alpha, samp.getShutterOpen(),
ceilSamp.getShutterOpen());
MTime sec(1.0, MTime::kSeconds);
oArray[11] =
360.0 * (shutterClose - shutterOpen) * sec.as(MTime::uiUnit());
std::size_t numOps = samp.getNumOps();
for (std::size_t i = 0; i < numOps; ++i)
{
Alembic::AbcGeom::FilmBackXformOp & op = samp[i];
Alembic::AbcGeom::FilmBackXformOp & ceilOp = ceilSamp[i];
if (op.getHint() == "filmFitOffs")
{
double val = op.getChannelValue(0) *
samp.getHorizontalAperture();
double ceilVal = ceilOp.getChannelValue(0) *
ceilSamp.getHorizontalAperture();
if (val != 0.0)
{
// chanValue(0) * 0.5 * horiz aper / 2.54
oArray[12] = simpleLerp<double>(alpha, val, ceilVal) / 5.08;
}
else
{
val = op.getChannelValue(1) * samp.getHorizontalAperture();
ceilVal = ceilOp.getChannelValue(1) *
ceilSamp.getHorizontalAperture();
// chanValue(1)* 0.5 * horiz aper / 2.54
oArray[12] = simpleLerp<double>(alpha, val, ceilVal) / 5.08;
}
}
else if (op.getHint() == "preScale")
{
oArray[13] = 1.0 / simpleLerp<double>(alpha,
op.getChannelValue(0), ceilOp.getChannelValue(0));
}
else if (op.getHint() == "filmTranslate")
{
oArray[14] = simpleLerp<double>(alpha,
op.getChannelValue(0), ceilOp.getChannelValue(0));
oArray[15] = simpleLerp<double>(alpha,
op.getChannelValue(1), ceilOp.getChannelValue(1));
}
else if (op.getHint() == "postScale")
{
oArray[16] = 1.0 / simpleLerp<double>(alpha,
op.getChannelValue(0), ceilOp.getChannelValue(0));
}
else if (op.getHint() == "cameraScale")
{
oArray[17] = simpleLerp<double>(alpha,
op.getChannelValue(0), ceilOp.getChannelValue(0));
}
}
}
else
{
Alembic::AbcGeom::CameraSample samp;
schema.get(samp, index);
oArray[0] = samp.getFocalLength();
oArray[1] = samp.getLensSqueezeRatio();
oArray[2] = samp.getHorizontalAperture()/2.54;
oArray[3] = samp.getVerticalAperture()/2.54;
oArray[4] = samp.getHorizontalFilmOffset()/2.54;
oArray[5] = samp.getVerticalFilmOffset()/2.54;
if (samp.getOverScanLeft() == samp.getOverScanRight() &&
samp.getOverScanTop() == samp.getOverScanBottom() &&
samp.getOverScanLeft() == samp.getOverScanTop())
{
oArray[6] = samp.getOverScanLeft() + 1.0;
}
else
{
oArray[6] = 1.0;
}
oArray[7] = samp.getNearClippingPlane();
oArray[8] = samp.getFarClippingPlane();
oArray[9] = samp.getFStop();
oArray[10] = samp.getFocusDistance();
MTime sec(1.0, MTime::kSeconds);
oArray[11] = 360.0 * (samp.getShutterClose()-samp.getShutterOpen()) *
sec.as(MTime::uiUnit());
// prescale, film translate H, V, roll pivot H,V, film roll value
// post scale might be in the 3x3
std::size_t numOps = samp.getNumOps();
for (std::size_t i = 0; i < numOps; ++i)
{
Alembic::AbcGeom::FilmBackXformOp & op = samp[i];
if (op.getHint() == "filmFitOffs")
{
if (op.getChannelValue(0) != 0.0)
{
oArray[12] = op.getChannelValue(0) *
samp.getHorizontalAperture() / 5.08;
}
else
{
oArray[12] = op.getChannelValue(1) *
samp.getHorizontalAperture() / 5.08;
}
}
else if (op.getHint() == "preScale")
{
oArray[13] = 1.0 / op.getChannelValue(0);
}
else if (op.getHint() == "filmTranslate")
{
oArray[14] = op.getChannelValue(0);
oArray[15] = op.getChannelValue(1);
}
else if (op.getHint() == "postScale")
{
oArray[16] = 1.0 / op.getChannelValue(0);
}
else if (op.getHint() == "cameraScale")
{
oArray[17] = op.getChannelValue(0);
}
}
}
}
MObject create(Alembic::AbcGeom::ICamera & iNode, MObject & iParent)
{
Alembic::AbcGeom::ICameraSchema schema = iNode.getSchema();
MString name(iNode.getName().c_str());
MFnCamera fnCamera;
MObject obj = fnCamera.create(iParent);
fnCamera.setName(name);
// we need to read this to determine the film fit
Alembic::AbcGeom::CameraSample samp;
iNode.getSchema().get(samp);
std::size_t numOps = samp.getNumOps();
if (numOps > 0)
{
std::string hint = samp[0].getHint();
if (hint == "filmFitFill")
{
fnCamera.setFilmFit(MFnCamera::kFillFilmFit);
}
else if (hint == "filmFitHorz")
{
fnCamera.setFilmFit(MFnCamera::kHorizontalFilmFit);
}
else if (hint == "filmFitVert")
{
fnCamera.setFilmFit(MFnCamera::kVerticalFilmFit);
}
else if (hint == "filmFitOver")
{
fnCamera.setFilmFit(MFnCamera::kOverscanFilmFit);
}
}
if (schema.isConstant())
{
// no center of interest
fnCamera.setFocalLength(samp.getFocalLength());
fnCamera.setLensSqueezeRatio(samp.getLensSqueezeRatio());
// camera scale might be in the 3x3
// weirdo attrs that are in inches
fnCamera.setHorizontalFilmAperture(samp.getHorizontalAperture()/2.54);
fnCamera.setVerticalFilmAperture(samp.getVerticalAperture()/2.54);
fnCamera.setHorizontalFilmOffset(samp.getHorizontalFilmOffset()/2.54);
fnCamera.setVerticalFilmOffset(samp.getVerticalFilmOffset()/2.54);
// film fit offset might be in the 3x3
if (samp.getOverScanLeft() == samp.getOverScanRight() &&
samp.getOverScanTop() == samp.getOverScanBottom() &&
samp.getOverScanLeft() == samp.getOverScanTop())
{
fnCamera.setOverscan(samp.getOverScanLeft() + 1.0);
}
else
{
MString warn = iNode.getName().c_str();
warn += " has unsupported overscan values.";
MGlobal::displayWarning(warn);
}
fnCamera.setNearClippingPlane(samp.getNearClippingPlane());
fnCamera.setFarClippingPlane(samp.getFarClippingPlane());
// prescale, film translate H, V, roll pivot H,V, film roll value
// post scale might be in the 3x3
fnCamera.setFStop(samp.getFStop());
fnCamera.setFocusDistance(samp.getFocusDistance());
MTime sec(1.0, MTime::kSeconds);
fnCamera.setShutterAngle(Alembic::AbcGeom::DegreesToRadians(
360.0 * (samp.getShutterClose()-samp.getShutterOpen()) *
sec.as(MTime::uiUnit()) ));
for (std::size_t i = 0; i < numOps; ++i)
{
Alembic::AbcGeom::FilmBackXformOp & op = samp[i];
if (op.getHint() == "filmFitOffs")
{
double val = op.getChannelValue(0) *
samp.getHorizontalAperture() / 5.08;
if (val != 0.0)
{
fnCamera.setFilmFitOffset(val);
}
else
{
fnCamera.setFilmFitOffset(op.getChannelValue(1) *
samp.getHorizontalAperture() / 5.08);
}
}
else if (op.getHint() == "preScale")
{
fnCamera.setPreScale(1.0/op.getChannelValue(0));
}
else if (op.getHint() == "filmTranslate")
{
fnCamera.setFilmTranslateH(op.getChannelValue(0));
fnCamera.setFilmTranslateV(op.getChannelValue(1));
}
else if (op.getHint() == "postScale")
{
fnCamera.setPostScale(1.0/op.getChannelValue(0));
}
else if (op.getHint() == "cameraScale")
{
fnCamera.setCameraScale(op.getChannelValue(0));
}
}
}
// extra transform node is unfortuneatly automatically created above the
// camera, let's do some reparenting and delete that extra transform
MDagPath path;
fnCamera.getPath(path);
MObject camObj = path.node();
MDagModifier dagMod;
dagMod.reparentNode(camObj, iParent);
dagMod.doIt();
dagMod.deleteNode(obj);
dagMod.doIt();
return camObj;
}
|
// Advent of Code 2019
// Peter Westerström (digimatic)
#include "config.h"
#include <common/common.h>
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <regex>
#include <stdexcept>
#include <string>
#include <tuple>
#include <unordered_set>
#include <utility>
using namespace westerstrom;
using namespace std;
using namespace std::string_literals;
auto parseLine(const string& line)
{
vector<pair<char, int>> p;
auto remaining = line;
while(remaining.length() > 0)
{
char c = remaining[0];
remaining = remaining.substr(1);
size_t taken = 0;
auto n = std::stoi(remaining, &taken);
p.emplace_back(c, n);
if(taken >= remaining.length())
break;
remaining = remaining.substr(taken + 1);
}
return p;
}
auto parseLines(const vector<string>& lines)
{
vector<vector<pair<char, int>>> parsedLines;
for(auto& line : lines)
{
parsedLines.push_back(parseLine(line));
}
return parsedLines;
}
pair<int, int> step(char dir)
{
int dx{0}, dy{0};
switch(dir)
{
case 'U':
dy = -1;
break;
case 'D':
dy = 1;
break;
case 'L':
dx = -1;
break;
case 'R':
dx = 1;
break;
}
return {dx, dy};
}
void solve_part1()
{
map<pair<int, int>, char> grid;
int minDist = std::numeric_limits<int>::max();
grid[make_pair(0, 0)] = 'o';
auto parsedInput = parseLines(readLines(string(inputFile)));
int x = 0;
int y = 0;
for(auto [dir, n] : parsedInput[0])
{
for(int i = 0; i < n; i++)
{
auto [dx, dy] = step(dir);
x += dx;
y += dy;
auto& c = grid[make_pair(x, y)];
c = 'a';
}
}
x = y = 0;
for(auto [dir, n] : parsedInput[1])
{
for(int i = 0; i < n; i++)
{
auto [dx, dy] = step(dir);
x += dx;
y += dy;
auto& c = grid[make_pair(x, y)];
if(c == 'a')
{
minDist = min(abs(x) + abs(y), minDist);
} else
{
c = 'b';
}
}
}
cout << dayName << " - part 1: " << minDist << endl;
}
void solve_part2()
{
map<pair<int, int>, int> grid;
int minSteps = std::numeric_limits<int>::max();
grid[make_pair(0, 0)] = 0;
auto parsedInput = parseLines(readLines(string(inputFile)));
int x = 0;
int y = 0;
int steps{};
for(auto [dir, n] : parsedInput[0])
{
for(int i = 0; i < n; i++)
{
auto [dx, dy] = step(dir);
x += dx;
y += dy;
steps++;
auto& c = grid[make_pair(x, y)];
c = steps;
}
}
x = y = 0;
steps = 0;
for(auto [dir, n] : parsedInput[1])
{
for(int i = 0; i < n; i++)
{
auto [dx, dy] = step(dir);
x += dx;
y += dy;
steps++;
if(grid.contains(make_pair(x, y)))
{
minSteps = min(minSteps, grid.at(make_pair(x, y)) + steps);
}
}
}
cout << dayName << " - part 2: " << minSteps << endl;
}
int main()
{
solve_part1();
solve_part2();
return 0;
}
|
#include "gear_core_common.h"
#include "Mesh.h"
#include "Material.h"
using namespace gear;
using namespace objects;
using namespace miru;
using namespace miru::crossplatform;
Mesh::Mesh(CreateInfo* pCreateInfo)
{
m_CI = *pCreateInfo;
ModelLoader::SetDevice(m_CI.device);
data = ModelLoader::LoadModelData(m_CI.filepath);
graphics::Vertexbuffer::CreateInfo vbCI;
vbCI.debugName = "GEAR_CORE_Mesh: " + m_CI.debugName;
vbCI.device = m_CI.device;
vbCI.stride = ModelLoader::GetSizeOfVertex();
graphics::Indexbuffer::CreateInfo ibCI;
ibCI.debugName = "GEAR_CORE_Mesh: " + m_CI.debugName;
ibCI.device = m_CI.device;
ibCI.stride = ModelLoader::GetSizeOfIndex();
for (auto& mesh : data.meshes)
{
vbCI.data = mesh.vertices.data();
vbCI.size = mesh.vertices.size() * ModelLoader::GetSizeOfVertex();
m_VBs.emplace_back(CreateRef<graphics::Vertexbuffer>(&vbCI));
ibCI.data = mesh.indices.data();
ibCI.size = mesh.indices.size() * ModelLoader::GetSizeOfIndex();
m_IBs.emplace_back(CreateRef<graphics::Indexbuffer>(&ibCI));
m_Materials.push_back(mesh.pMaterial);
}
}
Mesh::~Mesh()
{
m_VBs.clear();
m_IBs.clear();
m_Materials.clear();
}
void Mesh::Update()
{
if (CreateInfoHasChanged(&m_CI))
{
uint64_t newHash = m_CreateInfoHash;
*this = Mesh(&m_CI);
m_CreateInfoHash = newHash; //Set the Hash value from the previous instance of the Mesh.
}
for (auto& material : m_Materials)
material->Update();
}
bool Mesh::CreateInfoHasChanged(const ObjectComponentInterface::CreateInfo* pCreateInfo)
{
const CreateInfo& CI = *reinterpret_cast<const CreateInfo*>(pCreateInfo);
uint64_t newHash = 0;
newHash ^= core::GetHash(CI.filepath);
return CompareCreateInfoHash(newHash);
}
|
#include "DlgSongs.h"
#include <assert.h>
#include <QFileDialog>
#include <QDebug>
#include <QProcessEnvironment>
#include <QMessageBox>
#include <QComboBox>
#include <QMenu>
#include <QFile>
#include <QInputDialog>
#include "ui_DlgSongs.h"
#include "Database.h"
#include "MetadataScanner.h"
#include "AVPP.h"
#include "Stopwatch.h"
#include "LengthHashCalculator.h"
#include "Settings.h"
#include "DlgSongProperties.h"
#include "DlgTempoDetect.h"
#include "DlgTapTempo.h"
/** The number of ticks (periodic UI updates) to wait between the user changing the search text
and applying it to the filter. This is to avoid slowdowns while typing the search text. */
static const int TICKS_UNTIL_SET_SEARCH_TEXT = 3;
////////////////////////////////////////////////////////////////////////////////
// DlgSongs:
DlgSongs::DlgSongs(
Database & a_DB,
MetadataScanner & a_Scanner,
LengthHashCalculator & a_Hasher,
std::unique_ptr<QSortFilterProxyModel> && a_FilterModel,
bool a_ShowManipulators,
QWidget * a_Parent
):
Super(a_Parent),
m_DB(a_DB),
m_MetadataScanner(a_Scanner),
m_LengthHashCalculator(a_Hasher),
m_UI(new Ui::DlgSongs),
m_FilterModel(std::move(a_FilterModel)),
m_SongModel(a_DB),
m_SongModelFilter(m_SongModel),
m_IsLibraryRescanShown(true),
m_LastLibraryRescanTotal(0),
m_LastLibraryRescanQueue(-1),
m_TicksUntilSetSearchText(0)
{
m_UI->setupUi(this);
Settings::loadWindowPos("DlgSongs", *this);
if (m_FilterModel == nullptr)
{
m_FilterModel.reset(new QSortFilterProxyModel);
}
if (!a_ShowManipulators)
{
m_UI->btnAddFolder->hide();
m_UI->btnRemove->hide();
m_UI->btnAddToPlaylist->hide();
}
m_FilterModel->setSourceModel(&m_SongModelFilter);
m_UI->tblSongs->setModel(m_FilterModel.get());
m_UI->tblSongs->setItemDelegate(new SongModelEditorDelegate(this));
// Add the context-menu actions to their respective controls, so that their shortcuts work:
m_UI->tblSongs->addActions({
m_UI->actAddToPlaylist,
m_UI->actInsertIntoPlaylist,
m_UI->actDeleteFromDisk,
m_UI->actProperties,
m_UI->actRate,
m_UI->actRemoveFromLibrary,
m_UI->actTempoDetector,
m_UI->actTapTempo,
});
// Connect the signals:
connect(m_UI->btnAddFile, &QPushButton::clicked, this, &DlgSongs::chooseAddFile);
connect(m_UI->btnAddFolder, &QPushButton::clicked, this, &DlgSongs::chooseAddFolder);
connect(m_UI->btnRemove, &QPushButton::clicked, this, &DlgSongs::removeSelected);
connect(m_UI->btnClose, &QPushButton::clicked, this, &DlgSongs::close);
connect(m_UI->btnAddToPlaylist, &QPushButton::clicked, this, &DlgSongs::addSelectedToPlaylist);
connect(m_UI->btnRescanMetadata, &QPushButton::clicked, this, &DlgSongs::rescanMetadata);
connect(&m_SongModel, &SongModel::songEdited, this, &DlgSongs::modelSongEdited);
connect(&m_SongModel, &SongModel::rowsInserted, this, &DlgSongs::updateSongStats);
connect(&m_DB, &Database::songFileAdded, this, &DlgSongs::updateSongStats);
connect(&m_DB, &Database::songRemoved, this, &DlgSongs::updateSongStats);
connect(&m_PeriodicUiUpdate, &QTimer::timeout, this, &DlgSongs::periodicUiUpdate);
connect(m_UI->tblSongs, &QTableView::customContextMenuRequested, this, &DlgSongs::showSongsContextMenu);
connect(m_UI->actAddToPlaylist, &QAction::triggered, this, &DlgSongs::addSelectedToPlaylist);
connect(m_UI->actInsertIntoPlaylist, &QAction::triggered, this, &DlgSongs::insertSelectedToPlaylist);
connect(m_UI->actDeleteFromDisk, &QAction::triggered, this, &DlgSongs::deleteFromDisk);
connect(m_UI->actProperties, &QAction::triggered, this, &DlgSongs::showProperties);
connect(m_UI->actRate, &QAction::triggered, this, &DlgSongs::rateSelected);
connect(m_UI->actRemoveFromLibrary, &QAction::triggered, this, &DlgSongs::removeSelected);
connect(m_UI->actTempoDetector, &QAction::triggered, this, &DlgSongs::showTempoDetector);
connect(m_UI->actTapTempo, &QAction::triggered, this, &DlgSongs::showTapTempo);
initFilterSearch();
createContextMenu();
Settings::loadHeaderView("DlgSongs", "tblSongs", *m_UI->tblSongs->horizontalHeader());
// Make the dialog have Maximize button on Windows:
setWindowFlags(Qt::Window);
updateSongStats();
m_PeriodicUiUpdate.start(100);
}
DlgSongs::~DlgSongs()
{
Settings::saveHeaderView("DlgSongs", "tblSongs", *m_UI->tblSongs->horizontalHeader());
Settings::saveWindowPos("DlgSongs", *this);
}
void DlgSongs::addFiles(const QStringList & a_FileNames)
{
// Duplicates are skippen inside m_DB, no need to handle them here
QStringList songs;
for (const auto & fnam: a_FileNames)
{
QFileInfo fi(fnam);
if (!fi.exists())
{
continue;
}
songs.append(fnam);
}
if (songs.empty())
{
return;
}
qDebug() << ": Adding " << songs.size() << " song files";
m_DB.addSongFiles(songs);
}
void DlgSongs::addFolderRecursive(const QString & a_Path)
{
QDir dir(a_Path + "/");
QStringList songs;
for (const auto & item: dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot))
{
if (item.isDir())
{
addFolderRecursive(item.absoluteFilePath());
continue;
}
if (!item.isFile())
{
continue;
}
songs.append(item.absoluteFilePath());
}
if (songs.empty())
{
return;
}
qDebug() << ": Adding " << songs.size() << " songs from folder " << a_Path;
m_DB.addSongFiles(songs);
}
void DlgSongs::updateSongStats()
{
auto numFiltered = static_cast<size_t>(m_FilterModel->rowCount());
auto numTotal = m_DB.songs().size();
if (numFiltered == numTotal)
{
m_UI->lblStats->setText(tr("Total songs: %1").arg(numTotal));
}
else
{
m_UI->lblStats->setText(tr("Total songs: %1 (filtered out of %2)").arg(numFiltered).arg(numTotal));
}
}
void DlgSongs::initFilterSearch()
{
m_UI->cbFilter->addItem(tr("All songs"), SongModelFilter::fltNone);
m_UI->cbFilter->addItem(tr("Songs without ID3 tag"), SongModelFilter::fltNoId3);
m_UI->cbFilter->addItem(tr("Songs with no genre"), SongModelFilter::fltNoGenre);
m_UI->cbFilter->addItem(tr("Songs with no tempo"), SongModelFilter::fltNoMeasuresPerMinute);
m_UI->cbFilter->addItem(tr("Songs with warnings"), SongModelFilter::fltWarnings);
m_UI->cbFilter->addItem(tr("Songs not matching any template item"), SongModelFilter::fltNoTemplateFilterMatch);
m_UI->cbFilter->addItem(tr("Songs with duplicates"), SongModelFilter::fltDuplicates);
m_UI->cbFilter->addItem(tr("Songs with skip-start"), SongModelFilter::fltSkipStart);
// Bind signals / slots:
// Cannot bind overloaded signal via fn ptr in older Qt, need to use SIGNAL() / SLOT()
connect(m_UI->cbFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterChosen(int)));
connect(m_UI->leSearch, &QLineEdit::textEdited, this, &DlgSongs::searchTextEdited);
m_SongModelFilter.setFavoriteTemplateItems(m_DB.getFavoriteTemplateItems());
}
void DlgSongs::createContextMenu()
{
// Create the context menu:
m_ContextMenu.reset(new QMenu());
m_ContextMenu->addAction(m_UI->actAddToPlaylist);
m_ContextMenu->addAction(m_UI->actInsertIntoPlaylist);
m_ContextMenu->addSeparator();
m_ContextMenu->addAction(m_UI->actRemoveFromLibrary);
m_ContextMenu->addAction(m_UI->actDeleteFromDisk);
m_ContextMenu->addSeparator();
m_ContextMenu->addAction(m_UI->actRate);
connect(m_ContextMenu->addAction(QString(" * * * * *")), &QAction::triggered, [this](){ rateSelectedSongs(5); });
connect(m_ContextMenu->addAction(QString(" * * * *")), &QAction::triggered, [this](){ rateSelectedSongs(4); });
connect(m_ContextMenu->addAction(QString(" * * *")), &QAction::triggered, [this](){ rateSelectedSongs(3); });
connect(m_ContextMenu->addAction(QString(" * *")), &QAction::triggered, [this](){ rateSelectedSongs(2); });
connect(m_ContextMenu->addAction(QString(" *")), &QAction::triggered, [this](){ rateSelectedSongs(1); });
m_ContextMenu->addSeparator();
m_ContextMenu->addAction(m_UI->actTapTempo);
m_ContextMenu->addAction(m_UI->actTempoDetector);
m_ContextMenu->addSeparator();
m_ContextMenu->addAction(m_UI->actProperties);
}
SongPtr DlgSongs::songFromIndex(const QModelIndex & a_Index)
{
return m_SongModel.songFromIndex(
m_SongModelFilter.mapToSource(
m_FilterModel->mapToSource(a_Index)
)
);
}
void DlgSongs::rateSelectedSongs(double a_Rating)
{
foreach(const auto & idx, m_UI->tblSongs->selectionModel()->selectedRows())
{
auto song = songFromIndex(idx);
if (song == nullptr)
{
qWarning() << "Got a nullptr song from index " << idx;
continue;
}
song->setLocalRating(a_Rating);
emit m_SongModel.songEdited(song);
m_DB.saveSong(song);
}
}
void DlgSongs::chooseAddFile()
{
auto files = QFileDialog::getOpenFileNames(
this,
tr("SkauTan: Choose files to add"),
QProcessEnvironment::systemEnvironment().value("SKAUTAN_MUSIC_PATH", "")
);
if (files.isEmpty())
{
return;
}
addFiles(files);
}
void DlgSongs::chooseAddFolder()
{
auto dir = QFileDialog::getExistingDirectory(
this,
tr("SkauTan: Choose folder to add"),
QProcessEnvironment::systemEnvironment().value("SKAUTAN_MUSIC_PATH", "")
);
if (dir.isEmpty())
{
return;
}
addFolderRecursive(dir);
}
void DlgSongs::removeSelected()
{
// Collect the songs to remove:
std::vector<SongPtr> songs;
foreach(const auto & idx, m_UI->tblSongs->selectionModel()->selectedRows())
{
songs.push_back(songFromIndex(idx));
}
if (songs.empty())
{
return;
}
// Ask for confirmation:
if (QMessageBox::question(
this,
tr("SkauTan: Remove songs?"),
tr(
"Are you sure you want to remove the selected songs from the library? The song files will stay "
"on the disk, but all properties set in the library will be lost.\n\n"
"This operation cannot be undone!"
),
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape
) == QMessageBox::No)
{
return;
}
// Remove from the DB:
for (const auto & song: songs)
{
m_DB.removeSong(*song, false);
}
}
void DlgSongs::deleteFromDisk()
{
// Collect the songs to remove:
std::vector<SongPtr> songs;
foreach(const auto & idx, m_UI->tblSongs->selectionModel()->selectedRows())
{
songs.push_back(songFromIndex(idx));
}
if (songs.empty())
{
return;
}
// Ask for confirmation:
if (QMessageBox::question(
this,
tr("SkauTan: Delete songs?"),
tr(
"Are you sure you want to delete the selected songs from the disk?"
"The files will be deleted and all properties set in the library will be lost.\n\n"
"This operation cannot be undone!"
),
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape
) == QMessageBox::No)
{
return;
}
// Remove from the DB and delete files from disk:
for (const auto & song: songs)
{
m_DB.removeSong(*song, true);
}
}
void DlgSongs::addSelectedToPlaylist()
{
foreach(const auto & idx, m_UI->tblSongs->selectionModel()->selectedRows())
{
auto song = songFromIndex(idx);
emit addSongToPlaylist(song);
}
}
void DlgSongs::insertSelectedToPlaylist()
{
std::vector<SongPtr> songs;
foreach(const auto & idx, m_UI->tblSongs->selectionModel()->selectedRows())
{
songs.push_back(songFromIndex(idx));
}
for (auto itr = songs.crbegin(), end = songs.crend(); itr != end; ++itr)
{
emit insertSongToPlaylist(*itr);
}
}
void DlgSongs::rescanMetadata()
{
foreach(const auto & idx, m_UI->tblSongs->selectionModel()->selectedRows())
{
auto song = songFromIndex(idx);
m_MetadataScanner.queueScanSong(song);
}
}
void DlgSongs::modelSongEdited(SongPtr a_Song)
{
m_DB.saveSong(a_Song);
}
void DlgSongs::periodicUiUpdate()
{
// Update the LibraryRescan UI:
// Hash calc is calculated twice for the queue length, because after calculating the hash,
// songs will go to metadata updater anyway.
auto queueLength = m_LengthHashCalculator.queueLength() * 2 + m_MetadataScanner.queueLength();
if (m_LastLibraryRescanQueue != queueLength)
{
m_LastLibraryRescanQueue = queueLength;
if (queueLength == 0)
{
if (m_IsLibraryRescanShown)
{
m_UI->wLibraryRescan->hide();
m_IsLibraryRescanShown = false;
}
}
else
{
auto numSongs = static_cast<int>(m_DB.songs().size() * 2);
if (numSongs != m_LastLibraryRescanTotal)
{
m_UI->pbLibraryRescan->setMaximum(numSongs);
m_LastLibraryRescanTotal = numSongs;
}
m_UI->pbLibraryRescan->setValue(std::max(numSongs - queueLength, 0));
m_UI->pbLibraryRescan->update(); // For some reason setting the value is not enough to redraw
if (!m_IsLibraryRescanShown)
{
m_UI->wLibraryRescan->show();
m_IsLibraryRescanShown = true;
}
}
}
if (m_TicksUntilSetSearchText > 0)
{
m_TicksUntilSetSearchText -= 1;
if (m_TicksUntilSetSearchText == 0)
{
m_SongModelFilter.setSearchString(m_NewSearchText);
updateSongStats();
}
}
}
void DlgSongs::filterChosen(int a_Index)
{
auto filter = static_cast<SongModelFilter::EFilter>(m_UI->cbFilter->itemData(a_Index).toInt());
m_SongModelFilter.setFilter(filter);
updateSongStats();
}
void DlgSongs::searchTextEdited(const QString & a_NewText)
{
m_NewSearchText = a_NewText;
m_TicksUntilSetSearchText = TICKS_UNTIL_SET_SEARCH_TEXT;
}
void DlgSongs::showSongsContextMenu(const QPoint & a_Pos)
{
// Update the actions based on the selection:
const auto & sel = m_UI->tblSongs->selectionModel()->selectedRows();
m_UI->actAddToPlaylist->setEnabled(!sel.isEmpty());
m_UI->actInsertIntoPlaylist->setEnabled(!sel.isEmpty());
m_UI->actDeleteFromDisk->setEnabled(!sel.isEmpty());
m_UI->actProperties->setEnabled(sel.count() == 1);
m_UI->actRemoveFromLibrary->setEnabled(!sel.isEmpty());
m_UI->actRate->setEnabled(!sel.isEmpty());
m_UI->actTempoDetector->setEnabled(sel.count() == 1);
// Show the context menu:
auto widget = dynamic_cast<QWidget *>(sender());
auto pos = (widget == nullptr) ? a_Pos : widget->mapToGlobal(a_Pos);
m_ContextMenu->exec(pos, nullptr);
}
void DlgSongs::showProperties()
{
const auto & sel = m_UI->tblSongs->selectionModel()->selectedRows();
if (sel.isEmpty())
{
return;
}
auto song = songFromIndex(sel[0]);
DlgSongProperties dlg(m_DB, song, this);
dlg.exec();
}
void DlgSongs::rateSelected()
{
bool isOK;
auto rating = QInputDialog::getDouble(
this,
tr("SkauTan: Rate songs"),
tr("Rating:"),
5, 0, 5,
1, &isOK
);
if (!isOK)
{
return;
}
// Apply the rating:
const auto & sel = m_UI->tblSongs->selectionModel()->selectedRows();
for (const auto & idx: sel)
{
auto song = songFromIndex(idx);
if (song == nullptr)
{
qWarning() << "Received a nullptr song from index " << idx;
continue;
}
song->setLocalRating(rating);
emit m_SongModel.songEdited(song);
m_DB.saveSong(song);
}
}
void DlgSongs::showTempoDetector()
{
const auto & sel = m_UI->tblSongs->selectionModel()->selectedRows();
if (sel.isEmpty())
{
return;
}
auto song = songFromIndex(sel[0]);
assert(song != nullptr);
DlgTempoDetect dlg(m_DB, song, this);
dlg.exec();
}
void DlgSongs::showTapTempo()
{
const auto & sel = m_UI->tblSongs->selectionModel()->selectedRows();
if (sel.isEmpty())
{
return;
}
auto song = songFromIndex(sel[0]);
assert(song != nullptr);
DlgTapTempo dlg(m_DB, song, this);
dlg.exec();
}
|
#pragma once
#include <Eigen/Dense>
#include "pnc/whole_body_controllers/task.hpp"
/// class JointTask
class JointTask : public Task {
public:
/// \{ \name Constructor and Destructor
JointTask(RobotSystem *_robot);
virtual ~JointTask(){};
/// \}
private:
void update_cmd();
void update_jacobian();
};
/// class SelectedJointTask
class SelectedJointTask : public Task {
public:
/// \{ \name Constructor and Destructor
SelectedJointTask(RobotSystem *_robot, std::vector<std::string> _target_ids);
virtual ~SelectedJointTask(){};
/// \}
private:
void update_cmd();
void update_jacobian();
};
/// class LinkPosTask
class LinkPosTask : public Task {
public:
/// \{ \name Constructor and Destructor
LinkPosTask(RobotSystem *_robot, std::vector<std::string> _target_ids);
virtual ~LinkPosTask(){};
/// \}
private:
void update_cmd();
void update_jacobian();
};
/// class LinkOriTask
class LinkOriTask : public Task {
public:
/// \{ \name Constructor and Destructor
LinkOriTask(RobotSystem *_robot, std::vector<std::string> _target_ids);
virtual ~LinkOriTask(){};
/// \}
private:
void update_cmd();
void update_jacobian();
};
/// class CenterOfMassTask
class CenterOfMassTask : public Task {
public:
/// \{ \name Constructor and Destructor
CenterOfMassTask(RobotSystem *_robot);
virtual ~CenterOfMassTask(){};
/// \}
private:
void update_cmd();
void update_jacobian();
};
|
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/***************************************************************************
Motorola MC2661/MC68661 Enhanced Programmable Communications Interface
***************************************************************************/
#include "emu.h"
#include "mc2661.h"
//#define VERBOSE 1
#include "logmacro.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(MC2661, mc2661_device, "mc2661", "MC2661")
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
uint32_t baud_rates[16] =
{
50, 75, 110, 135 /*134.5*/, 150, 300, 600, 1200, 1800, 2000, 2400, 3600, 4800, 7200, 9600, 19200
};
enum
{
REGISTER_HOLDING = 0,
REGISTER_STATUS,
REGISTER_SYNC = REGISTER_STATUS,
REGISTER_MODE,
REGISTER_COMMAND
};
#define MODE_BAUD_RATE (m_mr[0] & 0x03)
#define MODE_CHARACTER ((m_mr[0] >> 2) & 0x03)
#define MODE_PARITY BIT(m_mr[0], 4)
#define MODE_PARITY_EVEN BIT(m_mr[0], 5)
#define MODE_TRANSPARENT BIT(m_mr[0], 6)
#define MODE_SINGLE_SYN BIT(m_mr[0], 7)
#define MODE_STOP_BITS ((m_mr[0] >> 6) & 0x03)
#define SYN1 m_sync[0]
#define SYN2 m_sync[1]
#define DLE m_sync[2]
#define COMMAND_TXEN BIT(m_cr, 0)
#define COMMAND_DTR BIT(m_cr, 1)
#define COMMAND_RXEN BIT(m_cr, 2)
#define COMMAND_BREAK BIT(m_cr, 3)
#define COMMAND_DLE BIT(m_cr, 3)
#define COMMAND_RESET BIT(m_cr, 4)
#define COMMAND_RTS BIT(m_cr, 5)
#define COMMAND_MODE (m_cr >> 6)
enum
{
MODE_NORMAL = 0,
MODE_ASYNC,
MODE_LOCAL_LOOP_BACK,
MODE_REMOTE_LOOP_BACK
};
#define STATUS_TXRDY 0x01
#define STATUS_RXRDY 0x02
#define STATUS_TXEMT 0x04
#define STATUS_PE 0x08
#define STATUS_DLE 0x08
#define STATUS_OVERRUN 0x10
#define STATUS_FE 0x20
#define STATUS_SYN 0x20
#define STATUS_DCD 0x40
#define STATUS_DSR 0x80
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// mc2661_device - constructor
//-------------------------------------------------
mc2661_device::mc2661_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, MC2661, tag, owner, clock),
device_serial_interface(mconfig, *this),
m_write_txd(*this),
m_write_rxrdy(*this),
m_write_txrdy(*this),
m_write_rts(*this),
m_write_dtr(*this),
m_write_txemt_dschg(*this),
m_write_bkdet(*this),
m_write_xsync(*this),
m_rxc(0),
m_txc(0),
m_sr(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void mc2661_device::device_start()
{
// resolve callbacks
m_write_txd.resolve_safe();
m_write_rxrdy.resolve_safe();
m_write_txrdy.resolve_safe();
m_write_rts.resolve_safe();
m_write_dtr.resolve_safe();
m_write_txemt_dschg.resolve_safe();
m_write_bkdet.resolve_safe();
m_write_xsync.resolve_safe();
// create the timers
if (m_rxc > 0)
{
set_rcv_rate(m_rxc);
}
if (m_txc > 0)
{
set_tra_rate(m_txc);
}
// save state
save_item(NAME(m_rhr));
save_item(NAME(m_thr));
save_item(NAME(m_cr));
save_item(NAME(m_sr));
save_item(NAME(m_mr));
save_item(NAME(m_sync));
save_item(NAME(m_mode_index));
save_item(NAME(m_sync_index));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void mc2661_device::device_reset()
{
receive_register_reset();
transmit_register_reset();
m_mr[0] = m_mr[1] = 0;
m_sync[0] = m_sync[1] = m_sync[2] = 0;
m_cr = 0;
m_sr = 0;
m_mode_index = 0;
m_sync_index = 0;
m_write_txd(1);
m_write_rxrdy(CLEAR_LINE);
m_write_txrdy(CLEAR_LINE);
m_write_rts(1);
m_write_dtr(1);
m_write_txemt_dschg(CLEAR_LINE);
m_write_bkdet(0);
m_write_xsync(0);
}
//-------------------------------------------------
// tra_callback -
//-------------------------------------------------
void mc2661_device::tra_callback()
{
m_write_txd(transmit_register_get_data_bit());
}
//-------------------------------------------------
// tra_complete -
//-------------------------------------------------
void mc2661_device::tra_complete()
{
// TODO
m_sr |= STATUS_TXRDY;
m_write_txrdy(ASSERT_LINE);
}
//-------------------------------------------------
// rcv_complete -
//-------------------------------------------------
void mc2661_device::rcv_complete()
{
// TODO
receive_register_extract();
m_rhr = get_received_char();
m_sr |= STATUS_RXRDY;
m_write_rxrdy(ASSERT_LINE);
}
//-------------------------------------------------
// read - register read
//-------------------------------------------------
READ8_MEMBER( mc2661_device::read )
{
uint8_t data = 0;
switch (offset & 0x03)
{
case REGISTER_HOLDING:
data = m_rhr;
m_sr &= ~STATUS_RXRDY;
m_write_rxrdy(CLEAR_LINE);
break;
case REGISTER_STATUS:
data = m_sr;
break;
case REGISTER_MODE:
data = m_mr[m_mode_index];
m_mode_index++;
m_mode_index &= 0x01;
break;
case REGISTER_COMMAND:
m_mode_index = 0;
m_sync_index = 0;
data = m_cr;
break;
}
return data;
}
//-------------------------------------------------
// write - register write
//-------------------------------------------------
WRITE8_MEMBER( mc2661_device::write )
{
switch (offset & 0x03)
{
case REGISTER_HOLDING:
LOG("MC2661 Transmit Holding Register: %02x\n", data);
m_thr = data;
if(COMMAND_TXEN)
{
if(COMMAND_MODE != 0x02)
transmit_register_setup(m_thr);
m_sr &= ~STATUS_TXRDY;
m_write_txrdy(CLEAR_LINE);
}
if(COMMAND_MODE == 0x02) // loopback - the Wicat will set this after enabling the transmitter
{
m_rhr = data;
m_sr |= STATUS_RXRDY; // pcd expects this
m_write_rxrdy(ASSERT_LINE);
}
break;
case REGISTER_SYNC:
LOG("MC2661 Sync Register %u: %02x\n", m_sync_index + 1, data);
m_sync[m_sync_index] = data;
m_sync_index++;
if (m_sync_index == 3) m_sync_index = 0;
break;
case REGISTER_MODE:
LOG("MC2661 Mode Register %u: %02x\n", m_mode_index + 1, data);
m_mr[m_mode_index] = data;
if (m_mode_index == 0)
{
int data_bit_count = 5 + MODE_CHARACTER;
parity_t parity;
if (!MODE_PARITY) parity = PARITY_NONE;
else if (MODE_PARITY_EVEN) parity = PARITY_EVEN;
else parity = PARITY_ODD;
stop_bits_t stop_bits;
switch (MODE_STOP_BITS)
{
case 0:
default:
stop_bits = STOP_BITS_0;
break;
case 1:
stop_bits = STOP_BITS_1;
break;
case 2:
stop_bits = STOP_BITS_1_5;
break;
case 3:
stop_bits = STOP_BITS_2;
break;
}
set_data_frame(1, data_bit_count, parity, stop_bits);
}
if(m_mode_index == 1)
{
uint32_t rx_baud = baud_rates[data & 0x0f];
uint32_t tx_baud = baud_rates[data & 0x0f];
if(data & 0x10) // internal receiver clock
{
// if((m_mr[0] & 0x03) != 0)
// rx_baud *= 16;
}
else // external receiver clock
{
switch(m_mr[0] & 0x03)
{
case 0x02:
rx_baud *= 16;
break;
case 0x03:
rx_baud *= 64;
break;
default:
// x1
break;
}
}
if(data & 0x20) // internal transmitter clock
{
// if((m_mr[0] & 0x03) != 0)
// tx_baud *= 16;
}
else // external transmitter clock
{
switch(m_mr[0] & 0x03)
{
case 0x02:
tx_baud *= 16;
break;
case 0x03:
tx_baud *= 64;
break;
default:
// x1
break;
}
}
set_rcv_rate(rx_baud);
set_tra_rate(tx_baud);
}
m_mode_index++;
m_mode_index &= 0x01;
break;
case REGISTER_COMMAND:
LOG("MC2661 Command Register: %02x\n", data);
m_cr = data & 0xef;
m_write_dtr(!COMMAND_DTR);
m_write_rts(!COMMAND_RTS);
if (COMMAND_MODE == 0x02) // local loopback
{
if(COMMAND_DTR && COMMAND_RTS) // CR1 and CR5 must be set to 1 to use local loopback
{
// probably much more to it that this, but this is enough for the Wicat to be happy
m_rhr = m_thr;
m_sr |= STATUS_RXRDY;
m_write_rxrdy(ASSERT_LINE);
return;
}
}
if (COMMAND_TXEN)
{
m_sr |= STATUS_TXRDY;
m_write_txrdy(ASSERT_LINE);
}
else
{
m_sr &= ~STATUS_TXRDY;
m_write_txrdy(CLEAR_LINE);
}
if (!COMMAND_RXEN)
{
m_sr &= ~STATUS_RXRDY;
m_write_rxrdy(CLEAR_LINE);
}
if (COMMAND_RESET)
{
m_sr &= ~(STATUS_FE | STATUS_OVERRUN | STATUS_PE);
}
break;
}
}
//-------------------------------------------------
// dsr_w - data set ready
//-------------------------------------------------
WRITE_LINE_MEMBER( mc2661_device::dsr_w )
{
LOG("MC2661 Data Set Ready: %u\n", state);
if (state)
{
m_sr &= ~STATUS_DSR;
}
else
{
m_sr |= STATUS_DSR;
}
}
//-------------------------------------------------
// dcd_w - data carrier detect
//-------------------------------------------------
WRITE_LINE_MEMBER( mc2661_device::dcd_w )
{
LOG("MC2661 Data Carrier Detect: %u\n", state);
if (state)
{
m_sr &= ~STATUS_DCD;
}
else
{
m_sr |= STATUS_DCD;
}
}
//-------------------------------------------------
// cts_w - clear to send
//-------------------------------------------------
WRITE_LINE_MEMBER( mc2661_device::cts_w )
{
LOG("MC2661 Clear to Send: %u\n", state);
}
//-------------------------------------------------
// rxrdy_r - receiver ready
//-------------------------------------------------
READ_LINE_MEMBER( mc2661_device::rxrdy_r )
{
return (m_sr & STATUS_RXRDY) ? ASSERT_LINE : CLEAR_LINE;
}
//-------------------------------------------------
// txemt_r - transmitter empty
//-------------------------------------------------
READ_LINE_MEMBER( mc2661_device::txemt_r )
{
return (m_sr & STATUS_TXEMT) ? ASSERT_LINE : CLEAR_LINE;
}
|
// Copyright 2019 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include <smk/BlendMode.hpp>
namespace smk {
/// @brief destination = source.
const BlendMode BlendMode::Replace = {
GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE, GL_ZERO, GL_ONE, GL_ZERO,
};
/// @brief destination += source.
const BlendMode BlendMode::Add = {
GL_FUNC_ADD, GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE,
};
/// @brief destination -= source.
const BlendMode BlendMode::Subtract = {
GL_FUNC_REVERSE_SUBTRACT,
GL_FUNC_REVERSE_SUBTRACT,
GL_ONE,
GL_ONE,
GL_ONE,
GL_ONE,
};
/// @brief destination = source * source.a + destination * (1 - souce.a)
const BlendMode BlendMode::Alpha = {
GL_FUNC_ADD, GL_FUNC_ADD,
GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
};
/// @brief destination *= source
const BlendMode BlendMode::Multiply = {
GL_FUNC_ADD, GL_FUNC_ADD, GL_DST_COLOR, GL_ZERO, GL_DST_ALPHA, GL_ZERO,
};
/// @brief destination = 1 - destination
const BlendMode BlendMode::Invert = {
GL_FUNC_ADD,
GL_FUNC_ADD,
GL_ONE_MINUS_DST_COLOR,
GL_ZERO,
GL_ONE_MINUS_SRC_ALPHA,
GL_ZERO,
};
bool BlendMode::operator==(const BlendMode& o) const {
return equation_rgb == o.equation_rgb && //
equation_alpha == o.equation_alpha && //
src_rgb == o.src_rgb && //
dst_rgb == o.dst_rgb && //
src_alpha == o.src_alpha && //
dst_alpha == o.dst_alpha; //
}
bool BlendMode::operator!=(const BlendMode& o) const {
return !operator==(o);
}
} // namespace smk
|
/*
* Copyright (c) 2012-2017, Intel Corporation
*
* 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.
*/
//!
//! \file vphal_render_sfc_g10_base.cpp
//! \brief VPHAL SFC Gen10 rendering component
//! \details The SFC renderer supports Scaling, IEF, CSC/ColorFill and Rotation.
//! It's responsible for setting up HW states and generating the SFC
//! commands.
//!
#include "vphal_render_vebox_base.h"
#include "vphal_render_sfc_g10_base.h"
#if __VPHAL_SFC_SUPPORTED
bool VphalSfcStateG10::IsInputFormatSupported(
PVPHAL_SURFACE srcSurface)
{
bool ret = true;
// Check if Input Format is supported
if ((srcSurface->Format != Format_NV12) &&
(srcSurface->Format != Format_AYUV) &&
(srcSurface->Format != Format_P010) &&
(srcSurface->Format != Format_P016) &&
(srcSurface->Format != Format_A8B8G8R8) &&
(srcSurface->Format != Format_X8B8G8R8) &&
(srcSurface->Format != Format_A8R8G8B8) &&
(srcSurface->Format != Format_X8R8G8B8) &&
!IS_PA_FORMAT(srcSurface->Format))
{
VPHAL_RENDER_NORMALMESSAGE("Unsupported Source Format '0x%08x' for SFC.", srcSurface->Format);
ret = false;
}
return ret;
}
bool VphalSfcStateG10::IsOutputFormatSupported(
PVPHAL_SURFACE outSurface)
{
bool ret = true;
if (!IS_RGB32_FORMAT(outSurface->Format) &&
// Remove RGB565 support due to quality issue, may reopen this after root cause in the future.
//!IS_RGB16_FORMAT(outSurface->Format) &&
outSurface->Format != Format_NV12 &&
outSurface->Format != Format_YUY2 &&
outSurface->Format != Format_UYVY &&
outSurface->Format != Format_AYUV)
{
VPHAL_RENDER_NORMALMESSAGE("Unsupported Render Target Format '0x%08x' for SFC Pipe.", outSurface->Format);
ret = false;
}
return ret;
}
void VphalSfcStateG10::GetInputWidthHeightAlignUnit(
MOS_FORMAT inputFormat,
MOS_FORMAT outputFormat,
uint16_t &widthAlignUnit,
uint16_t &heightAlignUnit)
{
MOS_UNUSED(inputFormat);
widthAlignUnit = 1;
heightAlignUnit = 1;
// Apply output alignment restriction to Region of the input frame.
GetOutputWidthHeightAlignUnit(outputFormat, widthAlignUnit, heightAlignUnit);
}
#endif // __VPHAL_SFC_SUPPORTED
|
#include <iostream>
#include <vector>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
void printList(ListNode* list)
{
cout << list->val << " ";
for ( ; list->next != NULL; )
{ list = list->next;
cout << list->val << " ";
}
}
class Solution {
public:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
ListNode sum(0);
ListNode *sum_ptr = &sum, *result = ∑
bool carry = false;
int bit_sum;
for (; l1->next == NULL && l2->next == NULL; l1 = l1->next, l2 = l2->next)
{
if (l1->next == NULL && l2->next == NULL)
bit_sum = (carry) ? l1->val + l2->val + 1 : l1->val + l2->val;
else if (l1->next == NULL)
bit_sum = (carry) ? l2->val + 1 : l2->val;
else if (l2->next == NULL)
bit_sum = (carry) ? l1->val + 1 : l1->val;
if (bit_sum >= 10)
{
carry = true;
sum_ptr->val = bit_sum - 10;
}
else
{
sum_ptr->val = bit_sum;
}
ListNode newSum(0);
sum_ptr->next = &newSum;
sum_ptr = &newSum;
}
return result;
}
};
int main()
{
cout << "H" << endl;
ListNode *p1, *p2;
ListNode L1(3), L2(5);
p1 = &L1;
L1.next = &L2;
p2 = p1;
Solution sol;
printList(sol.addTwoNumbers(p1, p2));
cout << endl;
printList(p1);
cout << endl;
printList(p2);
cout << endl;
printList(sol.addTwoNumbers(p1, p2));
}
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "clientversion.h"
#include "init.h"
#include "main.h"
#include "masternodeconfig.h"
#include "noui.h"
#include "scheduler.h"
#include "rpcserver.h"
#include "ui_interface.h"
#include "util.h"
#include "httpserver.h"
#include "httprpc.h"
#include "rpcserver.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <stdio.h>
/* Introduction text for doxygen: */
/*! \mainpage Developer documentation
*
* \section intro_sec Introduction
*
* This is the developer documentation of the reference client for an experimental new digital currency called Ultrachaint (http://www.ultrachaint.org),
* which enables instant payments to anyone, anywhere in the world. Ultrachaint uses peer-to-peer technology to operate
* with no central authority: managing transactions and issuing money are carried out collectively by the network.
*
* The software is a community-driven open source project, released under the MIT license.
*
* \section Navigation
* Use the buttons <code>Namespaces</code>, <code>Classes</code> or <code>Files</code> at the top of the page to start navigating the code.
*/
static bool fDaemon;
void WaitForShutdown(boost::thread_group* threadGroup)
{
bool fShutdown = ShutdownRequested();
// Tell the main threads to shutdown.
while (!fShutdown) {
MilliSleep(200);
fShutdown = ShutdownRequested();
}
if (threadGroup) {
Interrupt(*threadGroup);
threadGroup->join_all();
}
}
//////////////////////////////////////////////////////////////////////////////
//
// Start
//
bool AppInit(int argc, char* argv[])
{
boost::thread_group threadGroup;
CScheduler scheduler;
bool fRet = false;
//
// Parameters
//
// If Qt is used, parameters/ultrachaint.conf are parsed in qt/ultrachaint.cpp's main()
ParseParameters(argc, argv);
// Process help and version before taking care about datadir
if (mapArgs.count("-?") || mapArgs.count("-help") || mapArgs.count("-version")) {
std::string strUsage = _("Ultrachaint Core Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n";
if (mapArgs.count("-version")) {
strUsage += LicenseInfo();
} else {
strUsage += "\n" + _("Usage:") + "\n" +
" ultrachaintd [options] " + _("Start Ultrachaint Core Daemon") + "\n";
strUsage += "\n" + HelpMessage(HMM_BITCOIND);
}
fprintf(stdout, "%s", strUsage.c_str());
return false;
}
try {
if (!boost::filesystem::is_directory(GetDataDir(false))) {
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
return false;
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
} catch (std::exception& e) {
fprintf(stderr, "Error reading configuration file: %s\n", e.what());
return false;
}
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
if (!SelectParamsFromCommandLine()) {
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");
return false;
}
// parse masternode.conf
std::string strErr;
if (!masternodeConfig.read(strErr)) {
fprintf(stderr, "Error reading masternode configuration file: %s\n", strErr.c_str());
return false;
}
// Command-line RPC
bool fCommandLine = false;
for (int i = 1; i < argc; i++)
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "ultrachaint:"))
fCommandLine = true;
if (fCommandLine) {
fprintf(stderr, "Error: There is no RPC client functionality in ultrachaintd anymore. Use the ultrachaint-cli utility instead.\n");
exit(1);
}
#ifndef WIN32
fDaemon = GetBoolArg("-daemon", false);
if (fDaemon) {
fprintf(stdout, "Ultrachaint server starting\n");
// Daemonize
pid_t pid = fork();
if (pid < 0) {
fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno);
return false;
}
if (pid > 0) // Parent process, pid is child process id
{
return true;
}
// Child process falls through to rest of initialization
pid_t sid = setsid();
if (sid < 0)
fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
}
#endif
SoftSetBoolArg("-server", true);
fRet = AppInit2(threadGroup, scheduler);
} catch (std::exception& e) {
PrintExceptionContinue(&e, "AppInit()");
} catch (...) {
PrintExceptionContinue(NULL, "AppInit()");
}
if (!fRet) {
Interrupt(threadGroup);
// threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of
// the startup-failure cases to make sure they don't result in a hang due to some
// thread-blocking-waiting-for-another-thread-during-startup case
} else {
WaitForShutdown(&threadGroup);
}
Shutdown();
return fRet;
}
int main(int argc, char* argv[])
{
SetupEnvironment();
// Connect ultrachaintd signal handlers
noui_connect();
return (AppInit(argc, argv) ? 0 : 1);
}
|
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
*
* 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 "./ConnectionProvider.hpp"
#include "oatpp/network/server/SimpleTCPConnectionProvider.hpp"
#include "oatpp/core/utils/ConversionUtils.hpp"
#include "mbedtls/error.h"
namespace oatpp { namespace mbedtls { namespace server {
ConnectionProvider::ConnectionProvider(const std::shared_ptr<Config>& config,
const std::shared_ptr<oatpp::network::ServerConnectionProvider>& streamProvider)
: m_config(config)
, m_streamProvider(streamProvider)
{
setProperty(PROPERTY_HOST, streamProvider->getProperty(PROPERTY_HOST).toString());
setProperty(PROPERTY_PORT, streamProvider->getProperty(PROPERTY_PORT).toString());
}
std::shared_ptr<ConnectionProvider> ConnectionProvider::createShared(const std::shared_ptr<Config>& config,
const std::shared_ptr<oatpp::network::ServerConnectionProvider>& streamProvider){
return std::shared_ptr<ConnectionProvider>(new ConnectionProvider(config, streamProvider));
}
std::shared_ptr<ConnectionProvider> ConnectionProvider::createShared(const std::shared_ptr<Config>& config, v_uint16 port) {
return createShared(config, oatpp::network::server::SimpleTCPConnectionProvider::createShared(port));
}
ConnectionProvider::~ConnectionProvider() {
close();
}
void ConnectionProvider::close() {
m_streamProvider->close();
}
std::shared_ptr<oatpp::data::stream::IOStream> ConnectionProvider::getConnection(){
std::shared_ptr<IOStream> stream = m_streamProvider->getConnection();
if(!stream) {
return nullptr;
}
auto * tlsHandle = new mbedtls_ssl_context();
mbedtls_ssl_init(tlsHandle);
auto res = mbedtls_ssl_setup(tlsHandle, m_config->getTLSConfig());
if(res != 0) {
mbedtls_ssl_free(tlsHandle);
delete tlsHandle;
return nullptr;
}
return std::make_shared<Connection>(tlsHandle, stream, false);
}
void ConnectionProvider::invalidateConnection(const std::shared_ptr<IOStream>& connection) {
auto c = std::static_pointer_cast<oatpp::mbedtls::Connection>(connection);
/********************************************
* WARNING!!!
*
* c->closeTLS(); <--- DO NOT
*
* DO NOT CLOSE or DELETE TLS handles here.
* Remember - other threads can still be
* waiting for TLS events.
********************************************/
/* Invalidate underlying transport */
auto s = c->getTransportStream();
m_streamProvider->invalidateConnection(s);
}
}}}
|
// Copyright 2018, Bosch Software Innovations GmbH.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ROSBAG2__CONVERTER_HPP_
#define ROSBAG2__CONVERTER_HPP_
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "rosbag2/converter_options.hpp"
#include "rosbag2/serialization_format_converter_factory.hpp"
#include "rosbag2/serialization_format_converter_factory_interface.hpp"
#include "rosbag2/converter_interfaces/serialization_format_converter.hpp"
#include "rosbag2/types.hpp"
#include "rosbag2/visibility_control.hpp"
// This is necessary because of using stl types here. It is completely safe, because
// a) the member is not accessible from the outside
// b) there are no inline functions.
#ifdef _WIN32
# pragma warning(push)
# pragma warning(disable:4251)
#endif
namespace rosbag2
{
// Convenience struct to keep both type supports (rmw and introspection) together.
// Only used internally.
struct ConverterTypeSupport
{
const rosidl_message_type_support_t * rmw_type_support;
const rosidl_message_type_support_t * introspection_type_support;
};
class ROSBAG2_PUBLIC Converter
{
public:
explicit
Converter(
const std::string & input_format,
const std::string & output_format,
std::shared_ptr<SerializationFormatConverterFactoryInterface> converter_factory =
std::make_shared<SerializationFormatConverterFactory>());
Converter(
const rosbag2::ConverterOptions & converter_options,
std::shared_ptr<SerializationFormatConverterFactoryInterface> converter_factory =
std::make_shared<SerializationFormatConverterFactory>());
~Converter();
/**
* Converts the given SerializedBagMessage into the output format of the converter. The
* serialization format of the input message must be identical to the input format of the
* converter.
*
* \param message Message to convert
* \returns Converted message
*/
std::shared_ptr<SerializedBagMessage>
convert(std::shared_ptr<const SerializedBagMessage> message);
void add_topic(const std::string & topic, const std::string & type);
private:
std::shared_ptr<SerializationFormatConverterFactoryInterface> converter_factory_;
std::unique_ptr<converter_interfaces::SerializationFormatDeserializer> input_converter_;
std::unique_ptr<converter_interfaces::SerializationFormatSerializer> output_converter_;
std::unordered_map<std::string, ConverterTypeSupport> topics_and_types_;
};
class ROSBAG2_PUBLIC ConverterToDeserialized
{
public:
explicit
ConverterToDeserialized(
const std::string & input_format,
std::shared_ptr<SerializationFormatConverterFactoryInterface> converter_factory =
std::make_shared<SerializationFormatConverterFactory>());
~ConverterToDeserialized();
std::shared_ptr<rosbag2_introspection_message_t>
convert(std::shared_ptr<const SerializedBagMessage> message);
void add_topic(const std::string & topic, const std::string & type);
private:
std::shared_ptr<SerializationFormatConverterFactoryInterface> converter_factory_;
std::unique_ptr<converter_interfaces::SerializationFormatDeserializer> input_converter_;
std::unordered_map<std::string, ConverterTypeSupport> topics_and_types_;
};
} // namespace rosbag2
#ifdef _WIN32
# pragma warning(pop)
#endif
#endif // ROSBAG2__CONVERTER_HPP_
|
/* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 1999, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.2 $
// $Date: 2003-02-19 21:49:00 $
// $Source: /usr/local/cvs/OpenSees/EXAMPLES/TclPlaneTruss/TclPlaneTruss.cpp,v $
// Written: fmk
// Created: 04/98
// Revision: A
//
// Description: This file contains the class implementation for TclPlaneTruss
// TclPlaneTruss is a class for building a Plane Frame model in an interpreted
// environment. The constructor is used to add new commands to the interpreter,
// these commands are also defined in this file.
//
// What: "@(#) TclPlaneTruss.C, revA"
#include <stdlib.h>
#include <string.h>
#include <Domain.h>
#include <Node.h>
#include <Truss.h>
#include "MyTruss.h"
#include <fElmt02.h>
#include <ElasticMaterial.h>
#include <ElasticPPMaterial.h>
#include <ParallelMaterial.h>
#include <SP_Constraint.h>
#include <NodalLoad.h>
#include <ArrayOfTaggedObjects.h>
#include <LoadPattern.h>
#include "TclPlaneTruss.h"
//
// some static variables used in the functions
//
static Domain *theTclPlaneTrussDomain = 0;
static TclPlaneTruss *theTclPlaneTruss =0;
extern LoadPattern *theTclLoadPattern;
static int numSPs = 0;
static int loadTag = 0;
//
// the functions that will be invoked by the interpreter while building the model
//
int
TclPlaneTruss_addNode(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
int
TclPlaneTruss_addTruss(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
int
TclPlaneTruss_addMyTruss(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
int
TclPlaneTruss_addfTruss(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
int
TclModelBuilder_addMyPattern(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
int
TclPlaneTruss_addMaterial(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
int
TclPlaneTruss_addSP(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
int
TclPlaneTruss_addNodalLd(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
int
TclPlaneTruss_done(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv);
//
// the class constructor, destructor and methods
//
TclPlaneTruss::TclPlaneTruss(Domain &theDomain, Tcl_Interp *interp)
:ModelBuilder(theDomain)
{
theMaterials = new ArrayOfTaggedObjects(32);
// set the static pointer used in the class
theTclPlaneTrussDomain = &theDomain;
// call Tcl_CreateCommand for class specific commands
Tcl_CreateCommand(interp, "node", TclPlaneTruss_addNode,
(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand(interp, "truss", TclPlaneTruss_addTruss,
(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand(interp, "myTruss", TclPlaneTruss_addMyTruss,
(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand(interp, "fTruss", TclPlaneTruss_addfTruss,
(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand(interp, "material", TclPlaneTruss_addMaterial,
(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand(interp, "fix", TclPlaneTruss_addSP,
(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand(interp, "pattern", TclModelBuilder_addMyPattern,
(ClientData)NULL, NULL);
Tcl_CreateCommand(interp, "load", TclPlaneTruss_addNodalLd,
(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
Tcl_CreateCommand(interp, "doneModel", TclPlaneTruss_done,
(ClientData) NULL, (Tcl_CmdDeleteProc *)NULL);
// set the static pointer in this file
theTclPlaneTruss = this;
numSPs = 0;
theTclLoadPattern = 0;
}
TclPlaneTruss::~TclPlaneTruss()
{
// delete the material objects
theMaterials->clearAll();
delete theMaterials;
theTclLoadPattern =0;
// may possibly invoke Tcl_DeleteCommand() later
}
int
TclPlaneTruss::buildFE_Model(void)
{
return 0;
}
int
TclPlaneTruss::addMaterial(UniaxialMaterial &theMaterial)
{
bool result = theMaterials->addComponent(&theMaterial);
if (result == true)
return 0;
else
return -1;
}
UniaxialMaterial *
TclPlaneTruss::getMaterial(int tag)
{
TaggedObject *mc = theMaterials->getComponentPtr(tag);
if (mc == 0) return 0;
UniaxialMaterial *result = (UniaxialMaterial *)mc;
return result;
}
//
// the functions for adding nodes, beams, constraints and loads to the model
// that are called by the interpreter
//
int
TclPlaneTruss_addNode(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv)
{
// make sure at least one other argument to contain type of system
if (argc < 4) {
interp->result = "WARNING bad command - want node node_id x_loc y_loc <m_x m_y>";
return TCL_ERROR;
}
// get the id, x_loc and y_loc
int nodeId;
double xLoc, yLoc;
if (Tcl_GetInt(interp, argv[1], &nodeId) != TCL_OK) {
interp->result = "WARNING invalid node_id - node node_id x_loc y_loc ";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[2], &xLoc) != TCL_OK) {
interp->result = "WARNING invalid x_loc - node node_id x_loc y_loc ";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[3], &yLoc) != TCL_OK) {
interp->result = "WARNING invalid x_loc - node node_id x_loc y_loc ";
return TCL_ERROR;
}
// now create the node and add it to the Domain
Node *theNode = new Node(nodeId,2,xLoc,yLoc);
if (theNode == 0) {
opserr << "WARNING TclPlaneTruss - addNode - ran out of memory for node ";
opserr << nodeId << endln;
return TCL_ERROR;
}
// the node may have some mass associated with it
if (argc == 6) {
double mx, my;
if (Tcl_GetDouble(interp, argv[4], &mx) != TCL_OK) {
interp->result = "WARNING invalid x_mass - node node_id x_loc y_loc x_mass y_mass";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[5], &my) != TCL_OK) {
interp->result = "WARNING invalid x_loc - node node_id x_loc y_loc ";
return TCL_ERROR;
}
Matrix mass(2,2);
mass(0,0) = mx;
mass(1,1) = my;
theNode->setMass(mass);
}
if (theTclPlaneTrussDomain->addNode(theNode) == false) {
opserr << "WARNING TclPlaneTruss - addNode - could not add node to domain ";
opserr << nodeId << endln;
return TCL_ERROR;
}
// if get here we have successfully created the node and added it to the domain
return TCL_OK;
}
//
// to create a beam of type beam2d02 and add to the domain
//
int
TclPlaneTruss_addTruss(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv)
{
// make sure at least one other argument to contain type of system
if (argc != 6) {
interp->result = "WARNING bad command - want: truss eleId iNode jNode A matID";
return TCL_ERROR;
}
// get the id, x_loc and y_loc
int trussId, iNode, jNode, matID;
double A;
if (Tcl_GetInt(interp, argv[1], &trussId) != TCL_OK) {
interp->result = "WARNING invalid trussId- truss trussId iNode jNode A matID";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[2], &iNode) != TCL_OK) {
interp->result = "WARNING invalid iNode- truss trussId iNode jNode A matID";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[3], &jNode) != TCL_OK) {
interp->result = "WARNING invalid jNode- truss trussId iNode jNode A matID";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[4], &A) != TCL_OK) {
interp->result = "WARNING invalid A- truss trussId iNode jNode A matID";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[5], &matID) != TCL_OK) {
interp->result = "WARNING invalid matId- truss trussId iNode jNode A matID";
return TCL_ERROR;
}
UniaxialMaterial *theMaterial = theTclPlaneTruss->getMaterial(matID);
if (theMaterial == 0) {
opserr << "WARNING TclPlaneTruss - truss - no Material found with tag ";
opserr << matID << endln;
return TCL_ERROR;
}
// now create the truss and add it to the Domain
Truss *theTruss = new Truss(trussId,2,iNode,jNode,*theMaterial,A);
if (theTruss == 0) {
opserr << "WARNING TclPlaneTruss - addTruss - ran out of memory for node ";
opserr << trussId << endln;
return TCL_ERROR;
}
if (theTclPlaneTrussDomain->addElement(theTruss) == false) {
opserr << "WARNING TclPlaneTruss - addTruss - could not add Truss to domain ";
opserr << trussId << endln;
return TCL_ERROR;
}
// if get here we have successfully created the node and added it to the domain
return TCL_OK;
}
//
// to create an element of type MyTruss
//
int
TclPlaneTruss_addMyTruss(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv)
{
// make sure at least one other argument to contain type of system
if (argc != 6 && argc != 7) {
interp->result = "WARNING bad command - want: myTruss eleId iNode jNode Area matID";
return TCL_ERROR;
}
// get the id, x_loc and y_loc
int trussId, iNode, jNode, matID;
double A, M = 0.0;
if (Tcl_GetInt(interp, argv[1], &trussId) != TCL_OK) {
interp->result = "WARNING invalid eleId - myTruss eleId iNode jNode Area matID";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[2], &iNode) != TCL_OK) {
interp->result = "WARNING invalid iNode- myTruss eleId iNode jNode Area matID";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[3], &jNode) != TCL_OK) {
interp->result = "WARNING invalid jNode- myTruss eleId iNode jNode Area matID";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[4], &A) != TCL_OK) {
interp->result = "WARNING invalid A- myTruss eleId iNode jNode Area matID";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[5], &matID) != TCL_OK) {
interp->result = "WARNING invalid matId- myTruss eleId iNode jNode Area matID";
return TCL_ERROR;
}
if (argc == 7 && Tcl_GetDouble(interp, argv[6], &M) != TCL_OK) {
interp->result = "WARNING invalid matId- myTruss eleId iNode jNode Area matID";
return TCL_ERROR;
}
UniaxialMaterial *theMaterial = theTclPlaneTruss->getMaterial(matID);
if (theMaterial == 0) {
opserr << "WARNING TclPlaneTruss - truss - no Material found with tag ";
opserr << matID << endln;
return TCL_ERROR;
}
// now create the truss and add it to the Domain
MyTruss *theTruss = new MyTruss(trussId,iNode,jNode,*theMaterial,A,M);
if (theTruss == 0) {
opserr << "WARNING TclPlaneTruss - addMyTruss - ran out of memory for node ";
opserr << trussId << endln;
return TCL_ERROR;
}
if (theTclPlaneTrussDomain->addElement(theTruss) == false) {
delete theTruss;
opserr << "WARNING TclPlaneTruss - addTruss - could not add Truss to domain ";
opserr << trussId << endln;
return TCL_ERROR;
}
// if get here we have successfully created the node and added it to the domain
return TCL_OK;
}
//
// to create an element of type fElmt02 - fTruss
//
int
TclPlaneTruss_addfTruss(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv)
{
// make sure at least one other argument to contain type of system
if (argc != 6 && argc != 7) {
interp->result = "WARNING bad command - want: myTruss eleId iNode jNode Area E <rho>";
return TCL_ERROR;
}
// get the id, x_loc and y_loc
int trussId, iNode, jNode;
double A, E, M = 0.0;
if (Tcl_GetInt(interp, argv[1], &trussId) != TCL_OK) {
interp->result = "WARNING invalid eleId - myTruss eleId iNode jNode Area E";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[2], &iNode) != TCL_OK) {
interp->result = "WARNING invalid iNode- myTruss eleId iNode jNode Area E";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[3], &jNode) != TCL_OK) {
interp->result = "WARNING invalid jNode- myTruss eleId iNode jNode Area E";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[4], &A) != TCL_OK) {
interp->result = "WARNING invalid A- myTruss eleId iNode jNode Area E";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[5], &E) != TCL_OK) {
interp->result = "WARNING invalid E - myTruss eleId iNode jNode Area E";
return TCL_ERROR;
}
if (argc == 7 && Tcl_GetDouble(interp, argv[6], &M) != TCL_OK) {
interp->result = "WARNING invalid rho - myTruss eleId iNode jNode Area E rho";
return TCL_ERROR;
}
// now create the truss and add it to the Domain
fElmt02 *theTruss = new fElmt02(trussId,iNode,jNode,A,E,M);
if (theTruss == 0) {
opserr << "WARNING TclPlaneTruss - addMyTruss - ran out of memory for node ";
opserr << trussId << endln;
return TCL_ERROR;
}
if (theTclPlaneTrussDomain->addElement(theTruss) == false) {
delete theTruss;
opserr << "WARNING TclPlaneTruss - addTruss - could not add Truss to domain ";
opserr << trussId << endln;
return TCL_ERROR;
}
// if get here we have successfully created the node and added it to the domain
return TCL_OK;
}
int
TclPlaneTruss_addMaterial(ClientData clientData,
Tcl_Interp *interp, int argc,
char **argv)
{
// make sure at least one other argument to contain integrator
if (argc < 2) {
interp->result = "WARNING need to specify a Material type ";
return TCL_ERROR;
}
// check argv[1] for type of Numberer and create the object
if (strcmp(argv[1],"Elastic") == 0) {
if (argc != 4) {
interp->result = "WARNING want: material Elastic tag E ";
return TCL_ERROR;
}
int tag;
double E;
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
return TCL_ERROR;
if (Tcl_GetDouble(interp, argv[3], &E) != TCL_OK)
return TCL_ERROR;
UniaxialMaterial *theMaterial = new ElasticMaterial(tag,E);
if (theTclPlaneTruss->addMaterial(*theMaterial) < 0)
return TCL_ERROR;
else
return TCL_OK;
}
else if (strcmp(argv[1],"ElasticPP") == 0) {
if (argc != 5) {
interp->result = "WARNING want: material Elastic tag E ep";
return TCL_ERROR;
}
int tag;
double E, ep;
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
return TCL_ERROR;
if (Tcl_GetDouble(interp, argv[3], &E) != TCL_OK)
return TCL_ERROR;
if (Tcl_GetDouble(interp, argv[4], &ep) != TCL_OK)
return TCL_ERROR;
UniaxialMaterial *theMaterial = new ElasticPPMaterial(tag,E,ep);
if (theTclPlaneTruss->addMaterial(*theMaterial) < 0)
return TCL_ERROR;
else
return TCL_OK;
}
else if (strcmp(argv[1],"Parallel") == 0) {
if (argc < 3) {
interp->result = "WARNING want: material Parallel tag matTags";
return TCL_ERROR;
}
// get material tag
int tag;
if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
return TCL_ERROR;
// get tags of material in parallel model
int numMaterials = argc-3;
UniaxialMaterial **theMats = new UniaxialMaterial *[numMaterials];
for (int i=0; i<numMaterials; i++) {
int matTag;
if (Tcl_GetInt(interp, argv[3+i], &matTag) != TCL_OK)
return TCL_ERROR;
UniaxialMaterial *theMaterial =
theTclPlaneTruss->getMaterial(matTag);
if (theMaterial == 0) {
interp->result = "WARNING material Parallel tags - unknown tag ";
return TCL_ERROR;
}
theMats[i] = theMaterial;
}
// create the parallel model
UniaxialMaterial *theMaterial =
new ParallelMaterial(tag, numMaterials, theMats);
delete [] theMats;
if (theTclPlaneTruss->addMaterial(*theMaterial) < 0)
return TCL_ERROR;
else
return TCL_OK;
}
else {
interp->result = "WARNING No Material type exists ";
return TCL_ERROR;
}
return TCL_OK;
}
extern int TclPatternCommand(ClientData clientData,
Tcl_Interp *interp, int argc,
char **argv, Domain *theDomain);
int
TclModelBuilder_addMyPattern(ClientData clientData, Tcl_Interp *interp,
int argc, char **argv)
{
return TclPatternCommand(clientData, interp,
argc, argv, theTclPlaneTrussDomain);
}
int
TclPlaneTruss_addSP(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv)
{
// make sure at least one other argument to contain type of system
if (argc < 4) {
interp->result = "WARNING bad command - want: fix nodeId fixX fixY";
return TCL_ERROR;
}
// get the id, x_loc and y_loc
int nodeId, xFix, yFix;
if (Tcl_GetInt(interp, argv[1], &nodeId) != TCL_OK) {
interp->result = "WARNING invalid nodeId - fix nodeId fixX fixY";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[2], &xFix) != TCL_OK) {
interp->result = "WARNING invalid fixX - fix nodeId fixX fixY";
return TCL_ERROR;
}
if (Tcl_GetInt(interp, argv[3], &yFix) != TCL_OK) {
interp->result = "WARNING invalid fixY - fix nodeId fixX fixY";
return TCL_ERROR;
}
// now for every constrained dof create a SP_Constraint
SP_Constraint *theSP;
if (xFix != 0) {
theSP = new SP_Constraint(numSPs++, nodeId, 0, 0.0);
if (theSP == 0) {
opserr << "WARNING TclPlaneTruss - fix - ran out of memory for SP_Constraint ";
opserr << nodeId << endln;
return TCL_ERROR;
}
if (theTclPlaneTrussDomain->addSP_Constraint(theSP) == false) {
opserr << "WARNING TclPlaneTruss - fix - could not add SP_Constraint to domain ";
opserr << nodeId << endln;
return TCL_ERROR;
}
}
if (yFix != 0) {
theSP = new SP_Constraint(numSPs++, nodeId, 1, 0.0);
if (theSP == 0) {
opserr << "WARNING TclPlaneTruss - fix - ran out of memory for SP_Constraint ";
opserr << nodeId << endln;
return TCL_ERROR;
}
if (theTclPlaneTrussDomain->addSP_Constraint(theSP) == false) {
opserr << "WARNING TclPlaneTruss - fix - could not add SP_Constraint to domain ";
opserr << nodeId << endln;
return TCL_ERROR;
}
}
// if get here we have successfully created the node and added it to the domain
return TCL_OK;
}
int
TclPlaneTruss_addNodalLd(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv)
{
// make sure at least one other argument to contain type of system
if (argc < 4) {
interp->result = "WARNING bad command - want: load nodeId forceX forceY <tStart duration>";
return TCL_ERROR;
}
// get the id, x_loc and y_loc
int nodeId;
double xForce, yForce;
if (Tcl_GetInt(interp, argv[1], &nodeId) != TCL_OK) {
interp->result = "WARNING invalid nodeId - load nodeId forceX forceY ";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[2], &xForce) != TCL_OK) {
interp->result = "WARNING invalid forceX - load nodeId forceX forceY ";
return TCL_ERROR;
}
if (Tcl_GetDouble(interp, argv[3], &yForce) != TCL_OK) {
interp->result = "WARNING invalid forceY - load nodeId forceX forceY ";
return TCL_ERROR;
}
// now create the load and add it to the Domain
Vector forces(2);
forces(0)=xForce; forces(1)=yForce;
bool isLoadConst = false;
int loadPatternTag = 123456789; // some pattern that will never be used!
// allow some additional options at end of command
int endMarker = 4;
while (endMarker != argc) {
if (strcmp(argv[endMarker],"-const") == 0) {
// allow user to specify const load
isLoadConst = true;
} else if (strcmp(argv[endMarker],"-pattern") == 0) {
// allow user to specify load pattern other than current
endMarker++;
if (endMarker == argc ||
Tcl_GetInt(interp, argv[endMarker], &loadPatternTag) != TCL_OK) {
opserr << "WARNING invalid patternTag - load " << nodeId << " ";
opserr << "fX fY -pattern patternTag\n";
return TCL_ERROR;
}
}
endMarker++;
}
// get the current pattern tag if no tag given in i/p
if (loadPatternTag == 123456789)
if (theTclLoadPattern == 0) {
opserr << "WARNING no current load pattern - load " << nodeId;
opserr << " fX fY\n";
return TCL_ERROR;
} else
loadPatternTag = theTclLoadPattern->getTag();
// get a tag for the load - use the number of nodal loads in the domain
loadTag++;
// create the load
NodalLoad *theLoad = new NodalLoad(loadTag, nodeId, forces, isLoadConst);
if (theLoad == 0) {
opserr << "WARNING ran out of memory for load - load " << nodeId;
opserr << " fX fY\n";
return TCL_ERROR;
}
// add the load to the domain
if (theTclPlaneTrussDomain->addNodalLoad(theLoad, loadPatternTag)
== false) {
opserr << "WARNING TclModelBuilder - could not add load to domain ";
delete theLoad;
return TCL_ERROR;
}
// if get here we have successfully created the node and added it
return TCL_OK;
}
int
TclPlaneTruss_done(ClientData clientData, Tcl_Interp *interp, int argc,
char **argv)
{
return TCL_OK;
}
|
#include <connection_mock.h>
#include <test_error.h>
#include <ozo/impl/async_request.h>
#include <ozo/time_traits.h>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
namespace {
namespace hana = boost::hana;
using namespace testing;
using namespace ozo::tests;
using callback_mock = callback_gmock<connection_ptr<>>;
using ozo::impl::query_state;
using ozo::error_code;
using ozo::time_traits;
struct async_request_op : Test {
StrictMock<connection_gmock> connection {};
StrictMock<executor_gmock> callback_executor {};
StrictMock<callback_mock> callback {};
StrictMock<executor_gmock> executor {};
StrictMock<executor_gmock> strand {};
StrictMock<strand_executor_service_gmock> strand_service {};
StrictMock<stream_descriptor_gmock> socket {};
StrictMock<steady_timer_gmock> timer {};
io_context io {executor, strand_service};
decltype(make_connection(connection, io, socket, timer)) conn =
make_connection(connection, io, socket, timer);
time_traits::duration timeout {42};
};
TEST_F(async_request_op, should_set_timer_and_send_query_params_and_get_result_and_call_handler) {
Sequence s;
EXPECT_CALL(strand_service, get_executor()).InSequence(s).WillOnce(ReturnRef(strand));
// Set timer
EXPECT_CALL(timer, expires_after(time_traits::duration(42))).InSequence(s).WillOnce(Return(0));
EXPECT_CALL(timer, async_wait(_)).InSequence(s).WillOnce(Return());
// Send query params
EXPECT_CALL(connection, set_nonblocking()).InSequence(s).WillOnce(Return(0));
EXPECT_CALL(connection, send_query_params()).InSequence(s).WillOnce(Return(1));
EXPECT_CALL(executor, post(_)).InSequence(s).WillOnce(InvokeArgument<0>());
EXPECT_CALL(strand, dispatch(_)).InSequence(s).WillOnce(InvokeArgument<0>());
EXPECT_CALL(connection, flush_output()).InSequence(s).WillOnce(Return(ozo::impl::query_state::send_finish));
// Get result
EXPECT_CALL(executor, post(_)).InSequence(s).WillOnce(InvokeArgument<0>());
EXPECT_CALL(strand, dispatch(_)).InSequence(s).WillOnce(InvokeArgument<0>());
EXPECT_CALL(connection, is_busy()).InSequence(s).WillOnce(Return(false));
EXPECT_CALL(connection, get_result()).InSequence(s).WillOnce(Return(boost::none));
// Cancel timer
EXPECT_CALL(strand, post(_)).InSequence(s).WillOnce(InvokeArgument<0>());
EXPECT_CALL(timer, cancel()).InSequence(s).WillOnce(Return(1));
// Call client handler
EXPECT_CALL(callback, get_executor()).WillOnce(Return(ozo::tests::executor {&callback_executor}));
EXPECT_CALL(executor, post(_)).InSequence(s).WillOnce(InvokeArgument<0>());
EXPECT_CALL(callback_executor, dispatch(_)).InSequence(s).WillOnce(InvokeArgument<0>());
EXPECT_CALL(callback, call(error_code {}, _)).InSequence(s).WillOnce(Return());
ozo::impl::make_async_request_op(fake_query {}, timeout, [] (auto, auto) {}, wrap(callback))(error_code {}, conn);
}
TEST_F(async_request_op, should_cancel_socket_on_timeout) {
Sequence s;
EXPECT_CALL(strand_service, get_executor()).InSequence(s).WillOnce(ReturnRef(strand));
// Set timer
EXPECT_CALL(timer, expires_after(time_traits::duration(42))).InSequence(s).WillOnce(Return(0));
EXPECT_CALL(timer, async_wait(_)).InSequence(s).WillOnce(InvokeArgument<0>(error_code {}));
EXPECT_CALL(strand, post(_)).InSequence(s).WillOnce(InvokeArgument<0>());
EXPECT_CALL(socket, cancel(_)).InSequence(s).WillOnce(Return());
// Send query params
EXPECT_CALL(connection, set_nonblocking()).InSequence(s).WillOnce(Return(0));
EXPECT_CALL(connection, send_query_params()).InSequence(s).WillOnce(Return(1));
EXPECT_CALL(executor, post(_)).InSequence(s).WillOnce(Return());
// Get result
EXPECT_CALL(executor, post(_)).InSequence(s).WillOnce(Return());
ozo::impl::make_async_request_op(fake_query {}, timeout, [] (auto, auto) {}, wrap(callback))(error_code {}, conn);
}
} // namespace
|
/*
Copyright (C) 2021 Mike Kipnis
This file is part of DistributedATS, a free-software/open-source project
that integrates QuickFIX and LiquiBook over OpenDDS. This project simplifies
the process of having multiple FIX gateways communicating with multiple
matching engines in realtime.
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 "FileLog.h"
using namespace FIX;
namespace DistributedATS {
FIX::Log *FileLogFactory::create() {
m_globalLogCount++;
if (m_globalLogCount > 1)
return m_globalLog;
try {
if (m_path.size())
return new FileLog(m_path, m_fix_prefix);
std::string path;
std::string backupPath;
FIX::Dictionary settings = m_settings.get();
path = settings.getString(FILE_LOG_PATH);
backupPath = path;
if (settings.has(FILE_LOG_BACKUP_PATH))
backupPath = settings.getString(FILE_LOG_BACKUP_PATH);
return m_globalLog =
new DistributedATS::FileLog(path, backupPath, m_fix_prefix);
} catch (ConfigError &) {
m_globalLogCount--;
throw;
}
}
Log *FileLogFactory::create(const FIX::SessionID &s) {
if (m_path.size() && m_backupPath.size())
return new DistributedATS::FileLog(m_path, m_backupPath, s, m_fix_prefix);
if (m_path.size())
return new DistributedATS::FileLog(m_path, s, m_fix_prefix);
std::string path;
std::string backupPath;
FIX::SessionID defaultSession("FIX.4.4", "DEFAULT", "DEFAULT");
Dictionary settings = m_settings.get(defaultSession);
path = settings.getString(FILE_LOG_PATH);
backupPath = path;
if (settings.has(FILE_LOG_BACKUP_PATH))
backupPath = settings.getString(FILE_LOG_BACKUP_PATH);
return new DistributedATS::FileLog(path, backupPath, s, m_fix_prefix);
}
void FileLogFactory::destroy(FIX::Log *pLog) {
if (pLog == m_globalLog) {
m_globalLogCount--;
if (m_globalLogCount == 0) {
delete pLog;
m_globalLogCount = 0;
}
} else {
delete pLog;
}
}
FileLog::FileLog(const std::string &path, const std::string &prefix) {
init(path, path, prefix + "-GLOBAL");
}
FileLog::FileLog(const std::string &path, const std::string &backupPath,
const std::string &prefix) {
init(path, backupPath, prefix + "-GLOBAL");
}
FileLog::FileLog(const std::string &path, const FIX::SessionID &s,
const std::string &prefix) {
init(path, path, generatePrefix(prefix, s));
}
FileLog::FileLog(const std::string &path, const std::string &backupPath,
const FIX::SessionID &s, const std::string &prefix) {
init(path, backupPath, generatePrefix(prefix, s));
}
std::string FileLog::generatePrefix(const std::string &filePrefix,
const SessionID &s) {
const std::string &begin = s.getBeginString().getString();
const std::string &sender = s.getSenderCompID().getString();
const std::string &target = s.getTargetCompID().getString();
const std::string &qualifier = s.getSessionQualifier();
std::string prefix = filePrefix + "-" + begin + "-" + sender + "-" + target;
if (qualifier.size())
prefix += "-" + qualifier;
return prefix;
}
void FileLog::init(std::string path, std::string backupPath,
const std::string &prefix) {
file_mkdir(path.c_str());
file_mkdir(backupPath.c_str());
if (path.empty())
path = ".";
if (backupPath.empty())
backupPath = path;
m_fullPrefix = file_appendpath(path, prefix + ".");
m_fullBackupPrefix = file_appendpath(backupPath, prefix + ".");
m_messagesFileName = m_fullPrefix + "messages.current.log";
m_eventFileName = m_fullPrefix + "event.current.log";
m_messages.open(m_messagesFileName.c_str(), std::ios::out | std::ios::app);
if (!m_messages.is_open())
throw ConfigError("Could not open messages file: " + m_messagesFileName);
m_event.open(m_eventFileName.c_str(), std::ios::out | std::ios::app);
if (!m_event.is_open())
throw ConfigError("Could not open event file: " + m_eventFileName);
}
FileLog::~FileLog() {
m_messages.close();
m_event.close();
}
void FileLog::clear() {
m_messages.close();
m_event.close();
m_messages.open(m_messagesFileName.c_str(), std::ios::out | std::ios::trunc);
m_event.open(m_eventFileName.c_str(), std::ios::out | std::ios::trunc);
}
void FileLog::backup() {
m_messages.close();
m_event.close();
int i = 0;
while (true) {
std::stringstream messagesFileName;
std::stringstream eventFileName;
messagesFileName << m_fullBackupPrefix << "messages.backup." << ++i
<< ".log";
eventFileName << m_fullBackupPrefix << "event.backup." << i << ".log";
FILE *messagesLogFile = file_fopen(messagesFileName.str().c_str(), "r");
FILE *eventLogFile = file_fopen(eventFileName.str().c_str(), "r");
if (messagesLogFile == NULL && eventLogFile == NULL) {
file_rename(m_messagesFileName.c_str(), messagesFileName.str().c_str());
file_rename(m_eventFileName.c_str(), eventFileName.str().c_str());
m_messages.open(m_messagesFileName.c_str(),
std::ios::out | std::ios::trunc);
m_event.open(m_eventFileName.c_str(), std::ios::out | std::ios::trunc);
return;
}
if (messagesLogFile != NULL)
file_fclose(messagesLogFile);
if (eventLogFile != NULL)
file_fclose(eventLogFile);
}
}
} // namespace DistributedATS
|
/*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* 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 <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <string>
#include <stdexcept>
#include "ecs1030.hpp"
using namespace upm;
ECS1030::ECS1030 (uint8_t pinNumber) {
m_dataPinCtx = mraa_aio_init(pinNumber);
if (m_dataPinCtx == NULL) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed");
}
m_calibration = 111.1;
}
ECS1030::~ECS1030 () {
mraa_result_t error = MRAA_SUCCESS;
error = mraa_aio_close (m_dataPinCtx);
if (error != MRAA_SUCCESS) {
}
}
double
ECS1030::getCurrency_A () {
int sensorValue = 0;
float volt = 0;
float rms = 0;
for (int i = 0; i < NUMBER_OF_SAMPLES; i++) {
sensorValue = mraa_aio_read (m_dataPinCtx);
if (sensorValue == -1) throw std::runtime_error(std::string(__FUNCTION__) +
": Failed to do an aio read.");
volt = (VOLT_M * sensorValue) - 2.5;
volt = volt * volt;
rms = rms + volt;
usleep (DELAY_MS);
}
rms = rms / (float)NUMBER_OF_SAMPLES;
rms = sqrt(rms);
return rms / R_LOAD;
}
double
ECS1030::getCurrency_B () {
double sumCurrency = 0;
for (int i = 0; i < NUMBER_OF_SAMPLES; i++) {
m_lastSample = m_sample;
m_sample = mraa_aio_read (m_dataPinCtx);
if (m_sample == -1) throw std::runtime_error(std::string(__FUNCTION__) +
": Failed to do an aio read.");
m_lastFilter = m_filteredSample;
m_filteredSample = 0.996 * (m_lastFilter + m_sample - m_lastSample);
sumCurrency += (m_filteredSample * m_filteredSample);
}
double ratio = m_calibration * ((SUPPLYVOLTAGE / 1000.0) / (ADC_RESOLUTION));
return ( ratio * sqrt(sumCurrency / NUMBER_OF_SAMPLES) );
}
double
ECS1030::getPower_A () {
return 220.0 * getCurrency_A ();
}
double
ECS1030::getPower_B () {
return 220.0 * getCurrency_B ();
}
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/callback_helpers.h"
#include "base/bind.h"
#include "base/callback.h"
#include "gtest/gtest.h"
namespace {
void Increment(int* value) {
(*value)++;
}
TEST(CallbackHelpersTest, TestResetAndReturn) {
int run_count = 0;
base::Closure cb = base::Bind(&Increment, &run_count);
EXPECT_EQ(0, run_count);
base::ResetAndReturn(&cb).Run();
EXPECT_EQ(1, run_count);
EXPECT_FALSE(cb);
run_count = 0;
base::OnceClosure cb2 = base::BindOnce(&Increment, &run_count);
EXPECT_EQ(0, run_count);
base::ResetAndReturn(&cb2).Run();
EXPECT_EQ(1, run_count);
EXPECT_FALSE(cb2);
}
TEST(CallbackHelpersTest, TestScopedClosureRunnerExitScope) {
int run_count = 0;
{
base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count));
EXPECT_EQ(0, run_count);
}
EXPECT_EQ(1, run_count);
}
TEST(CallbackHelpersTest, TestScopedClosureRunnerRelease) {
int run_count = 0;
base::OnceClosure c;
{
base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count));
c = runner.Release();
EXPECT_EQ(0, run_count);
}
EXPECT_EQ(0, run_count);
std::move(c).Run();
EXPECT_EQ(1, run_count);
}
TEST(CallbackHelpersTest, TestScopedClosureRunnerReplaceClosure) {
int run_count_1 = 0;
int run_count_2 = 0;
{
base::ScopedClosureRunner runner;
runner.ReplaceClosure(base::Bind(&Increment, &run_count_1));
runner.ReplaceClosure(base::Bind(&Increment, &run_count_2));
EXPECT_EQ(0, run_count_1);
EXPECT_EQ(0, run_count_2);
}
EXPECT_EQ(0, run_count_1);
EXPECT_EQ(1, run_count_2);
}
TEST(CallbackHelpersTest, TestScopedClosureRunnerRunAndReset) {
int run_count_3 = 0;
{
base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count_3));
EXPECT_EQ(0, run_count_3);
runner.RunAndReset();
EXPECT_EQ(1, run_count_3);
}
EXPECT_EQ(1, run_count_3);
}
TEST(CallbackHelpersTest, TestScopedClosureRunnerMoveConstructor) {
int run_count = 0;
{
std::unique_ptr<base::ScopedClosureRunner> runner(
new base::ScopedClosureRunner(base::Bind(&Increment, &run_count)));
base::ScopedClosureRunner runner2(std::move(*runner));
runner.reset();
EXPECT_EQ(0, run_count);
}
EXPECT_EQ(1, run_count);
}
TEST(CallbackHelpersTest, TestScopedClosureRunnerMoveAssignment) {
int run_count_1 = 0;
int run_count_2 = 0;
{
base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count_1));
{
base::ScopedClosureRunner runner2(base::Bind(&Increment, &run_count_2));
runner = std::move(runner2);
EXPECT_EQ(0, run_count_1);
EXPECT_EQ(0, run_count_2);
}
EXPECT_EQ(0, run_count_1);
EXPECT_EQ(0, run_count_2);
}
EXPECT_EQ(0, run_count_1);
EXPECT_EQ(1, run_count_2);
}
TEST(CallbackHelpersTest, TestAdaptCallbackForRepeating) {
int count = 0;
base::OnceCallback<void(int*)> cb =
base::BindOnce([](int* count) { ++*count; });
base::RepeatingCallback<void(int*)> wrapped =
base::AdaptCallbackForRepeating(std::move(cb));
EXPECT_EQ(0, count);
wrapped.Run(&count);
EXPECT_EQ(1, count);
wrapped.Run(&count);
EXPECT_EQ(1, count);
}
} // namespace
|
// Part of measurement-kit <https://measurement-kit.github.io/>.
// Measurement-kit is free software. See AUTHORS and LICENSE for more
// information on the copying conditions.
#ifndef MEASUREMENT_KIT_NETTESTS_BASE_TEST_HPP
#define MEASUREMENT_KIT_NETTESTS_BASE_TEST_HPP
#include <measurement_kit/nettests/runnable.hpp>
namespace mk {
namespace nettests {
class Runnable;
class BaseTest {
public:
BaseTest &on_logger_eof(Delegate<>);
BaseTest &on_log(Delegate<uint32_t, const char *>);
BaseTest &on_event(Delegate<const char *>);
BaseTest &on_progress(Delegate<double, const char *>);
BaseTest &set_verbosity(uint32_t);
BaseTest &increase_verbosity();
BaseTest();
virtual ~BaseTest();
BaseTest &add_input_filepath(std::string);
BaseTest &set_input_filepath(std::string);
BaseTest &set_output_filepath(std::string);
BaseTest &set_error_filepath(std::string);
template <typename T> BaseTest &set_options(std::string key, T value) {
runnable->options[key] = value;
return *this;
}
BaseTest &on_entry(Delegate<std::string>);
BaseTest &on_begin(Delegate<>);
BaseTest &on_end(Delegate<> cb);
BaseTest &on_destroy(Delegate<> cb);
void run();
void start(Callback<> func);
Var<Runnable> runnable;
};
} // namespace nettests
} // namespace mk
#endif
|
#include <wx/fontdlg.h>
#include "fontdialog.h"
ChangeFont::ChangeFont(const wxString & title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(300, 200))
{
wxPanel *panel = new wxPanel(this, -1);
wxMenuBar *menubar = new wxMenuBar;
wxMenu *file = new wxMenu;
file->Append(ID_FONTDIALOG, wxT("&Change font"));
menubar->Append(file, wxT("&File"));
SetMenuBar(menubar);
Connect(ID_FONTDIALOG, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(ChangeFont::OnOpen));
st = new wxStaticText(panel, wxID_ANY, wxT("The Agoge"),
wxPoint(20, 20));
Center();
}
|
// github.com/andy489
#include <stdio.h>
#include <vector>
using namespace std;
const int mxN = 1e5;
int a[mxN], n;
vector<int> t[2 * mxN];
void init() {
scanf("%d", &n);
for (int i = 0; i < n; ++i)
scanf("%d", a + i);
}
void build(int v, int tl, int tr) {
if (tl == tr)
t[v] = vector<int>(1, a[tl]);
else {
int tm = tl + tr >> 1;
build(v + 1, tl, tm);
build(v + 2 * (tm - tl + 1), tm + 1, tr);
merge(t[v + 1].begin(), t[v + 1].end(),
t[v + 2 * (tm - tl + 1)].begin(), t[v + 2 * (tm - tl + 1)].end(),
back_inserter(t[v]));
}
}
int querySucc(int v, int tl, int tr, int l, int r, int x) {
if (l > r)
return 1e9;
if (l == tl && r == tr) {
vector<int>::iterator pos = lower_bound(t[v].begin(), t[v].end(), x);
if (pos != t[v].end())
return *pos;
return 1e9;
}
int tm = tl + tr >> 1;
return min(querySucc(v + 1, tl, tm, l, min(r, tm), x),
querySucc(v + 2 * (tm - tl + 1), tm + 1, tr, max(l, tm + 1), r, x));
}
int main() {
init();
build(1, 0, n - 1);
int q, cmd, l, r, x;
scanf("%d", &q);
while (q--) {
scanf("%d%d%d%d", &cmd, &l, &r, &x);
if (cmd == 1) {
--l, --r;
printf("%d\n", querySucc(1, 0, n - 1, l, r, x));
} else if (cmd == 2) {
// no modifications
} else {
printf("~Bad input\n");
}
}
return 0;
}
|
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
//
// hud_msg.cpp
//
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include "r_efx.h"
#define MAX_CLIENTS 32
extern BEAM* pBeam;
extern BEAM* pBeam2;
/// USER-DEFINED SERVER MESSAGE HANDLERS
int CHud::MsgFunc_ResetHUD(const char* pszName, int iSize, void* pbuf)
{
ASSERT(iSize == 0);
// clear all hud data
HUDLIST* pList = m_pHudList;
while (pList)
{
if (pList->p)
pList->p->Reset();
pList = pList->pNext;
}
// reset concussion effect
m_iConcussionEffect = 0;
return 1;
}
void CHud::MsgFunc_ViewMode(const char* pszName, int iSize, void* pbuf)
{
}
void CHud::MsgFunc_InitHUD(const char* pszName, int iSize, void* pbuf)
{
// prepare all hud data
HUDLIST* pList = m_pHudList;
while (pList)
{
if (pList->p)
pList->p->InitHUDData();
pList = pList->pNext;
}
//Probably not a good place to put this.
pBeam = pBeam2 = nullptr;
}
int CHud::MsgFunc_GameMode(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
m_Teamplay = READ_BYTE();
return 1;
}
int CHud::MsgFunc_Damage(const char* pszName, int iSize, void* pbuf)
{
int armor, blood;
Vector from;
int i = 0;
float count = 0.f;
BEGIN_READ(pbuf, iSize);
armor = READ_BYTE();
blood = READ_BYTE();
for (i = 0; i < 3; i++)
from[i] = READ_COORD();
count = (blood * 0.5) + (armor * 0.5);
if (count < 10)
count = 10;
// TODO: kick viewangles, show damage visually
return 1;
}
int CHud::MsgFunc_Concuss(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
m_iConcussionEffect = READ_BYTE();
if (m_iConcussionEffect)
this->m_StatusIcons.EnableIcon("dmg_concuss", 255, 160, 0);
else
this->m_StatusIcons.DisableIcon("dmg_concuss");
return 1;
}
int CHud::MsgFunc_GroundEnt(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
m_iGroundEntIndex = READ_SHORT();
return 1;
}
int CHud::MsgFunc_VRCtrlEnt(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
bool isLeftHand = READ_BYTE() != 0;
auto& data = isLeftHand ? m_leftControllerModelData : m_rightControllerModelData;
data.controller.body = READ_BYTE();
data.controller.skin = READ_BYTE();
data.controller.scale = READ_FLOAT();
data.controller.sequence = READ_LONG();
data.controller.frame = READ_FLOAT();
data.controller.framerate = READ_FLOAT();
data.controller.animtime = READ_FLOAT();
strncpy_s(data.controller.modelname, READ_STRING(), 1024);
data.hasDraggedEnt = false;
bool hasDraggedEntity = READ_BYTE() != 0;
if (hasDraggedEntity)
{
data.draggedEntIndex = READ_SHORT();
data.draggedEntOriginOffset = Vector{ READ_FLOAT(), READ_FLOAT(), READ_FLOAT() };
data.draggedEntAnglesOffset = Vector{ READ_FLOAT(), READ_FLOAT(), READ_FLOAT() };
data.draggedEnt.body = READ_BYTE();
data.draggedEnt.skin = READ_BYTE();
data.draggedEnt.scale = READ_FLOAT();
data.draggedEnt.sequence = READ_LONG();
data.draggedEnt.frame = READ_FLOAT();
data.draggedEnt.framerate = READ_FLOAT();
data.draggedEnt.animtime = READ_FLOAT();
data.draggedEnt.effects = READ_LONG();
data.draggedEnt.rendermode = READ_BYTE() & 0xFF;
data.draggedEnt.renderamt = READ_BYTE() & 0xFF;
data.draggedEnt.renderfx = READ_BYTE() & 0xFF;
data.draggedEnt.rendercolor.r = READ_BYTE() & 0xFF;
data.draggedEnt.rendercolor.g = READ_BYTE() & 0xFF;
data.draggedEnt.rendercolor.b = READ_BYTE() & 0xFF;
strncpy_s(data.draggedEnt.modelname, READ_STRING(), 1024);
data.hasDraggedEnt = true;
}
return 1;
}
int CHud::MsgFunc_TrainCtrl(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
m_trainControlPosition.x = READ_COORD();
m_trainControlPosition.y = READ_COORD();
m_trainControlPosition.z = READ_COORD();
m_trainControlYaw = READ_ANGLE();
return 1;
}
int CHud::MsgFunc_VRScrnShke(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
m_screenShakeAmplitude = READ_FLOAT();
m_screenShakeDuration = READ_FLOAT();
m_screenShakeFrequency = READ_FLOAT();
m_hasScreenShake = true;
return 1;
}
int CHud::MsgFunc_GrbdLddr(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
m_vrGrabbedLadderEntIndex = READ_SHORT();
return 1;
}
int CHud::MsgFunc_PullLdg(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
m_vrIsPullingOnLedge = READ_BYTE() != 0;
return 1;
}
int CHud::MsgFunc_VRTouch(const char* pszName, int iSize, void* pbuf)
{
BEGIN_READ(pbuf, iSize);
bool isLeftHand = READ_BYTE() != 0;
if (isLeftHand)
{
m_vrLeftHandTouchVibrateIntensity = READ_FLOAT();
}
else
{
m_vrRightHandTouchVibrateIntensity = READ_FLOAT();
}
return 1;
}
|
/*
MIT License
Copyright (c) 2020 Nicolai Trandafil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
template <bool condition>
struct When;
|
// C program for Knight Tour problem
#include<stdio.h>
#define N 8
int solveKTUtil(int x, int y, int movei, int sol[N][N],
int xMove[], int yMove[]);
/* A utility function to check if i,j are valid indexes
for N*N chessboard */
bool isSafe(int x, int y, int sol[N][N])
{
return ( x >= 0 && x < N && y >= 0 &&
y < N && sol[x][y] == -1);
}
/* A utility function to print solution matrix sol[N][N] */
void printSolution(int sol[N][N])
{
for (int x = 0; x < N; x++)
{
for (int y = 0; y < N; y++)
printf(" %2d ", sol[x][y]);
printf("\n");
}
}
/* This function solves the Knight Tour problem using
Backtracking. This function mainly uses solveKTUtil()
to solve the problem. It returns false if no complete
tour is possible, otherwise return true and prints the
tour.
Please note that there may be more than one solutions,
this function prints one of the feasible solutions. */
bool solveKT()
{
int sol[N][N];
/* Initialization of solution matrix */
for (int x = 0; x < N; x++)
for (int y = 0; y < N; y++)
sol[x][y] = -1;
/* xMove[] and yMove[] define next move of Knight.
xMove[] is for next value of x coordinate
yMove[] is for next value of y coordinate */
int xMove[8] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int yMove[8] = { 1, 2, 2, 1, -1, -2, -2, -1 };
// Since the Knight is initially at the first block
sol[0][0] = 0;
/* Start from 0,0 and explore all tours using
solveKTUtil() */
if (solveKTUtil(0, 0, 1, sol, xMove, yMove) == false)
{
printf("Solution does not exist");
return false;
}
else
printSolution(sol);
return true;
}
/* A recursive utility function to solve Knight Tour
problem */
int solveKTUtil(int x, int y, int movei, int sol[N][N],
int xMove[N], int yMove[N])
{
int k, next_x, next_y;
if (movei == N*N)
return true;
/* Try all next moves from the current coordinate x, y */
for (k = 0; k < 8; k++)
{
next_x = x + xMove[k];
next_y = y + yMove[k];
if (isSafe(next_x, next_y, sol))
{
sol[next_x][next_y] = movei;
if (solveKTUtil(next_x, next_y, movei+1, sol,
xMove, yMove) == true)
return true;
else
sol[next_x][next_y] = -1;// backtracking
}
}
return false;
}
/* Driver program to test above functions */
int main()
{
solveKT();
return 0;
}
|
/******************************************************************************
* $Id: rmfdataset.cpp 33987 2016-04-17 14:56:07Z rouault $
*
* Project: Raster Matrix Format
* Purpose: Read/write raster files used in GIS "Integratsia"
* (also known as "Panorama" GIS).
* Author: Andrey Kiselev, dron@ak4719.spb.edu
*
******************************************************************************
* Copyright (c) 2005, Andrey Kiselev <dron@ak4719.spb.edu>
* Copyright (c) 2007-2012, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "cpl_string.h"
#include "gdal_frmts.h"
#include "ogr_spatialref.h"
#include "rmfdataset.h"
CPL_CVSID("$Id: rmfdataset.cpp 33987 2016-04-17 14:56:07Z rouault $");
static const int RMF_DEFAULT_BLOCKXSIZE = 256;
static const int RMF_DEFAULT_BLOCKYSIZE = 256;
static const char RMF_SigRSW[] = { 'R', 'S', 'W', '\0' };
static const char RMF_SigRSW_BE[] = { '\0', 'W', 'S', 'R' };
static const char RMF_SigMTW[] = { 'M', 'T', 'W', '\0' };
static const char RMF_UnitsEmpty[] = "";
static const char RMF_UnitsM[] = "m";
static const char RMF_UnitsCM[] = "cm";
static const char RMF_UnitsDM[] = "dm";
static const char RMF_UnitsMM[] = "mm";
/************************************************************************/
/* ==================================================================== */
/* RMFRasterBand */
/* ==================================================================== */
/************************************************************************/
/************************************************************************/
/* RMFRasterBand() */
/************************************************************************/
RMFRasterBand::RMFRasterBand( RMFDataset *poDSIn, int nBandIn,
GDALDataType eType ) :
nBytesPerPixel(poDSIn->sHeader.nBitDepth / 8),
nLastTileWidth(poDSIn->GetRasterXSize() % poDSIn->sHeader.nTileWidth),
nLastTileHeight(poDSIn->GetRasterYSize() % poDSIn->sHeader.nTileHeight),
nDataSize(GDALGetDataTypeSize( eType ) / 8)
{
poDS = poDSIn;
nBand = nBandIn;
eDataType = eType;
nBlockXSize = poDSIn->sHeader.nTileWidth;
nBlockYSize = poDSIn->sHeader.nTileHeight;
nBlockSize = nBlockXSize * nBlockYSize;
nBlockBytes = nBlockSize * nDataSize;
#ifdef DEBUG
CPLDebug( "RMF",
"Band %d: tile width is %d, tile height is %d, "
" last tile width %u, last tile height %u, "
"bytes per pixel is %d, data type size is %d",
nBand, nBlockXSize, nBlockYSize,
nLastTileWidth, nLastTileHeight,
nBytesPerPixel, nDataSize );
#endif
}
/************************************************************************/
/* ~RMFRasterBand() */
/************************************************************************/
RMFRasterBand::~RMFRasterBand() {}
/************************************************************************/
/* ReadBuffer() */
/* */
/* Helper function to read specified amount of bytes from the input */
/* file stream. */
/************************************************************************/
CPLErr RMFRasterBand::ReadBuffer( GByte *pabyBuf, GUInt32 nBytes ) const
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
CPLAssert( pabyBuf != NULL && poGDS->fp != NULL );
const vsi_l_offset nOffset = VSIFTellL( poGDS->fp );
if ( VSIFReadL( pabyBuf, 1, nBytes, poGDS->fp ) < nBytes )
{
// XXX
if( poGDS->eAccess == GA_Update )
{
return CE_Failure;
}
else
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't read at offset %ld from input file.\n%s\n",
static_cast<long>( nOffset ), VSIStrerror( errno ) );
return CE_Failure;
}
}
#ifdef CPL_MSB
if ( poGDS->eRMFType == RMFT_MTW )
{
if ( poGDS->sHeader.nBitDepth == 16 )
{
for ( GUInt32 i = 0; i < nBytes; i += 2 )
CPL_SWAP16PTR( pabyBuf + i );
}
else if ( poGDS->sHeader.nBitDepth == 32 )
{
for ( GUInt32 i = 0; i < nBytes; i += 4 )
CPL_SWAP32PTR( pabyBuf + i );
}
else if ( poGDS->sHeader.nBitDepth == 64 )
{
for ( GUInt32 i = 0; i < nBytes; i += 8 )
CPL_SWAPDOUBLE( pabyBuf + i );
}
}
#endif
return CE_None;
}
/************************************************************************/
/* IReadBlock() */
/************************************************************************/
CPLErr RMFRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
void * pImage )
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
CPLAssert( poGDS != NULL
&& nBlockXOff >= 0
&& nBlockYOff >= 0
&& pImage != NULL );
memset( pImage, 0, nBlockBytes );
GUInt32 nTile = nBlockYOff * poGDS->nXTiles + nBlockXOff;
if (2 * nTile + 1 >= poGDS->sHeader.nTileTblSize / sizeof(GUInt32))
{
return CE_Failure;
}
GUInt32 nTileBytes = poGDS->paiTiles[2 * nTile + 1];
GUInt32 nCurBlockYSize;
if ( nLastTileHeight
&& static_cast<GUInt32>( nBlockYOff ) == poGDS->nYTiles - 1 )
nCurBlockYSize = nLastTileHeight;
else
nCurBlockYSize = nBlockYSize;
vsi_l_offset nTileOffset = poGDS->GetFileOffset( poGDS->paiTiles[2 * nTile] );
if ( VSIFSeekL( poGDS->fp, nTileOffset, SEEK_SET ) < 0 )
{
// XXX: We will not report error here, because file just may be
// in update state and data for this block will be available later
if( poGDS->eAccess == GA_Update )
return CE_None;
CPLError( CE_Failure, CPLE_FileIO,
"Can't seek to offset %ld in input file to read data.\n%s\n",
static_cast<long>( nTileOffset ),
VSIStrerror( errno ) );
return CE_Failure;
}
if ( poGDS->nBands == 1 &&
( poGDS->sHeader.nBitDepth == 8
|| poGDS->sHeader.nBitDepth == 16
|| poGDS->sHeader.nBitDepth == 32
|| poGDS->sHeader.nBitDepth == 64 ) )
{
if ( nTileBytes > nBlockBytes )
nTileBytes = nBlockBytes;
/* -------------------------------------------------------------------- */
/* Decompress buffer, if needed. */
/* -------------------------------------------------------------------- */
if ( poGDS->Decompress )
{
GUInt32 nRawBytes;
if ( nLastTileWidth && (GUInt32)nBlockXOff == poGDS->nXTiles - 1 )
nRawBytes = poGDS->nBands * nLastTileWidth * nDataSize;
else
nRawBytes = poGDS->nBands * nBlockXSize * nDataSize;
if ( nLastTileHeight && (GUInt32)nBlockYOff == poGDS->nYTiles - 1 )
nRawBytes *= nLastTileHeight;
else
nRawBytes *= nBlockYSize;
if ( nRawBytes > nTileBytes )
{
GByte *pabyTile = reinterpret_cast<GByte *>(
VSIMalloc( nTileBytes ) );
if ( !pabyTile )
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't allocate tile block of size %lu.\n%s\n",
(unsigned long) nTileBytes, VSIStrerror( errno ) );
return CE_Failure;
}
if ( ReadBuffer( pabyTile, nTileBytes ) == CE_Failure )
{
// XXX: Do not fail here, just return empty block
// and continue reading.
CPLFree( pabyTile );
return CE_None;
}
(*poGDS->Decompress)( pabyTile, nTileBytes,
reinterpret_cast<GByte*>( pImage ),
nRawBytes );
CPLFree( pabyTile );
/*nTileBytes = nRawBytes;*/
}
else
{
if ( ReadBuffer( reinterpret_cast<GByte *>( pImage ),
nTileBytes ) == CE_Failure )
{
// XXX: Do not fail here, just return empty block
// and continue reading.
return CE_None;
}
}
}
else
{
if ( ReadBuffer( reinterpret_cast<GByte *>( pImage ),
nTileBytes ) == CE_Failure )
{
// XXX: Do not fail here, just return empty block
// and continue reading.
return CE_None;
}
}
}
else if ( poGDS->eRMFType == RMFT_RSW )
{
GByte *pabyTile = reinterpret_cast<GByte *>( VSIMalloc( nTileBytes ) );
if ( !pabyTile )
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't allocate tile block of size %lu.\n%s\n",
(unsigned long) nTileBytes, VSIStrerror( errno ) );
return CE_Failure;
}
if ( ReadBuffer( pabyTile, nTileBytes ) == CE_Failure )
{
// XXX: Do not fail here, just return empty block
// and continue reading.
CPLFree( pabyTile );
return CE_None;
}
/* -------------------------------------------------------------------- */
/* If buffer was compressed, decompress it first. */
/* -------------------------------------------------------------------- */
if ( poGDS->Decompress )
{
GUInt32 nRawBytes;
if ( nLastTileWidth && (GUInt32)nBlockXOff == poGDS->nXTiles - 1 )
nRawBytes = poGDS->nBands * nLastTileWidth * nDataSize;
else
nRawBytes = poGDS->nBands * nBlockXSize * nDataSize;
if ( nLastTileHeight && (GUInt32)nBlockYOff == poGDS->nYTiles - 1 )
nRawBytes *= nLastTileHeight;
else
nRawBytes *= nBlockYSize;
if ( nRawBytes > nTileBytes )
{
GByte *pszRawBuf = reinterpret_cast<GByte *>(
VSIMalloc( nRawBytes ) );
if (pszRawBuf == NULL)
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't allocate a buffer for raw data of "
"size %lu.\n%s\n",
static_cast<unsigned long>( nRawBytes ),
VSIStrerror( errno ) );
VSIFree( pabyTile );
return CE_Failure;
}
(*poGDS->Decompress)( pabyTile, nTileBytes,
pszRawBuf, nRawBytes );
CPLFree( pabyTile );
pabyTile = pszRawBuf;
nTileBytes = nRawBytes;
}
}
/* -------------------------------------------------------------------- */
/* Deinterleave pixels from input buffer. */
/* -------------------------------------------------------------------- */
if ( poGDS->sHeader.nBitDepth == 24 || poGDS->sHeader.nBitDepth == 32 )
{
GUInt32 nTileSize = nTileBytes / nBytesPerPixel;
if ( nTileSize > nBlockSize )
nTileSize = nBlockSize;
for( GUInt32 i = 0; i < nTileSize; i++ )
{
// Colour triplets in RMF file organized in reverse order:
// blue, green, red. When we have 32-bit RMF the forth byte
// in quadruplet should be discarded as it has no meaning.
// That is why we always use 3 byte count in the following
// pabyTemp index.
reinterpret_cast<GByte *>( pImage )[i] =
pabyTile[i * nBytesPerPixel + 3 - nBand];
}
}
else if ( poGDS->sHeader.nBitDepth == 16 )
{
GUInt32 nTileSize = nTileBytes / nBytesPerPixel;
if ( nTileSize > nBlockSize )
nTileSize = nBlockSize;
for( GUInt32 i = 0; i < nTileSize; i++ )
{
switch ( nBand )
{
case 1:
reinterpret_cast<GByte *>( pImage )[i] =
static_cast<GByte>((reinterpret_cast<GUInt16 *>(
pabyTile )[i] & 0x7c00) >> 7);
break;
case 2:
reinterpret_cast<GByte *>( pImage )[i] =
static_cast<GByte>((reinterpret_cast<GUInt16 *>(
pabyTile )[i] & 0x03e0) >> 2);
break;
case 3:
reinterpret_cast<GByte *>( pImage )[i] =
static_cast<GByte>((reinterpret_cast<GUInt16 *>(
pabyTile)[i] & 0x1F) << 3);
break;
default:
break;
}
}
}
else if ( poGDS->sHeader.nBitDepth == 4 )
{
GByte *pabyTemp = pabyTile;
if( nTileBytes != (nBlockSize+1) / 2 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Tile has %d bytes, %d were expected",
nTileBytes, (nBlockSize+1) / 2 );
CPLFree( pabyTile );
return CE_Failure;
}
for( GUInt32 i = 0; i < nBlockSize; i++ )
{
// Most significant part of the byte represents leftmost pixel
if ( i & 0x01 )
reinterpret_cast<GByte *>( pImage )[i] = *pabyTemp++ & 0x0F;
else
reinterpret_cast<GByte *>( pImage )[i]
= (*pabyTemp & 0xF0) >> 4;
}
}
else if ( poGDS->sHeader.nBitDepth == 1 )
{
GByte *pabyTemp = pabyTile;
if( nTileBytes != (nBlockSize+7) / 8 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Tile has %d bytes, %d were expected",
nTileBytes, (nBlockSize+7) / 8 );
CPLFree( pabyTile );
return CE_Failure;
}
for( GUInt32 i = 0; i < nBlockSize; i++ )
{
switch ( i & 0x7 )
{
case 0:
reinterpret_cast<GByte *>( pImage )[i] = (*pabyTemp & 0x80) >> 7;
break;
case 1:
reinterpret_cast<GByte *>( pImage )[i] = (*pabyTemp & 0x40) >> 6;
break;
case 2:
reinterpret_cast<GByte *>( pImage )[i] = (*pabyTemp & 0x20) >> 5;
break;
case 3:
reinterpret_cast<GByte *>( pImage )[i] = (*pabyTemp & 0x10) >> 4;
break;
case 4:
reinterpret_cast<GByte *>( pImage )[i] = (*pabyTemp & 0x08) >> 3;
break;
case 5:
reinterpret_cast<GByte *>( pImage )[i] = (*pabyTemp & 0x04) >> 2;
break;
case 6:
reinterpret_cast<GByte *>( pImage )[i] = (*pabyTemp & 0x02) >> 1;
break;
case 7:
reinterpret_cast<GByte *>( pImage )[i] = *pabyTemp++ & 0x01;
break;
default:
break;
}
}
}
CPLFree( pabyTile );
}
if ( nLastTileWidth
&& static_cast<GUInt32>( nBlockXOff ) == poGDS->nXTiles - 1 )
{
for ( GUInt32 iRow = nCurBlockYSize - 1; iRow > 0; iRow-- )
{
memmove( reinterpret_cast<GByte *>( pImage )
+ nBlockXSize * iRow * nDataSize,
reinterpret_cast<GByte *>( pImage ) +
iRow * nLastTileWidth * nDataSize,
nLastTileWidth * nDataSize );
}
}
return CE_None;
}
/************************************************************************/
/* IWriteBlock() */
/************************************************************************/
CPLErr RMFRasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff,
void * pImage )
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
GUInt32 nTile = nBlockYOff * poGDS->nXTiles + nBlockXOff;
GUInt32 nTileBytes = nDataSize * poGDS->nBands;
GUInt32 iInPixel, iOutPixel, nCurBlockYSize;
GByte *pabyTile;
CPLAssert( poGDS != NULL
&& nBlockXOff >= 0
&& nBlockYOff >= 0
&& pImage != NULL );
vsi_l_offset nTileOffset = poGDS->GetFileOffset( poGDS->paiTiles[2 * nTile] );
if ( nTileOffset )
{
if ( VSIFSeekL( poGDS->fp, nTileOffset, SEEK_SET ) < 0 )
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't seek to offset %ld in output file to write data.\n%s",
static_cast<long>( nTileOffset ),
VSIStrerror( errno ) );
return CE_Failure;
}
}
else
{
if ( VSIFSeekL( poGDS->fp, 0, SEEK_END ) < 0 )
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't seek to offset %ld in output file to write data.\n%s",
static_cast<long>( nTileOffset ),
VSIStrerror( errno ) );
return CE_Failure;
}
vsi_l_offset nNewTileOffset;
nTileOffset = VSIFTellL( poGDS->fp );
poGDS->paiTiles[2 * nTile] = poGDS->GetRMFOffset( nTileOffset, &nNewTileOffset );
if( nTileOffset != nNewTileOffset )
{ //May be it is better to write some zeros here?
if ( VSIFSeekL( poGDS->fp, nNewTileOffset, SEEK_SET ) < 0 )
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't seek to offset %ld in output file to write data.\n%s",
static_cast<long>( nNewTileOffset ),
VSIStrerror( errno ) );
return CE_Failure;
}
}
nTileOffset = nNewTileOffset;
poGDS->bHeaderDirty = TRUE;
}
if ( nLastTileWidth
&& static_cast<GUInt32>( nBlockXOff ) == poGDS->nXTiles - 1 )
nTileBytes *= nLastTileWidth;
else
nTileBytes *= nBlockXSize;
if ( nLastTileHeight
&& static_cast<GUInt32>( nBlockYOff ) == poGDS->nYTiles - 1 )
nCurBlockYSize = nLastTileHeight;
else
nCurBlockYSize = nBlockYSize;
nTileBytes *= nCurBlockYSize;
pabyTile = reinterpret_cast<GByte *>( VSICalloc( nTileBytes, 1 ) );
if ( !pabyTile )
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't allocate space for the tile block of size %lu.\n%s",
static_cast<unsigned long>( nTileBytes ),
VSIStrerror( errno ) );
return CE_Failure;
}
if ( nLastTileWidth
&& static_cast<GUInt32>( nBlockXOff ) == poGDS->nXTiles - 1 )
{
GUInt32 iRow;
if ( poGDS->nBands == 1 )
{
for ( iRow = 0; iRow < nCurBlockYSize; iRow++ )
{
memcpy( pabyTile + iRow * nLastTileWidth * nDataSize,
reinterpret_cast<GByte *>( pImage )
+ nBlockXSize * iRow * nDataSize, nLastTileWidth * nDataSize );
}
}
else
{
if ( poGDS->paiTiles[2 * nTile + 1] )
{
VSIFReadL( pabyTile, 1, nTileBytes, poGDS->fp );
VSIFSeekL( poGDS->fp, nTileOffset, SEEK_SET );
}
for ( iRow = 0; iRow < nCurBlockYSize; iRow++ )
{
for ( iInPixel = 0, iOutPixel = nBytesPerPixel - nBand;
iOutPixel < nLastTileWidth * nDataSize * poGDS->nBands;
iInPixel++, iOutPixel += poGDS->nBands )
(pabyTile + iRow * nLastTileWidth * nDataSize * poGDS->nBands)[iOutPixel] =
(reinterpret_cast<GByte *>( pImage ) + nBlockXSize
* iRow * nDataSize)[iInPixel];
}
}
}
else
{
if ( poGDS->nBands == 1 )
memcpy( pabyTile, pImage, nTileBytes );
else
{
if ( poGDS->paiTiles[2 * nTile + 1] )
{
VSIFReadL( pabyTile, 1, nTileBytes, poGDS->fp );
VSIFSeekL( poGDS->fp, nTileOffset, SEEK_SET );
}
for ( iInPixel = 0, iOutPixel = nBytesPerPixel - nBand;
iOutPixel < nTileBytes;
iInPixel++, iOutPixel += poGDS->nBands )
pabyTile[iOutPixel] = reinterpret_cast<GByte *>( pImage )[iInPixel];
}
}
#ifdef CPL_MSB
if ( poGDS->eRMFType == RMFT_MTW )
{;
if ( poGDS->sHeader.nBitDepth == 16 )
{
for( GUInt32 i = 0; i < nTileBytes; i += 2 )
CPL_SWAP16PTR( pabyTile + i );
}
else if ( poGDS->sHeader.nBitDepth == 32 )
{
for( GUInt32 i = 0; i < nTileBytes; i += 4 )
CPL_SWAP32PTR( pabyTile + i );
}
else if ( poGDS->sHeader.nBitDepth == 64 )
{
for( GUInt32 i = 0; i < nTileBytes; i += 8 )
CPL_SWAPDOUBLE( pabyTile + i );
}
}
#endif
if ( VSIFWriteL( pabyTile, 1, nTileBytes, poGDS->fp ) < nTileBytes )
{
CPLError( CE_Failure, CPLE_FileIO,
"Can't write block with X offset %d and Y offset %d.\n%s",
nBlockXOff, nBlockYOff, VSIStrerror( errno ) );
VSIFree( pabyTile );
return CE_Failure;
}
poGDS->paiTiles[2 * nTile + 1] = nTileBytes;
VSIFree( pabyTile );
poGDS->bHeaderDirty = TRUE;
return CE_None;
}
/************************************************************************/
/* GetNoDataValue() */
/************************************************************************/
double RMFRasterBand::GetNoDataValue( int *pbSuccess )
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
if ( pbSuccess )
*pbSuccess = TRUE;
return poGDS->sHeader.dfNoData;
}
/************************************************************************/
/* GetUnitType() */
/************************************************************************/
const char *RMFRasterBand::GetUnitType()
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
return (const char *)poGDS->pszUnitType;
}
/************************************************************************/
/* SetUnitType() */
/************************************************************************/
CPLErr RMFRasterBand::SetUnitType( const char *pszNewValue )
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
CPLFree(poGDS->pszUnitType);
poGDS->pszUnitType = CPLStrdup( pszNewValue );
return CE_None;
}
/************************************************************************/
/* GetColorTable() */
/************************************************************************/
GDALColorTable *RMFRasterBand::GetColorTable()
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
return poGDS->poColorTable;
}
/************************************************************************/
/* SetColorTable() */
/************************************************************************/
CPLErr RMFRasterBand::SetColorTable( GDALColorTable *poColorTable )
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
if ( poColorTable )
{
if ( poGDS->eRMFType == RMFT_RSW && poGDS->nBands == 1 )
{
if ( !poGDS->pabyColorTable )
return CE_Failure;
GDALColorEntry oEntry;
for( GUInt32 i = 0; i < poGDS->nColorTableSize; i++ )
{
poColorTable->GetColorEntryAsRGB( i, &oEntry );
poGDS->pabyColorTable[i * 4] = (GByte) oEntry.c1; // Red
poGDS->pabyColorTable[i * 4 + 1] = (GByte) oEntry.c2; // Green
poGDS->pabyColorTable[i * 4 + 2] = (GByte) oEntry.c3; // Blue
poGDS->pabyColorTable[i * 4 + 3] = 0;
}
poGDS->bHeaderDirty = TRUE;
}
return CE_None;
}
return CE_Failure;
}
/************************************************************************/
/* GetColorInterpretation() */
/************************************************************************/
GDALColorInterp RMFRasterBand::GetColorInterpretation()
{
RMFDataset *poGDS = reinterpret_cast<RMFDataset *>( poDS );
if( poGDS->nBands == 3 )
{
if( nBand == 1 )
return GCI_RedBand;
else if( nBand == 2 )
return GCI_GreenBand;
else if( nBand == 3 )
return GCI_BlueBand;
return GCI_Undefined;
}
if ( poGDS->eRMFType == RMFT_RSW )
return GCI_PaletteIndex;
return GCI_Undefined;
}
/************************************************************************/
/* ==================================================================== */
/* RMFDataset */
/* ==================================================================== */
/************************************************************************/
/************************************************************************/
/* RMFDataset() */
/************************************************************************/
RMFDataset::RMFDataset() :
eRMFType(RMFT_RSW),
nXTiles(0),
nYTiles(0),
paiTiles(NULL),
nColorTableSize(0),
pabyColorTable(NULL),
poColorTable(NULL),
pszProjection(CPLStrdup( "" )),
pszUnitType(CPLStrdup( RMF_UnitsEmpty )),
bBigEndian(FALSE),
bHeaderDirty(FALSE),
pszFilename(NULL),
fp(NULL),
Decompress(NULL)
{
nBands = 0;
adfGeoTransform[0] = 0.0;
adfGeoTransform[1] = 1.0;
adfGeoTransform[2] = 0.0;
adfGeoTransform[3] = 0.0;
adfGeoTransform[4] = 0.0;
adfGeoTransform[5] = 1.0;
memset( &sHeader, 0, sizeof(sHeader) );
memset( &sExtHeader, 0, sizeof(sExtHeader) );
}
/************************************************************************/
/* ~RMFDataset() */
/************************************************************************/
RMFDataset::~RMFDataset()
{
FlushCache();
CPLFree( paiTiles );
CPLFree( pszProjection );
CPLFree( pszUnitType );
CPLFree( pabyColorTable );
if ( poColorTable != NULL )
delete poColorTable;
if ( fp )
VSIFCloseL( fp );
}
/************************************************************************/
/* GetGeoTransform() */
/************************************************************************/
CPLErr RMFDataset::GetGeoTransform( double * padfTransform )
{
memcpy( padfTransform, adfGeoTransform, sizeof(adfGeoTransform[0]) * 6 );
if( sHeader.iGeorefFlag )
return CE_None;
return CE_Failure;
}
/************************************************************************/
/* SetGeoTransform() */
/************************************************************************/
CPLErr RMFDataset::SetGeoTransform( double * padfTransform )
{
memcpy( adfGeoTransform, padfTransform, sizeof(double) * 6 );
sHeader.dfPixelSize = adfGeoTransform[1];
if ( sHeader.dfPixelSize != 0.0 )
sHeader.dfResolution = sHeader.dfScale / sHeader.dfPixelSize;
sHeader.dfLLX = adfGeoTransform[0];
sHeader.dfLLY = adfGeoTransform[3] - nRasterYSize * sHeader.dfPixelSize;
sHeader.iGeorefFlag = 1;
bHeaderDirty = TRUE;
return CE_None;
}
/************************************************************************/
/* GetProjectionRef() */
/************************************************************************/
const char *RMFDataset::GetProjectionRef()
{
if( pszProjection )
return pszProjection;
return "";
}
/************************************************************************/
/* SetProjection() */
/************************************************************************/
CPLErr RMFDataset::SetProjection( const char * pszNewProjection )
{
if ( pszProjection )
CPLFree( pszProjection );
pszProjection = CPLStrdup( (pszNewProjection) ? pszNewProjection : "" );
bHeaderDirty = TRUE;
return CE_None;
}
/************************************************************************/
/* WriteHeader() */
/************************************************************************/
CPLErr RMFDataset::WriteHeader()
{
/* -------------------------------------------------------------------- */
/* Setup projection. */
/* -------------------------------------------------------------------- */
if( pszProjection && !EQUAL( pszProjection, "" ) )
{
OGRSpatialReference oSRS;
char *pszProj = pszProjection;
if ( oSRS.importFromWkt( &pszProj ) == OGRERR_NONE )
{
long iProjection, iDatum, iEllips, iZone;
double adfPrjParams[7];
oSRS.exportToPanorama( &iProjection, &iDatum, &iEllips, &iZone,
adfPrjParams );
sHeader.iProjection = static_cast<int>(iProjection);
sHeader.dfStdP1 = adfPrjParams[0];
sHeader.dfStdP2 = adfPrjParams[1];
sHeader.dfCenterLat = adfPrjParams[2];
sHeader.dfCenterLong = adfPrjParams[3];
sExtHeader.nEllipsoid = static_cast<int>(iEllips);
sExtHeader.nDatum = static_cast<int>(iDatum);
sExtHeader.nZone = static_cast<int>(iZone);
}
}
#define RMF_WRITE_LONG( ptr, value, offset ) \
do { \
GInt32 iLong = CPL_LSBWORD32( value ); \
memcpy( (ptr) + (offset), &iLong, 4 ); \
} while(0);
#define RMF_WRITE_ULONG( ptr,value, offset ) \
do { \
GUInt32 iULong = CPL_LSBWORD32( value ); \
memcpy( (ptr) + (offset), &iULong, 4 ); \
} while(0);
#define RMF_WRITE_DOUBLE( ptr,value, offset ) \
do { \
double dfDouble = (value); \
CPL_LSBPTR64( &dfDouble ); \
memcpy( (ptr) + (offset), &dfDouble, 8 ); \
} while(0);
/* -------------------------------------------------------------------- */
/* Write out the main header. */
/* -------------------------------------------------------------------- */
{
GByte abyHeader[RMF_HEADER_SIZE];
memset( abyHeader, 0, sizeof(abyHeader) );
memcpy( abyHeader, sHeader.bySignature, RMF_SIGNATURE_SIZE );
RMF_WRITE_ULONG( abyHeader, sHeader.iVersion, 4 );
//
RMF_WRITE_ULONG( abyHeader, sHeader.nOvrOffset, 12 );
RMF_WRITE_ULONG( abyHeader, sHeader.iUserID, 16 );
memcpy( abyHeader + 20, sHeader.byName, RMF_NAME_SIZE );
RMF_WRITE_ULONG( abyHeader, sHeader.nBitDepth, 52 );
RMF_WRITE_ULONG( abyHeader, sHeader.nHeight, 56 );
RMF_WRITE_ULONG( abyHeader, sHeader.nWidth, 60 );
RMF_WRITE_ULONG( abyHeader, sHeader.nXTiles, 64 );
RMF_WRITE_ULONG( abyHeader, sHeader.nYTiles, 68 );
RMF_WRITE_ULONG( abyHeader, sHeader.nTileHeight, 72 );
RMF_WRITE_ULONG( abyHeader, sHeader.nTileWidth, 76 );
RMF_WRITE_ULONG( abyHeader, sHeader.nLastTileHeight, 80 );
RMF_WRITE_ULONG( abyHeader, sHeader.nLastTileWidth, 84 );
RMF_WRITE_ULONG( abyHeader, sHeader.nROIOffset, 88 );
RMF_WRITE_ULONG( abyHeader, sHeader.nROISize, 92 );
RMF_WRITE_ULONG( abyHeader, sHeader.nClrTblOffset, 96 );
RMF_WRITE_ULONG( abyHeader, sHeader.nClrTblSize, 100 );
RMF_WRITE_ULONG( abyHeader, sHeader.nTileTblOffset, 104 );
RMF_WRITE_ULONG( abyHeader, sHeader.nTileTblSize, 108 );
RMF_WRITE_LONG( abyHeader, sHeader.iMapType, 124 );
RMF_WRITE_LONG( abyHeader, sHeader.iProjection, 128 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfScale, 136 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfResolution, 144 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfPixelSize, 152 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfLLY, 160 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfLLX, 168 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfStdP1, 176 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfStdP2, 184 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfCenterLong, 192 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfCenterLat, 200 );
*(abyHeader + 208) = sHeader.iCompression;
*(abyHeader + 209) = sHeader.iMaskType;
*(abyHeader + 210) = sHeader.iMaskStep;
*(abyHeader + 211) = sHeader.iFrameFlag;
RMF_WRITE_ULONG( abyHeader, sHeader.nFlagsTblOffset, 212 );
RMF_WRITE_ULONG( abyHeader, sHeader.nFlagsTblSize, 216 );
RMF_WRITE_ULONG( abyHeader, sHeader.nFileSize0, 220 );
RMF_WRITE_ULONG( abyHeader, sHeader.nFileSize1, 224 );
*(abyHeader + 228) = sHeader.iUnknown;
*(abyHeader + 244) = sHeader.iGeorefFlag;
*(abyHeader + 245) = sHeader.iInverse;
memcpy( abyHeader + 248, sHeader.abyInvisibleColors,
sizeof(sHeader.abyInvisibleColors) );
RMF_WRITE_DOUBLE( abyHeader, sHeader.adfElevMinMax[0], 280 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.adfElevMinMax[1], 288 );
RMF_WRITE_DOUBLE( abyHeader, sHeader.dfNoData, 296 );
RMF_WRITE_ULONG( abyHeader, sHeader.iElevationUnit, 304 );
*(abyHeader + 308) = sHeader.iElevationType;
RMF_WRITE_ULONG( abyHeader, sHeader.nExtHdrOffset, 312 );
RMF_WRITE_ULONG( abyHeader, sHeader.nExtHdrSize, 316 );
VSIFSeekL( fp, 0, SEEK_SET );
VSIFWriteL( abyHeader, 1, sizeof(abyHeader), fp );
}
/* -------------------------------------------------------------------- */
/* Write out the extended header. */
/* -------------------------------------------------------------------- */
if ( sHeader.nExtHdrOffset && sHeader.nExtHdrSize )
{
GByte *pabyExtHeader = reinterpret_cast<GByte *>(
CPLCalloc( sHeader.nExtHdrSize, 1 ) );
RMF_WRITE_LONG( pabyExtHeader, sExtHeader.nEllipsoid, 24 );
RMF_WRITE_LONG( pabyExtHeader, sExtHeader.nDatum, 32 );
RMF_WRITE_LONG( pabyExtHeader, sExtHeader.nZone, 36 );
VSIFSeekL( fp, GetFileOffset( sHeader.nExtHdrOffset ), SEEK_SET );
VSIFWriteL( pabyExtHeader, 1, sHeader.nExtHdrSize, fp );
CPLFree( pabyExtHeader );
}
#undef RMF_WRITE_DOUBLE
#undef RMF_WRITE_ULONG
#undef RMF_WRITE_LONG
/* -------------------------------------------------------------------- */
/* Write out the color table. */
/* -------------------------------------------------------------------- */
if ( sHeader.nClrTblOffset && sHeader.nClrTblSize )
{
VSIFSeekL( fp, GetFileOffset( sHeader.nClrTblOffset ), SEEK_SET );
VSIFWriteL( pabyColorTable, 1, sHeader.nClrTblSize, fp );
}
/* -------------------------------------------------------------------- */
/* Write out the block table, swap if needed. */
/* -------------------------------------------------------------------- */
VSIFSeekL( fp, GetFileOffset( sHeader.nTileTblOffset ), SEEK_SET );
#ifdef CPL_MSB
GUInt32 *paiTilesSwapped = reinterpret_cast<GUInt32 *>(
CPLMalloc( sHeader.nTileTblSize ) );
if ( !paiTilesSwapped )
return CE_Failure;
memcpy( paiTilesSwapped, paiTiles, sHeader.nTileTblSize );
for ( GUInt32 i = 0; i < sHeader.nTileTblSize / sizeof(GUInt32); i++ )
CPL_SWAP32PTR( paiTilesSwapped + i );
VSIFWriteL( paiTilesSwapped, 1, sHeader.nTileTblSize, fp );
CPLFree( paiTilesSwapped );
#else
VSIFWriteL( paiTiles, 1, sHeader.nTileTblSize, fp );
#endif
bHeaderDirty = FALSE;
return CE_None;
}
/************************************************************************/
/* FlushCache() */
/************************************************************************/
void RMFDataset::FlushCache()
{
GDALDataset::FlushCache();
if ( !bHeaderDirty )
return;
if ( eRMFType == RMFT_MTW )
{
GDALRasterBand *poBand = GetRasterBand(1);
if ( poBand )
{
poBand->ComputeRasterMinMax( FALSE, sHeader.adfElevMinMax );
bHeaderDirty = TRUE;
}
}
WriteHeader();
}
/************************************************************************/
/* Identify() */
/************************************************************************/
int RMFDataset::Identify( GDALOpenInfo *poOpenInfo )
{
if( poOpenInfo->pabyHeader == NULL)
return FALSE;
if( memcmp(poOpenInfo->pabyHeader, RMF_SigRSW, sizeof(RMF_SigRSW)) != 0
&& memcmp(poOpenInfo->pabyHeader, RMF_SigRSW_BE, sizeof(RMF_SigRSW_BE)) != 0
&& memcmp(poOpenInfo->pabyHeader, RMF_SigMTW, sizeof(RMF_SigMTW)) != 0 )
return FALSE;
return TRUE;
}
/************************************************************************/
/* Open() */
/************************************************************************/
GDALDataset *RMFDataset::Open( GDALOpenInfo * poOpenInfo )
{
if ( !Identify(poOpenInfo) )
return NULL;
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
RMFDataset *poDS = new RMFDataset();
if( poOpenInfo->eAccess == GA_ReadOnly )
poDS->fp = VSIFOpenL( poOpenInfo->pszFilename, "rb" );
else
poDS->fp = VSIFOpenL( poOpenInfo->pszFilename, "r+b" );
if ( !poDS->fp )
{
delete poDS;
return NULL;
}
#define RMF_READ_SHORT(ptr, value, offset) \
do { \
if ( poDS->bBigEndian ) \
{ \
(value) = CPL_MSBWORD16(*(GInt16*)((ptr) + (offset))); \
} \
else \
{ \
(value) = CPL_LSBWORD16(*(GInt16*)((ptr) + (offset))); \
} \
} while(0);
#define RMF_READ_ULONG(ptr, value, offset) \
do { \
if ( poDS->bBigEndian ) \
{ \
(value) = CPL_MSBWORD32(*(GUInt32*)((ptr) + (offset))); \
} \
else \
{ \
(value) = CPL_LSBWORD32(*(GUInt32*)((ptr) + (offset))); \
} \
} while(0);
#define RMF_READ_LONG(ptr, value, offset) \
do { \
if ( poDS->bBigEndian ) \
{ \
(value) = CPL_MSBWORD32(*(GInt32*)((ptr) + (offset))); \
} \
else \
{ \
(value) = CPL_LSBWORD32(*(GInt32*)((ptr) + (offset))); \
} \
} while(0);
#define RMF_READ_DOUBLE(ptr, value, offset) \
do { \
(value) = *reinterpret_cast<double*>((ptr) + (offset)); \
if ( poDS->bBigEndian ) \
{ \
CPL_MSBPTR64(&(value)); \
} \
else \
{ \
CPL_LSBPTR64(&(value)); \
} \
} while(0);
/* -------------------------------------------------------------------- */
/* Read the main header. */
/* -------------------------------------------------------------------- */
{
GByte abyHeader[RMF_HEADER_SIZE];
VSIFSeekL( poDS->fp, 0, SEEK_SET );
if( VSIFReadL( abyHeader, 1, sizeof(abyHeader), poDS->fp ) != sizeof(abyHeader) )
{
delete poDS;
return NULL;
}
if ( memcmp(abyHeader, RMF_SigMTW, sizeof(RMF_SigMTW)) == 0 )
poDS->eRMFType = RMFT_MTW;
else if ( memcmp(abyHeader, RMF_SigRSW_BE, sizeof(RMF_SigRSW_BE)) == 0 )
{
poDS->eRMFType = RMFT_RSW;
poDS->bBigEndian = TRUE;
}
else
poDS->eRMFType = RMFT_RSW;
memcpy( poDS->sHeader.bySignature, abyHeader, RMF_SIGNATURE_SIZE );
RMF_READ_ULONG( abyHeader, poDS->sHeader.iVersion, 4 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nSize, 8 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nOvrOffset, 12 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.iUserID, 16 );
memcpy( poDS->sHeader.byName, abyHeader + 20,
sizeof(poDS->sHeader.byName) );
poDS->sHeader.byName[sizeof(poDS->sHeader.byName) - 1] = '\0';
RMF_READ_ULONG( abyHeader, poDS->sHeader.nBitDepth, 52 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nHeight, 56 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nWidth, 60 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nXTiles, 64 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nYTiles, 68 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nTileHeight, 72 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nTileWidth, 76 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nLastTileHeight, 80 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nLastTileWidth, 84 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nROIOffset, 88 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nROISize, 92 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nClrTblOffset, 96 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nClrTblSize, 100 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nTileTblOffset, 104 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nTileTblSize, 108 );
RMF_READ_LONG( abyHeader, poDS->sHeader.iMapType, 124 );
RMF_READ_LONG( abyHeader, poDS->sHeader.iProjection, 128 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfScale, 136 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfResolution, 144 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfPixelSize, 152 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfLLY, 160 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfLLX, 168 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfStdP1, 176 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfStdP2, 184 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfCenterLong, 192 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.dfCenterLat, 200 );
poDS->sHeader.iCompression = *(abyHeader + 208);
poDS->sHeader.iMaskType = *(abyHeader + 209);
poDS->sHeader.iMaskStep = *(abyHeader + 210);
poDS->sHeader.iFrameFlag = *(abyHeader + 211);
RMF_READ_ULONG( abyHeader, poDS->sHeader.nFlagsTblOffset, 212 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nFlagsTblSize, 216 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nFileSize0, 220 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nFileSize1, 224 );
poDS->sHeader.iUnknown = *(abyHeader + 228);
poDS->sHeader.iGeorefFlag = *(abyHeader + 244);
poDS->sHeader.iInverse = *(abyHeader + 245);
memcpy( poDS->sHeader.abyInvisibleColors,
abyHeader + 248, sizeof(poDS->sHeader.abyInvisibleColors) );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.adfElevMinMax[0], 280 );
RMF_READ_DOUBLE( abyHeader, poDS->sHeader.adfElevMinMax[1], 288 );
if (poDS->sHeader.nBitDepth == 8)
{
poDS->sHeader.dfNoData = *reinterpret_cast<char *>(abyHeader + 296);
}
else if (poDS->sHeader.nBitDepth == 16)
{
RMF_READ_SHORT(abyHeader, poDS->sHeader.dfNoData, 296);
}
else if (poDS->sHeader.nBitDepth == 32)
{
RMF_READ_LONG(abyHeader, poDS->sHeader.dfNoData, 296);
}
else if (poDS->sHeader.nBitDepth == 64)
{
RMF_READ_DOUBLE(abyHeader, poDS->sHeader.dfNoData, 296);
}
RMF_READ_ULONG( abyHeader, poDS->sHeader.iElevationUnit, 304 );
poDS->sHeader.iElevationType = *(abyHeader + 308);
RMF_READ_ULONG( abyHeader, poDS->sHeader.nExtHdrOffset, 312 );
RMF_READ_ULONG( abyHeader, poDS->sHeader.nExtHdrSize, 316 );
}
/* -------------------------------------------------------------------- */
/* Read the extended header. */
/* -------------------------------------------------------------------- */
if ( poDS->sHeader.nExtHdrOffset && poDS->sHeader.nExtHdrSize )
{
/* coverity[tainted_data] */
GByte *pabyExtHeader = reinterpret_cast<GByte *>(
VSICalloc( poDS->sHeader.nExtHdrSize, 1 ) );
if (pabyExtHeader == NULL)
{
delete poDS;
return NULL;
}
VSIFSeekL( poDS->fp, poDS->GetFileOffset( poDS->sHeader.nExtHdrOffset ), SEEK_SET );
VSIFReadL( pabyExtHeader, 1, poDS->sHeader.nExtHdrSize, poDS->fp );
RMF_READ_LONG( pabyExtHeader, poDS->sExtHeader.nEllipsoid, 24 );
RMF_READ_LONG( pabyExtHeader, poDS->sExtHeader.nDatum, 32 );
RMF_READ_LONG( pabyExtHeader, poDS->sExtHeader.nZone, 36 );
CPLFree( pabyExtHeader );
}
#undef RMF_READ_DOUBLE
#undef RMF_READ_LONG
#undef RMF_READ_ULONG
CPLDebug( "RMF", "Version %d", poDS->sHeader.iVersion );
#ifdef DEBUG
CPLDebug( "RMF", "%s image has width %d, height %d, bit depth %d, "
"compression scheme %d, %s, nodata %f",
(poDS->eRMFType == RMFT_MTW) ? "MTW" : "RSW",
poDS->sHeader.nWidth, poDS->sHeader.nHeight,
poDS->sHeader.nBitDepth, poDS->sHeader.iCompression,
poDS->bBigEndian ? "big endian" : "little endian",
poDS->sHeader.dfNoData );
CPLDebug( "RMF", "Size %d, offset to overview %#lx, user ID %d, "
"ROI offset %#lx, ROI size %d",
poDS->sHeader.nSize,
static_cast<unsigned long>( poDS->sHeader.nOvrOffset ),
poDS->sHeader.iUserID,
static_cast<unsigned long>( poDS->sHeader.nROIOffset ),
poDS->sHeader.nROISize );
CPLDebug( "RMF", "Map type %d, projection %d, scale %f, resolution %f, ",
poDS->sHeader.iMapType, poDS->sHeader.iProjection,
poDS->sHeader.dfScale, poDS->sHeader.dfResolution );
CPLDebug( "RMF", "Georeferencing: pixel size %f, LLX %f, LLY %f",
poDS->sHeader.dfPixelSize,
poDS->sHeader.dfLLX, poDS->sHeader.dfLLY );
if ( poDS->sHeader.nROIOffset && poDS->sHeader.nROISize )
{
GInt32 nValue;
CPLDebug( "RMF", "ROI coordinates:" );
/* coverity[tainted_data] */
for ( GUInt32 i = 0; i < poDS->sHeader.nROISize; i += sizeof(nValue) )
{
if( VSIFSeekL( poDS->fp,
poDS->GetFileOffset( poDS->sHeader.nROIOffset + i ),
SEEK_SET ) != 0 ||
VSIFReadL( &nValue, 1, sizeof(nValue), poDS->fp ) != sizeof(nValue) )
{
delete poDS;
return NULL;
}
CPLDebug( "RMF", "%d", nValue );
}
}
#endif
/* -------------------------------------------------------------------- */
/* Read array of blocks offsets/sizes. */
/* -------------------------------------------------------------------- */
if ( VSIFSeekL( poDS->fp,
poDS->GetFileOffset( poDS->sHeader.nTileTblOffset ),
SEEK_SET ) < 0)
{
delete poDS;
return NULL;
}
/* coverity[tainted_data] */
poDS->paiTiles = reinterpret_cast<GUInt32 *>(
VSIMalloc( poDS->sHeader.nTileTblSize ) );
if ( !poDS->paiTiles )
{
delete poDS;
return NULL;
}
if ( VSIFReadL( poDS->paiTiles, 1, poDS->sHeader.nTileTblSize,
poDS->fp ) < poDS->sHeader.nTileTblSize )
{
CPLDebug( "RMF", "Can't read tiles offsets/sizes table." );
delete poDS;
return NULL;
}
#ifdef CPL_MSB
if ( !poDS->bBigEndian )
{
for ( GUInt32 i = 0; i < poDS->sHeader.nTileTblSize / sizeof(GUInt32); i++ )
CPL_SWAP32PTR( poDS->paiTiles + i );
}
#else
if ( poDS->bBigEndian )
{
for ( GUInt32 i = 0; i < poDS->sHeader.nTileTblSize / sizeof(GUInt32); i++ )
CPL_SWAP32PTR( poDS->paiTiles + i );
}
#endif
#ifdef DEBUG
CPLDebug( "RMF", "List of block offsets/sizes:" );
for ( GUInt32 i = 0; i < poDS->sHeader.nTileTblSize / sizeof(GUInt32); i += 2 )
{
CPLDebug( "RMF", " %d / %d",
poDS->paiTiles[i], poDS->paiTiles[i + 1] );
}
#endif
/* -------------------------------------------------------------------- */
/* Set up essential image parameters. */
/* -------------------------------------------------------------------- */
GDALDataType eType = GDT_Byte;
poDS->nRasterXSize = poDS->sHeader.nWidth;
poDS->nRasterYSize = poDS->sHeader.nHeight;
if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize))
{
delete poDS;
return NULL;
}
if ( poDS->eRMFType == RMFT_RSW )
{
switch ( poDS->sHeader.nBitDepth )
{
case 32:
case 24:
case 16:
poDS->nBands = 3;
break;
case 1:
case 4:
case 8:
{
// Allocate memory for colour table and read it
poDS->nColorTableSize = 1 << poDS->sHeader.nBitDepth;
if ( poDS->nColorTableSize * 4 > poDS->sHeader.nClrTblSize )
{
CPLDebug( "RMF",
"Wrong color table size. Expected %d, got %d.",
poDS->nColorTableSize * 4,
poDS->sHeader.nClrTblSize );
delete poDS;
return NULL;
}
/* coverity[tainted_data] */
poDS->pabyColorTable = reinterpret_cast<GByte *>(
VSIMalloc( poDS->sHeader.nClrTblSize ) );
if (poDS->pabyColorTable == NULL)
{
CPLDebug( "RMF", "Can't allocate color table." );
delete poDS;
return NULL;
}
if ( VSIFSeekL( poDS->fp,
poDS->GetFileOffset( poDS->sHeader.nClrTblOffset ),
SEEK_SET ) < 0 )
{
CPLDebug( "RMF", "Can't seek to color table location." );
delete poDS;
return NULL;
}
if ( VSIFReadL( poDS->pabyColorTable, 1,
poDS->sHeader.nClrTblSize, poDS->fp )
< poDS->sHeader.nClrTblSize )
{
CPLDebug( "RMF", "Can't read color table." );
delete poDS;
return NULL;
}
GDALColorEntry oEntry;
poDS->poColorTable = new GDALColorTable();
for( GUInt32 i = 0; i < poDS->nColorTableSize; i++ )
{
oEntry.c1 = poDS->pabyColorTable[i * 4]; // Red
oEntry.c2 = poDS->pabyColorTable[i * 4 + 1]; // Green
oEntry.c3 = poDS->pabyColorTable[i * 4 + 2]; // Blue
oEntry.c4 = 255; // Alpha
poDS->poColorTable->SetColorEntry( i, &oEntry );
}
}
poDS->nBands = 1;
break;
default:
break;
}
eType = GDT_Byte;
}
else
{
poDS->nBands = 1;
if ( poDS->sHeader.nBitDepth == 8 )
eType = GDT_Byte;
else if ( poDS->sHeader.nBitDepth == 16 )
eType = GDT_Int16;
else if ( poDS->sHeader.nBitDepth == 32 )
eType = GDT_Int32;
else if ( poDS->sHeader.nBitDepth == 64 )
eType = GDT_Float64;
}
if (poDS->sHeader.nTileWidth == 0 || poDS->sHeader.nTileWidth > INT_MAX ||
poDS->sHeader.nTileHeight == 0 || poDS->sHeader.nTileHeight > INT_MAX)
{
CPLDebug ("RMF", "Invalid tile dimension : %u x %u",
poDS->sHeader.nTileWidth, poDS->sHeader.nTileHeight);
delete poDS;
return NULL;
}
const int nDataSize = GDALGetDataTypeSize( eType ) / 8;
const int nBlockXSize = static_cast<int>(poDS->sHeader.nTileWidth);
const int nBlockYSize = static_cast<int>(poDS->sHeader.nTileHeight);
if( nDataSize == 0 ||
nBlockXSize > INT_MAX / nBlockYSize ||
nBlockYSize > INT_MAX / nDataSize ||
nBlockXSize > INT_MAX / (nBlockYSize * nDataSize) )
{
CPLDebug ("RMF", "Too big raster / tile dimension");
delete poDS;
return NULL;
}
poDS->nXTiles = DIV_ROUND_UP( poDS->nRasterXSize, nBlockXSize );
poDS->nYTiles = DIV_ROUND_UP( poDS->nRasterYSize, nBlockYSize );
#ifdef DEBUG
CPLDebug( "RMF", "Image is %d tiles wide, %d tiles long",
poDS->nXTiles, poDS->nYTiles );
#endif
/* -------------------------------------------------------------------- */
/* Choose compression scheme. */
/* XXX: The DEM compression method seems to be only applicable */
/* to Int32 data. */
/* -------------------------------------------------------------------- */
if ( poDS->sHeader.iCompression == RMF_COMPRESSION_LZW )
poDS->Decompress = &LZWDecompress;
else if ( poDS->sHeader.iCompression == RMF_COMPRESSION_DEM
&& eType == GDT_Int32 )
poDS->Decompress = &DEMDecompress;
else // No compression
poDS->Decompress = NULL;
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
for( int iBand = 1; iBand <= poDS->nBands; iBand++ )
poDS->SetBand( iBand, new RMFRasterBand( poDS, iBand, eType ) );
/* -------------------------------------------------------------------- */
/* Set up projection. */
/* */
/* XXX: If projection value is not specified, but image still have */
/* georeferencing information, assume Gauss-Kruger projection. */
/* -------------------------------------------------------------------- */
if( poDS->sHeader.iProjection > 0 ||
(poDS->sHeader.dfPixelSize != 0.0 &&
poDS->sHeader.dfLLX != 0.0 &&
poDS->sHeader.dfLLY != 0.0) )
{
OGRSpatialReference oSRS;
GInt32 nProj =
(poDS->sHeader.iProjection) ? poDS->sHeader.iProjection : 1;
double padfPrjParams[8];
padfPrjParams[0] = poDS->sHeader.dfStdP1;
padfPrjParams[1] = poDS->sHeader.dfStdP2;
padfPrjParams[2] = poDS->sHeader.dfCenterLat;
padfPrjParams[3] = poDS->sHeader.dfCenterLong;
padfPrjParams[4] = 1.0;
padfPrjParams[5] = 0.0;
padfPrjParams[6] = 0.0;
// XXX: Compute zone number for Gauss-Kruger (Transverse Mercator)
// projection if it is not specified.
if ( nProj == 1L && poDS->sHeader.dfCenterLong == 0.0 )
{
if ( poDS->sExtHeader.nZone == 0 )
{
double centerXCoord = poDS->sHeader.dfLLX +
(poDS->nRasterXSize * poDS->sHeader.dfPixelSize / 2.0);
padfPrjParams[7] =
floor((centerXCoord - 500000.0 ) / 1000000.0);
}
else
padfPrjParams[7] = poDS->sExtHeader.nZone;
}
else
padfPrjParams[7] = 0.0;
oSRS.importFromPanorama( nProj, poDS->sExtHeader.nDatum,
poDS->sExtHeader.nEllipsoid, padfPrjParams );
if ( poDS->pszProjection )
CPLFree( poDS->pszProjection );
oSRS.exportToWkt( &poDS->pszProjection );
}
/* -------------------------------------------------------------------- */
/* Set up georeferencing. */
/* -------------------------------------------------------------------- */
if ( (poDS->eRMFType == RMFT_RSW && poDS->sHeader.iGeorefFlag) ||
(poDS->eRMFType == RMFT_MTW && poDS->sHeader.dfPixelSize != 0.0) )
{
poDS->adfGeoTransform[0] = poDS->sHeader.dfLLX;
poDS->adfGeoTransform[3] = poDS->sHeader.dfLLY
+ poDS->nRasterYSize * poDS->sHeader.dfPixelSize;
poDS->adfGeoTransform[1] = poDS->sHeader.dfPixelSize;
poDS->adfGeoTransform[5] = - poDS->sHeader.dfPixelSize;
poDS->adfGeoTransform[2] = 0.0;
poDS->adfGeoTransform[4] = 0.0;
}
/* -------------------------------------------------------------------- */
/* Set units. */
/* -------------------------------------------------------------------- */
if ( poDS->eRMFType == RMFT_MTW )
{
CPLFree(poDS->pszUnitType);
switch ( poDS->sHeader.iElevationUnit )
{
case 0:
poDS->pszUnitType = CPLStrdup( RMF_UnitsM );
break;
case 1:
poDS->pszUnitType = CPLStrdup( RMF_UnitsCM );
break;
case 2:
poDS->pszUnitType = CPLStrdup( RMF_UnitsDM );
break;
case 3:
poDS->pszUnitType = CPLStrdup( RMF_UnitsMM );
break;
default:
poDS->pszUnitType = CPLStrdup( RMF_UnitsEmpty );
break;
}
}
/* -------------------------------------------------------------------- */
/* Report some other dataset related information. */
/* -------------------------------------------------------------------- */
if ( poDS->eRMFType == RMFT_MTW )
{
char szTemp[256];
snprintf( szTemp, sizeof(szTemp), "%g", poDS->sHeader.adfElevMinMax[0] );
poDS->SetMetadataItem( "ELEVATION_MINIMUM", szTemp );
snprintf( szTemp, sizeof(szTemp), "%g", poDS->sHeader.adfElevMinMax[1] );
poDS->SetMetadataItem( "ELEVATION_MAXIMUM", szTemp );
poDS->SetMetadataItem( "ELEVATION_UNITS", poDS->pszUnitType );
snprintf( szTemp, sizeof(szTemp), "%d", poDS->sHeader.iElevationType );
poDS->SetMetadataItem( "ELEVATION_TYPE", szTemp );
}
/* -------------------------------------------------------------------- */
/* Check for overviews. */
/* -------------------------------------------------------------------- */
poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename );
return( poDS );
}
/************************************************************************/
/* Create() */
/************************************************************************/
GDALDataset *RMFDataset::Create( const char * pszFilename,
int nXSize, int nYSize, int nBands,
GDALDataType eType, char **papszParmList )
{
if ( nBands != 1 && nBands != 3 )
{
CPLError( CE_Failure, CPLE_NotSupported,
"RMF driver doesn't support %d bands. Must be 1 or 3.\n",
nBands );
return NULL;
}
if ( nBands == 1
&& eType != GDT_Byte
&& eType != GDT_Int16
&& eType != GDT_Int32
&& eType != GDT_Float64 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Attempt to create RMF dataset with an illegal data type (%s),\n"
"only Byte, Int16, Int32 and Float64 types supported "
"by the format for single-band images.\n",
GDALGetDataTypeName(eType) );
return NULL;
}
if ( nBands == 3 && eType != GDT_Byte )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Attempt to create RMF dataset with an illegal data type (%s),\n"
"only Byte type supported by the format for three-band images.\n",
GDALGetDataTypeName(eType) );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create the dataset. */
/* -------------------------------------------------------------------- */
RMFDataset *poDS = new RMFDataset();
poDS->fp = VSIFOpenL( pszFilename, "w+b" );
if( poDS->fp == NULL )
{
CPLError( CE_Failure, CPLE_OpenFailed, "Unable to create file %s.\n",
pszFilename );
delete poDS;
return NULL;
}
poDS->pszFilename = pszFilename;
/* -------------------------------------------------------------------- */
/* Fill the RMFHeader */
/* -------------------------------------------------------------------- */
GUInt32 nBlockXSize =
( nXSize < RMF_DEFAULT_BLOCKXSIZE ) ? nXSize : RMF_DEFAULT_BLOCKXSIZE;
GUInt32 nBlockYSize =
( nYSize < RMF_DEFAULT_BLOCKYSIZE ) ? nYSize : RMF_DEFAULT_BLOCKYSIZE;
if ( CSLFetchBoolean( papszParmList, "MTW", FALSE) )
poDS->eRMFType = RMFT_MTW;
else
poDS->eRMFType = RMFT_RSW;
if ( poDS->eRMFType == RMFT_MTW )
memcpy( poDS->sHeader.bySignature, RMF_SigMTW, RMF_SIGNATURE_SIZE );
else
memcpy( poDS->sHeader.bySignature, RMF_SigRSW, RMF_SIGNATURE_SIZE );
const char *pszRMFHUGE = CSLFetchNameValue(papszParmList, "RMFHUGE");
GUInt32 iVersion = RMF_VERSION;
if( pszRMFHUGE == NULL )
pszRMFHUGE = "NO";// Keep old behavior by default
if( EQUAL(pszRMFHUGE,"NO") )
{
iVersion = RMF_VERSION;
}
else if( EQUAL(pszRMFHUGE,"YES") )
{
iVersion = RMF_VERSION_HUGE;
}
else if( EQUAL(pszRMFHUGE,"IF_SAFER") )
{
double dfImageSize = ((double)nXSize) *
((double)nYSize) *
((double)nBands) *
((double)(GDALGetDataTypeSize(eType)/8));
if( dfImageSize > 3.0*1024.0*1024.0*1024.0 )
{
iVersion = RMF_VERSION_HUGE;
}
else
{
iVersion = RMF_VERSION;
}
}
CPLDebug( "RMF", "Version %d", iVersion );
poDS->sHeader.iVersion = iVersion;
poDS->sHeader.nOvrOffset = 0x00;
poDS->sHeader.iUserID = 0x00;
memset( poDS->sHeader.byName, 0, sizeof(poDS->sHeader.byName) );
poDS->sHeader.nBitDepth = GDALGetDataTypeSize( eType ) * nBands;
poDS->sHeader.nHeight = nYSize;
poDS->sHeader.nWidth = nXSize;
const char *pszValue = CSLFetchNameValue(papszParmList,"BLOCKXSIZE");
if( pszValue != NULL )
nBlockXSize = atoi( pszValue );
if( nBlockXSize <= 0 )
nBlockXSize = RMF_DEFAULT_BLOCKXSIZE;
pszValue = CSLFetchNameValue(papszParmList,"BLOCKYSIZE");
if( pszValue != NULL )
nBlockYSize = atoi( pszValue );
if( nBlockYSize <= 0 )
nBlockYSize = RMF_DEFAULT_BLOCKXSIZE;
poDS->sHeader.nTileWidth = nBlockXSize;
poDS->sHeader.nTileHeight = nBlockYSize;
poDS->nXTiles = poDS->sHeader.nXTiles =
( nXSize + poDS->sHeader.nTileWidth - 1 ) / poDS->sHeader.nTileWidth;
poDS->nYTiles = poDS->sHeader.nYTiles =
( nYSize + poDS->sHeader.nTileHeight - 1 ) / poDS->sHeader.nTileHeight;
poDS->sHeader.nLastTileHeight = nYSize % poDS->sHeader.nTileHeight;
if ( !poDS->sHeader.nLastTileHeight )
poDS->sHeader.nLastTileHeight = poDS->sHeader.nTileHeight;
poDS->sHeader.nLastTileWidth = nXSize % poDS->sHeader.nTileWidth;
if ( !poDS->sHeader.nLastTileWidth )
poDS->sHeader.nLastTileWidth = poDS->sHeader.nTileWidth;
poDS->sHeader.nROIOffset = 0x00;
poDS->sHeader.nROISize = 0x00;
vsi_l_offset nCurPtr = RMF_HEADER_SIZE;
// Extended header
poDS->sHeader.nExtHdrOffset = poDS->GetRMFOffset( nCurPtr, &nCurPtr );
poDS->sHeader.nExtHdrSize = RMF_EXT_HEADER_SIZE;
nCurPtr += poDS->sHeader.nExtHdrSize;
// Color table
if ( poDS->eRMFType == RMFT_RSW && nBands == 1 )
{
if ( poDS->sHeader.nBitDepth > 8 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Cannot create color table of RSW with nBitDepth = %d. Retry with MTW ?",
poDS->sHeader.nBitDepth );
delete poDS;
return NULL;
}
poDS->sHeader.nClrTblOffset = poDS->GetRMFOffset( nCurPtr, &nCurPtr );
poDS->nColorTableSize = 1 << poDS->sHeader.nBitDepth;
poDS->sHeader.nClrTblSize = poDS->nColorTableSize * 4;
poDS->pabyColorTable = reinterpret_cast<GByte *>(
VSI_MALLOC_VERBOSE( poDS->sHeader.nClrTblSize ) );
if (poDS->pabyColorTable == NULL)
{
delete poDS;
return NULL;
}
for( GUInt32 i = 0; i < poDS->nColorTableSize; i++ )
{
poDS->pabyColorTable[i * 4] =
poDS->pabyColorTable[i * 4 + 1] =
poDS->pabyColorTable[i * 4 + 2] = (GByte) i;
poDS->pabyColorTable[i * 4 + 3] = 0;
}
nCurPtr += poDS->sHeader.nClrTblSize;
}
else
{
poDS->sHeader.nClrTblOffset = 0x00;
poDS->sHeader.nClrTblSize = 0x00;
}
// Blocks table
poDS->sHeader.nTileTblOffset = poDS->GetRMFOffset( nCurPtr, &nCurPtr );
poDS->sHeader.nTileTblSize =
poDS->sHeader.nXTiles * poDS->sHeader.nYTiles * 4 * 2;
poDS->paiTiles = reinterpret_cast<GUInt32 *>(
CPLCalloc( poDS->sHeader.nTileTblSize, 1 ) );
/*nCurPtr += poDS->sHeader.nTileTblSize;*/
const GUInt32 nTileSize = poDS->sHeader.nTileWidth * poDS->sHeader.nTileHeight
* GDALGetDataTypeSize( eType ) / 8;
poDS->sHeader.nSize =
poDS->paiTiles[poDS->sHeader.nTileTblSize / 4 - 2] + nTileSize;
// Elevation units
if ( EQUAL(poDS->pszUnitType, RMF_UnitsM) )
poDS->sHeader.iElevationUnit = 0;
else if ( EQUAL(poDS->pszUnitType, RMF_UnitsCM) )
poDS->sHeader.iElevationUnit = 1;
else if ( EQUAL(poDS->pszUnitType, RMF_UnitsDM) )
poDS->sHeader.iElevationUnit = 2;
else if ( EQUAL(poDS->pszUnitType, RMF_UnitsMM) )
poDS->sHeader.iElevationUnit = 3;
else
poDS->sHeader.iElevationUnit = 0;
poDS->sHeader.iMapType = -1;
poDS->sHeader.iProjection = -1;
poDS->sHeader.dfScale = 10000.0;
poDS->sHeader.dfResolution = 100.0;
poDS->sHeader.iCompression = 0;
poDS->sHeader.iMaskType = 0;
poDS->sHeader.iMaskStep = 0;
poDS->sHeader.iFrameFlag = 0;
poDS->sHeader.nFlagsTblOffset = 0x00;
poDS->sHeader.nFlagsTblSize = 0x00;
poDS->sHeader.nFileSize0 = 0x00;
poDS->sHeader.nFileSize1 = 0x00;
poDS->sHeader.iUnknown = 0;
poDS->sHeader.iGeorefFlag = 0;
poDS->sHeader.iInverse = 0;
memset( poDS->sHeader.abyInvisibleColors, 0,
sizeof(poDS->sHeader.abyInvisibleColors) );
poDS->sHeader.adfElevMinMax[0] = 0.0;
poDS->sHeader.adfElevMinMax[1] = 0.0;
poDS->sHeader.dfNoData = 0.0;
poDS->sHeader.iElevationType = 0;
poDS->nRasterXSize = nXSize;
poDS->nRasterYSize = nYSize;
poDS->eAccess = GA_Update;
poDS->nBands = nBands;
poDS->WriteHeader();
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
for( int iBand = 1; iBand <= poDS->nBands; iBand++ )
poDS->SetBand( iBand, new RMFRasterBand( poDS, iBand, eType ) );
return reinterpret_cast<GDALDataset *>( poDS );
}
//GIS Panorama 11 was introduced new format for huge files (greater than 3 Gb)
vsi_l_offset RMFDataset::GetFileOffset( GUInt32 iRMFOffset )
{
if ( sHeader.iVersion >= RMF_VERSION_HUGE )
{
return ((vsi_l_offset)iRMFOffset) * RMF_HUGE_OFFSET_FACTOR;
}
else
{
return (vsi_l_offset)iRMFOffset;
}
}
GUInt32 RMFDataset::GetRMFOffset( vsi_l_offset nFileOffset, vsi_l_offset* pnNewFileOffset )
{
if ( sHeader.iVersion >= RMF_VERSION_HUGE )
{
//Round offset to next RMF_HUGE_OFFSET_FACTOR
GUInt32 iRMFOffset = (GUInt32) ((nFileOffset + (RMF_HUGE_OFFSET_FACTOR-1) ) / RMF_HUGE_OFFSET_FACTOR );
if ( pnNewFileOffset != NULL )
{
*pnNewFileOffset = GetFileOffset( iRMFOffset );
}
return iRMFOffset;
}
else
{
if ( pnNewFileOffset != NULL )
{
*pnNewFileOffset = nFileOffset;
}
return (GUInt32)nFileOffset;
}
}
/************************************************************************/
/* GDALRegister_RMF() */
/************************************************************************/
void GDALRegister_RMF()
{
if( GDALGetDriverByName( "RMF" ) != NULL )
return;
GDALDriver *poDriver = new GDALDriver();
poDriver->SetDescription( "RMF" );
poDriver->SetMetadataItem( GDAL_DCAP_RASTER, "YES" );
poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "Raster Matrix Format" );
poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, "frmt_rmf.html" );
poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "rsw" );
poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES,
"Byte Int16 Int32 Float64" );
poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST,
"<CreationOptionList>"
" <Option name='MTW' type='boolean' description='Create MTW DEM matrix'/>"
" <Option name='BLOCKXSIZE' type='int' description='Tile Width'/>"
" <Option name='BLOCKYSIZE' type='int' description='Tile Height'/>"
" <Option name='RMFHUGE' type='string-select' description='Creation of huge RMF file (Supported by GIS Panorama since v11)'>"
" <Value>NO</Value>"
" <Value>YES</Value>"
" <Value>IF_SAFER</Value>"
" </Option>"
"</CreationOptionList>" );
poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );
poDriver->pfnIdentify = RMFDataset::Identify;
poDriver->pfnOpen = RMFDataset::Open;
poDriver->pfnCreate = RMFDataset::Create;
GetGDALDriverManager()->RegisterDriver( poDriver );
}
|
/*******************************************************************************
* Copyright (c) 2015-2019 Skymind, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/
//
// @author raver119@gmail.com
//
#include <op_boilerplate.h>
#if NOT_EXCLUDED(OP_bits_hamming_distance)
#include <ops/declarable/CustomOperations.h>
#include <ops/declarable/helpers/helpers.h>
#include <ops/declarable/helpers/hamming.h>
namespace nd4j {
namespace ops {
CUSTOM_OP_IMPL(bits_hamming_distance, 2, 1, true, 0, 0) {
auto x = INPUT_VARIABLE(0);
auto y = INPUT_VARIABLE(1);
auto output = OUTPUT_VARIABLE(0);
REQUIRE_TRUE(x->lengthOf() == y->lengthOf(), 0, "bits_hamming_distance: both arguments must have the same length");
REQUIRE_TRUE(x->dataType() == y->dataType(), 0, "bits_hamming_distance: both arguments must have the same data type");
helpers::hamming(block.launchContext(), *x, *y, *output);
return Status::OK();
}
DECLARE_SHAPE_FN(bits_hamming_distance) {
return SHAPELIST(ConstantShapeHelper::getInstance()->scalarShapeInfo(nd4j::DataType::INT64));
}
DECLARE_TYPES(bits_hamming_distance) {
getOpDescriptor()
->setAllowedInputTypes(0, {ALL_INTS})
->setAllowedInputTypes(1, {ALL_INTS})
->setAllowedOutputTypes(0, {ALL_INDICES})
->setSameMode(true);
}
}
}
#endif
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Note: any code in this file MUST be async-signal safe.
#include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
#include <stddef.h>
#include <stdint.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "build/build_config.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
#include "sandbox/linux/seccomp-bpf/syscall.h"
#include "sandbox/linux/services/syscall_wrappers.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
#if defined(__mips__)
// __NR_Linux, is defined in <asm/unistd.h>.
#include <asm/unistd.h>
#endif
#define SECCOMP_MESSAGE_COMMON_CONTENT "seccomp-bpf failure"
#define SECCOMP_MESSAGE_CLONE_CONTENT "clone() failure"
#define SECCOMP_MESSAGE_PRCTL_CONTENT "prctl() failure"
#define SECCOMP_MESSAGE_IOCTL_CONTENT "ioctl() failure"
#define SECCOMP_MESSAGE_KILL_CONTENT "(tg)kill() failure"
#define SECCOMP_MESSAGE_FUTEX_CONTENT "futex() failure"
namespace {
inline bool IsArchitectureX86_64() {
#if defined(__x86_64__)
return true;
#else
return false;
#endif
}
// Write |error_message| to stderr. Similar to RawLog(), but a bit more careful
// about async-signal safety. |size| is the size to write and should typically
// not include a terminating \0.
void WriteToStdErr(const char* error_message, size_t size) {
while (size > 0) {
// TODO(jln): query the current policy to check if send() is available and
// use it to perform a non-blocking write.
const int ret = HANDLE_EINTR(
sandbox::sys_write(STDERR_FILENO, error_message, size));
// We can't handle any type of error here.
if (ret <= 0 || static_cast<size_t>(ret) > size) break;
size -= ret;
error_message += ret;
}
}
// Invalid syscall values are truncated to zero.
// On architectures where base value is zero (Intel and Arm),
// syscall number is the same as offset from base.
// This function returns values between 0 and 1023 on all architectures.
// On architectures where base value is different than zero (currently only
// Mips), we are truncating valid syscall values to offset from base.
uint32_t SyscallNumberToOffsetFromBase(uint32_t sysno) {
#if defined(__mips__)
// On MIPS syscall numbers are in different range than on x86 and ARM.
// Valid MIPS O32 ABI syscall __NR_syscall will be truncated to zero for
// simplicity.
sysno = sysno - __NR_Linux;
#endif
if (sysno >= 1024)
sysno = 0;
return sysno;
}
// Print a seccomp-bpf failure to handle |sysno| to stderr in an
// async-signal safe way.
void PrintSyscallError(uint32_t sysno) {
if (sysno >= 1024)
sysno = 0;
// TODO(markus): replace with async-signal safe snprintf when available.
const size_t kNumDigits = 4;
char sysno_base10[kNumDigits];
uint32_t rem = sysno;
uint32_t mod = 0;
for (int i = kNumDigits - 1; i >= 0; i--) {
mod = rem % 10;
rem /= 10;
sysno_base10[i] = '0' + mod;
}
#if defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32)
static const char kSeccompErrorPrefix[] = __FILE__
":**CRASHING**:" SECCOMP_MESSAGE_COMMON_CONTENT " in syscall 4000 + ";
#else
static const char kSeccompErrorPrefix[] =
__FILE__":**CRASHING**:" SECCOMP_MESSAGE_COMMON_CONTENT " in syscall ";
#endif
static const char kSeccompErrorPostfix[] = "\n";
WriteToStdErr(kSeccompErrorPrefix, sizeof(kSeccompErrorPrefix) - 1);
WriteToStdErr(sysno_base10, sizeof(sysno_base10));
WriteToStdErr(kSeccompErrorPostfix, sizeof(kSeccompErrorPostfix) - 1);
}
} // namespace
namespace sandbox {
intptr_t CrashSIGSYS_Handler(const struct arch_seccomp_data& args, void* aux) {
uint32_t syscall = SyscallNumberToOffsetFromBase(args.nr);
PrintSyscallError(syscall);
// Encode 8-bits of the 1st two arguments too, so we can discern which socket
// type, which fcntl, ... etc., without being likely to hit a mapped
// address.
// Do not encode more bits here without thinking about increasing the
// likelihood of collision with mapped pages.
syscall |= ((args.args[0] & 0xffUL) << 12);
syscall |= ((args.args[1] & 0xffUL) << 20);
// Purposefully dereference the syscall as an address so it'll show up very
// clearly and easily in crash dumps.
volatile char* addr = reinterpret_cast<volatile char*>(syscall);
*addr = '\0';
// In case we hit a mapped address, hit the null page with just the syscall,
// for paranoia.
syscall &= 0xfffUL;
addr = reinterpret_cast<volatile char*>(syscall);
*addr = '\0';
for (;;)
_exit(1);
}
// TODO(jln): refactor the reporting functions.
intptr_t SIGSYSCloneFailure(const struct arch_seccomp_data& args, void* aux) {
static const char kSeccompCloneError[] =
__FILE__":**CRASHING**:" SECCOMP_MESSAGE_CLONE_CONTENT "\n";
WriteToStdErr(kSeccompCloneError, sizeof(kSeccompCloneError) - 1);
// "flags" is the first argument in the kernel's clone().
// Mark as volatile to be able to find the value on the stack in a minidump.
volatile uint64_t clone_flags = args.args[0];
volatile char* addr;
if (IsArchitectureX86_64()) {
addr = reinterpret_cast<volatile char*>(clone_flags & 0xFFFFFF);
*addr = '\0';
}
// Hit the NULL page if this fails to fault.
addr = reinterpret_cast<volatile char*>(clone_flags & 0xFFF);
*addr = '\0';
for (;;)
_exit(1);
}
intptr_t SIGSYSPrctlFailure(const struct arch_seccomp_data& args,
void* /* aux */) {
static const char kSeccompPrctlError[] =
__FILE__":**CRASHING**:" SECCOMP_MESSAGE_PRCTL_CONTENT "\n";
WriteToStdErr(kSeccompPrctlError, sizeof(kSeccompPrctlError) - 1);
// Mark as volatile to be able to find the value on the stack in a minidump.
volatile uint64_t option = args.args[0];
volatile char* addr =
reinterpret_cast<volatile char*>(option & 0xFFF);
*addr = '\0';
for (;;)
_exit(1);
}
intptr_t SIGSYSIoctlFailure(const struct arch_seccomp_data& args,
void* /* aux */) {
static const char kSeccompIoctlError[] =
__FILE__":**CRASHING**:" SECCOMP_MESSAGE_IOCTL_CONTENT "\n";
WriteToStdErr(kSeccompIoctlError, sizeof(kSeccompIoctlError) - 1);
// Make "request" volatile so that we can see it on the stack in a minidump.
volatile uint64_t request = args.args[1];
volatile char* addr = reinterpret_cast<volatile char*>(request & 0xFFFF);
*addr = '\0';
// Hit the NULL page if this fails.
addr = reinterpret_cast<volatile char*>(request & 0xFFF);
*addr = '\0';
for (;;)
_exit(1);
}
intptr_t SIGSYSKillFailure(const struct arch_seccomp_data& args,
void* /* aux */) {
static const char kSeccompKillError[] =
__FILE__":**CRASHING**:" SECCOMP_MESSAGE_KILL_CONTENT "\n";
WriteToStdErr(kSeccompKillError, sizeof(kSeccompKillError) - 1);
// Make "pid" volatile so that we can see it on the stack in a minidump.
volatile uint64_t my_pid = sys_getpid();
volatile char* addr = reinterpret_cast<volatile char*>(my_pid & 0xFFF);
*addr = '\0';
for (;;)
_exit(1);
}
intptr_t SIGSYSFutexFailure(const struct arch_seccomp_data& args,
void* /* aux */) {
static const char kSeccompFutexError[] =
__FILE__ ":**CRASHING**:" SECCOMP_MESSAGE_FUTEX_CONTENT "\n";
WriteToStdErr(kSeccompFutexError, sizeof(kSeccompFutexError) - 1);
volatile int futex_op = args.args[1];
volatile char* addr = reinterpret_cast<volatile char*>(futex_op & 0xFFF);
*addr = '\0';
for (;;)
_exit(1);
}
intptr_t SIGSYSSchedHandler(const struct arch_seccomp_data& args,
void* aux) {
switch (args.nr) {
case __NR_sched_getaffinity:
case __NR_sched_getattr:
case __NR_sched_getparam:
case __NR_sched_getscheduler:
case __NR_sched_rr_get_interval:
case __NR_sched_setaffinity:
case __NR_sched_setattr:
case __NR_sched_setparam:
case __NR_sched_setscheduler:
const pid_t tid = sys_gettid();
// The first argument is the pid. If is our thread id, then replace it
// with 0, which is equivalent and allowed by the policy.
if (args.args[0] == static_cast<uint64_t>(tid)) {
return Syscall::Call(args.nr,
0,
static_cast<intptr_t>(args.args[1]),
static_cast<intptr_t>(args.args[2]),
static_cast<intptr_t>(args.args[3]),
static_cast<intptr_t>(args.args[4]),
static_cast<intptr_t>(args.args[5]));
}
break;
}
CrashSIGSYS_Handler(args, aux);
// Should never be reached.
RAW_CHECK(false);
return -ENOSYS;
}
bpf_dsl::ResultExpr CrashSIGSYS() {
return bpf_dsl::Trap(CrashSIGSYS_Handler, NULL);
}
bpf_dsl::ResultExpr CrashSIGSYSClone() {
return bpf_dsl::Trap(SIGSYSCloneFailure, NULL);
}
bpf_dsl::ResultExpr CrashSIGSYSPrctl() {
return bpf_dsl::Trap(SIGSYSPrctlFailure, NULL);
}
bpf_dsl::ResultExpr CrashSIGSYSIoctl() {
return bpf_dsl::Trap(SIGSYSIoctlFailure, NULL);
}
bpf_dsl::ResultExpr CrashSIGSYSKill() {
return bpf_dsl::Trap(SIGSYSKillFailure, NULL);
}
bpf_dsl::ResultExpr CrashSIGSYSFutex() {
return bpf_dsl::Trap(SIGSYSFutexFailure, NULL);
}
bpf_dsl::ResultExpr RewriteSchedSIGSYS() {
return bpf_dsl::Trap(SIGSYSSchedHandler, NULL);
}
const char* GetErrorMessageContentForTests() {
return SECCOMP_MESSAGE_COMMON_CONTENT;
}
const char* GetCloneErrorMessageContentForTests() {
return SECCOMP_MESSAGE_CLONE_CONTENT;
}
const char* GetPrctlErrorMessageContentForTests() {
return SECCOMP_MESSAGE_PRCTL_CONTENT;
}
const char* GetIoctlErrorMessageContentForTests() {
return SECCOMP_MESSAGE_IOCTL_CONTENT;
}
const char* GetKillErrorMessageContentForTests() {
return SECCOMP_MESSAGE_KILL_CONTENT;
}
const char* GetFutexErrorMessageContentForTests() {
return SECCOMP_MESSAGE_FUTEX_CONTENT;
}
} // namespace sandbox.
|
#include "World.h"
EagleBird::World::World(const uint32_t x_size, const uint32_t y_size, const uint32_t z_size)
{
_size_x = x_size;
_size_y = y_size;
_size_z = z_size;
int seed = rand();
_world_generator = new WorldGeneration::WorldGenerator(_size_x, _size_y, _size_z, seed);
_world_generator->GenerateWorld();
}
void EagleBird::World::Init()
{
}
uint32_t EagleBird::World::GetSizeX()
{
return _size_x;
}
uint32_t EagleBird::World::GetSizeY()
{
return _size_y;
}
uint32_t EagleBird::World::GetSizeZ()
{
return _size_z;
}
EagleBird::WorldGeneration::WorldGenerator * EagleBird::World::GetWorldGenerator()
{
return _world_generator;
}
float EagleBird::World::GetHeight(float x, float y)
{
return _world_generator->GetHeight(x, y);
}
|
/*
* OPCODE - Optimized Collision Detection
* http://www.codercorner.com/Opcode.htm
*
* Copyright (c) 2001-2008 Pierre Terdiman, pierre@codercorner.com
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.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Contains an implementation of the sweep-and-prune algorithm (moved from Z-Collide)
* \file OPC_SweepAndPrune.cpp
* \author Pierre Terdiman
* \date January, 29, 2000
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Precompiled Header
#include "Stdafx.h"
using namespace Opcode;
inline_ void Sort(udword& id0, udword& id1)
{
if(id0>id1) Swap(id0, id1);
}
class Opcode::SAP_Element
{
public:
inline_ SAP_Element() {}
inline_ SAP_Element(udword id, SAP_Element* next) : mID(id), mNext(next) {}
inline_ ~SAP_Element() {}
udword mID;
SAP_Element* mNext;
};
class Opcode::SAP_Box
{
public:
SAP_EndPoint* Min[3];
SAP_EndPoint* Max[3];
};
class Opcode::SAP_EndPoint
{
public:
float Value; // Min or Max value
SAP_EndPoint* Previous; // Previous EndPoint whose Value is smaller than ours (or null)
SAP_EndPoint* Next; // Next EndPoint whose Value is greater than ours (or null)
udword Data; // Parent box ID *2 | MinMax flag
inline_ void SetData(udword box_id, BOOL is_max) { Data = (box_id<<1)|is_max; }
inline_ BOOL IsMax() const { return Data & 1; }
inline_ udword GetBoxID() const { return Data>>1; }
inline_ void InsertAfter(SAP_EndPoint* element)
{
if(this!=element && this!=element->Next)
{
// Remove
if(Previous) Previous->Next = Next;
if(Next) Next->Previous = Previous;
// Insert
Next = element->Next;
if(Next) Next->Previous = this;
element->Next = this;
Previous = element;
}
}
inline_ void InsertBefore(SAP_EndPoint* element)
{
if(this!=element && this!=element->Previous)
{
// Remove
if(Previous) Previous->Next = Next;
if(Next) Next->Previous = Previous;
// Insert
Previous = element->Previous;
element->Previous = this;
Next = element;
if(Previous) Previous->Next = this;
}
}
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Constructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAP_PairData::SAP_PairData() :
mNbElements (0),
mNbUsedElements (0),
mElementPool (null),
mFirstFree (null),
mNbObjects (0),
mArray (null)
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Destructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAP_PairData::~SAP_PairData()
{
Release();
}
void SAP_PairData::Release()
{
mNbElements = 0;
mNbUsedElements = 0;
mNbObjects = 0;
DELETEARRAY(mElementPool);
DELETEARRAY(mArray);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Initializes.
* \param nb_objects [in]
* \return true if success
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool SAP_PairData::Init(udword nb_objects)
{
// Make sure everything has been released
Release();
if(!nb_objects) return false;
mArray = new SAP_Element*[nb_objects];
CHECKALLOC(mArray);
ZeroMemory(mArray, nb_objects*sizeof(SAP_Element*));
mNbObjects = nb_objects;
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Remaps a pointer when pool gets resized.
* \param element [in/out] remapped element
* \param delta [in] offset in bytes
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ void Remap(SAP_Element*& element, udword delta)
{
if(element) element = (SAP_Element*)(udword(element) + delta);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Gets a free element in the pool.
* \param id [in] element id
* \param next [in] next element
* \param remap [out] possible remapping offset
* \return the new element
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAP_Element* SAP_PairData::GetFreeElem(udword id, SAP_Element* next, udword* remap)
{
if(remap) *remap = 0;
SAP_Element* FreeElem;
if(mFirstFree)
{
// Recycle
FreeElem = mFirstFree;
mFirstFree = mFirstFree->mNext; // First free = next free (or null)
}
else
{
if(mNbUsedElements==mNbElements)
{
// Resize
mNbElements = mNbElements ? (mNbElements<<1) : 2;
SAP_Element* NewElems = new SAP_Element[mNbElements];
if(mNbUsedElements) CopyMemory(NewElems, mElementPool, mNbUsedElements*sizeof(SAP_Element));
// Remap everything
{
udword Delta = udword(NewElems) - udword(mElementPool);
for(udword i=0;i<mNbUsedElements;i++) Remap(NewElems[i].mNext, Delta);
for(udword i=0;i<mNbObjects;i++) Remap(mArray[i], Delta);
Remap(mFirstFree, Delta);
Remap(next, Delta);
if(remap) *remap = Delta;
}
DELETEARRAY(mElementPool);
mElementPool = NewElems;
}
FreeElem = &mElementPool[mNbUsedElements++];
}
FreeElem->mID = id;
FreeElem->mNext = next;
return FreeElem;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Frees an element of the pool.
* \param elem [in] element to free/recycle
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ void SAP_PairData::FreeElem(SAP_Element* elem)
{
elem->mNext = mFirstFree; // Next free
mFirstFree = elem;
}
// Add a pair to the set.
void SAP_PairData::AddPair(udword id1, udword id2)
{
// Order the ids
Sort(id1, id2);
ASSERT(id1<mNbObjects);
if(id1>=mNbObjects) return;
// Select the right list from "mArray".
SAP_Element* Current = mArray[id1];
if(!Current)
{
// Empty slot => create new element
mArray[id1] = GetFreeElem(id2, null);
}
else if(Current->mID>id2)
{
// The list is not empty but all elements are greater than id2 => insert id2 in the front.
mArray[id1] = GetFreeElem(id2, mArray[id1]);
}
else
{
// Else find the correct location in the sorted list (ascending order) and insert id2 there.
while(Current->mNext)
{
if(Current->mNext->mID > id2) break;
Current = Current->mNext;
}
if(Current->mID==id2) return; // The pair already exists
// Current->mNext = GetFreeElem(id2, Current->mNext);
udword Delta;
SAP_Element* E = GetFreeElem(id2, Current->mNext, &Delta);
if(Delta) Remap(Current, Delta);
Current->mNext = E;
}
}
// Delete a pair from the set.
void SAP_PairData::RemovePair(udword id1, udword id2)
{
// Order the ids.
Sort(id1, id2);
// Exit if the pair doesn't exist in the set
if(id1>=mNbObjects) return;
// Otherwise, select the correct list.
SAP_Element* Current = mArray[id1];
// If this list is empty, the pair doesn't exist.
if(!Current) return;
// Otherwise, if id2 is the first element, delete it.
if(Current->mID==id2)
{
mArray[id1] = Current->mNext;
FreeElem(Current);
}
else
{
// If id2 is not the first element, start traversing the sorted list.
while(Current->mNext)
{
// If we have moved too far away without hitting id2, then the pair doesn't exist
if(Current->mNext->mID > id2) return;
// Otherwise, delete id2.
if(Current->mNext->mID == id2)
{
SAP_Element* Temp = Current->mNext;
Current->mNext = Temp->mNext;
FreeElem(Temp);
return;
}
Current = Current->mNext;
}
}
}
void SAP_PairData::DumpPairs(Pairs& pairs) const
{
// ### Ugly and slow
for(udword i=0;i<mNbObjects;i++)
{
SAP_Element* Current = mArray[i];
while(Current)
{
ASSERT(Current->mID<mNbObjects);
pairs.AddPair(i, Current->mID);
Current = Current->mNext;
}
}
}
void SAP_PairData::DumpPairs(PairCallback callback, void* user_data) const
{
if(!callback) return;
// ### Ugly and slow
for(udword i=0;i<mNbObjects;i++)
{
SAP_Element* Current = mArray[i];
while(Current)
{
ASSERT(Current->mID<mNbObjects);
if(!(callback)(i, Current->mID, user_data)) return;
Current = Current->mNext;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Constructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SweepAndPrune::SweepAndPrune()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Destructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SweepAndPrune::~SweepAndPrune()
{
}
void SweepAndPrune::GetPairs(Pairs& pairs) const
{
mPairs.DumpPairs(pairs);
}
void SweepAndPrune::GetPairs(PairCallback callback, void* user_data) const
{
mPairs.DumpPairs(callback, user_data);
}
bool SweepAndPrune::Init(udword nb_objects, const AABB** boxes)
{
// 1) Create sorted lists
mNbObjects = nb_objects;
mBoxes = new SAP_Box[nb_objects];
// for(udword i=0;i<nb_objects;i++) mBoxes[i].Box = *boxes[i];
float* Data = new float[nb_objects*2];
for(udword Axis=0;Axis<3;Axis++)
{
mList[Axis] = new SAP_EndPoint[nb_objects*2];
for(udword i=0;i<nb_objects;i++)
{
Data[i*2+0] = boxes[i]->GetMin(Axis);
Data[i*2+1] = boxes[i]->GetMax(Axis);
}
RadixSort RS;
const udword* Sorted = RS.Sort(Data, nb_objects*2).GetRanks();
SAP_EndPoint* PreviousEndPoint = null;
for(udword i=0;i<nb_objects*2;i++)
{
udword SortedIndex = *Sorted++;
float SortedCoord = Data[SortedIndex];
udword BoxIndex = SortedIndex>>1;
ASSERT(BoxIndex<nb_objects);
SAP_EndPoint* CurrentEndPoint = &mList[Axis][SortedIndex];
CurrentEndPoint->Value = SortedCoord;
// CurrentEndPoint->IsMax = SortedIndex&1; // ### could be implicit ?
// CurrentEndPoint->ID = BoxIndex; // ### could be implicit ?
CurrentEndPoint->SetData(BoxIndex, SortedIndex&1); // ### could be implicit ?
CurrentEndPoint->Previous = PreviousEndPoint;
CurrentEndPoint->Next = null;
if(PreviousEndPoint) PreviousEndPoint->Next = CurrentEndPoint;
if(CurrentEndPoint->IsMax()) mBoxes[BoxIndex].Max[Axis] = CurrentEndPoint;
else mBoxes[BoxIndex].Min[Axis] = CurrentEndPoint;
PreviousEndPoint = CurrentEndPoint;
}
}
DELETEARRAY(Data);
CheckListsIntegrity();
// 2) Quickly find starting pairs
mPairs.Init(nb_objects);
{
Pairs P;
CompleteBoxPruning(nb_objects, boxes, P, Axes(AXES_XZY));
for(udword i=0;i<P.GetNbPairs();i++)
{
const Pair* PP = P.GetPair(i);
udword id0 = PP->id0;
udword id1 = PP->id1;
if(id0!=id1 && boxes[id0]->Intersect(*boxes[id1]))
{
mPairs.AddPair(id0, id1);
}
else ASSERT(0);
}
}
return true;
}
bool SweepAndPrune::CheckListsIntegrity()
{
for(udword Axis=0;Axis<3;Axis++)
{
// Find list head
SAP_EndPoint* Current = mList[Axis];
while(Current->Previous) Current = Current->Previous;
udword Nb = 0;
SAP_EndPoint* Previous = null;
while(Current)
{
Nb++;
if(Previous)
{
ASSERT(Previous->Value <= Current->Value);
if(Previous->Value > Current->Value) return false;
}
ASSERT(Current->Previous==Previous);
if(Current->Previous!=Previous) return false;
Previous = Current;
Current = Current->Next;
}
ASSERT(Nb==mNbObjects*2);
}
return true;
}
inline_ BOOL Intersect(const AABB& a, const SAP_Box& b)
{
if(b.Max[0]->Value < a.GetMin(0) || a.GetMax(0) < b.Min[0]->Value
|| b.Max[1]->Value < a.GetMin(1) || a.GetMax(1) < b.Min[1]->Value
|| b.Max[2]->Value < a.GetMin(2) || a.GetMax(2) < b.Min[2]->Value) return FALSE;
return TRUE;
}
bool SweepAndPrune::UpdateObject(udword i, const AABB& box)
{
for(udword Axis=0;Axis<3;Axis++)
{
// udword Base = (udword)&mList[Axis][0];
// Update min
{
SAP_EndPoint* const CurrentMin = mBoxes[i].Min[Axis];
ASSERT(!CurrentMin->IsMax());
const float Limit = box.GetMin(Axis);
if(Limit == CurrentMin->Value)
{
}
else if(Limit < CurrentMin->Value)
{
CurrentMin->Value = Limit;
// Min is moving left:
SAP_EndPoint* NewPos = CurrentMin;
ASSERT(NewPos);
SAP_EndPoint* tmp;
while((tmp = NewPos->Previous) && tmp->Value > Limit)
{
NewPos = tmp;
if(NewPos->IsMax())
{
// Our min passed a max => start overlap
//udword SortedIndex = (udword(CurrentMin) - Base)/sizeof(NS_EndPoint);
const udword id0 = CurrentMin->GetBoxID();
const udword id1 = NewPos->GetBoxID();
if(id0!=id1 && Intersect(box, mBoxes[id1])) mPairs.AddPair(id0, id1);
}
}
CurrentMin->InsertBefore(NewPos);
}
else// if(Limit > CurrentMin->Value)
{
CurrentMin->Value = Limit;
// Min is moving right:
SAP_EndPoint* NewPos = CurrentMin;
ASSERT(NewPos);
SAP_EndPoint* tmp;
while((tmp = NewPos->Next) && tmp->Value < Limit)
{
NewPos = tmp;
if(NewPos->IsMax())
{
// Our min passed a max => stop overlap
const udword id0 = CurrentMin->GetBoxID();
const udword id1 = NewPos->GetBoxID();
if(id0!=id1) mPairs.RemovePair(id0, id1);
}
}
CurrentMin->InsertAfter(NewPos);
}
}
// Update max
{
SAP_EndPoint* const CurrentMax = mBoxes[i].Max[Axis];
ASSERT(CurrentMax->IsMax());
const float Limit = box.GetMax(Axis);
if(Limit == CurrentMax->Value)
{
}
else if(Limit > CurrentMax->Value)
{
CurrentMax->Value = Limit;
// Max is moving right:
SAP_EndPoint* NewPos = CurrentMax;
ASSERT(NewPos);
SAP_EndPoint* tmp;
while((tmp = NewPos->Next) && tmp->Value < Limit)
{
NewPos = tmp;
if(!NewPos->IsMax())
{
// Our max passed a min => start overlap
const udword id0 = CurrentMax->GetBoxID();
const udword id1 = NewPos->GetBoxID();
if(id0!=id1 && Intersect(box, mBoxes[id1])) mPairs.AddPair(id0, id1);
}
}
CurrentMax->InsertAfter(NewPos);
}
else// if(Limit < CurrentMax->Value)
{
CurrentMax->Value = Limit;
// Max is moving left:
SAP_EndPoint* NewPos = CurrentMax;
ASSERT(NewPos);
SAP_EndPoint* tmp;
while((tmp = NewPos->Previous) && tmp->Value > Limit)
{
NewPos = tmp;
if(!NewPos->IsMax())
{
// Our max passed a min => stop overlap
const udword id0 = CurrentMax->GetBoxID();
const udword id1 = NewPos->GetBoxID();
if(id0!=id1) mPairs.RemovePair(id0, id1);
}
}
CurrentMax->InsertBefore(NewPos);
}
}
}
return true;
}
|
#include "LevelSelectionWinodw.h"
LevelSelectionWindow::LevelSelectionWindow(const unsigned short& _mode)
: mode(_mode),
levelsNumber(Levels::levelsNumber[_mode])
{
backButton = new MenuButton(L"Назад", sf::Vector2f(150, 50), sf::Vector2f(0, 550));
backButton->OnClick.add(this, &LevelSelectionWindow::back);
levelButtons.resize(levelsNumber);
for(int i = 0; i < levelsNumber; i++)
{
levelButtons[i] = new ImageButton(sf::Vector2f(115, 115));
levelButtons[i]->setContent(std::to_string(i + 1));
levelButtons[i]->setOutColor(sf::Color(150, 255, 150, 255));
levelButtons[i]->setOverColor(sf::Color(100, 255, 100, 255));
levelButtons[i]->setPosition(sf::Vector2f(5 + 125 * (i % 4), 100 + 125 * (i / 4)));
levelButtons[i]->MouseEnter.add(this, &LevelSelectionWindow::levelButtonMouseEnter);
levelButtons[i]->setMouseOverResize(sf::Vector2f(10, 10));
levelButtons[i]->id = i;
levelButtons[i]->OnClick.add(this, &LevelSelectionWindow::levelSelected);
}
infoLabel = new sf::Text(L"Выберите уровень", Resources::getSansation(), 40);
infoLabel->setPosition(sf::Vector2f(70, 15));
infoLabel->setColor(sf::Color(90, 255, 90, 255));
infoLabel->setOutlineThickness(1);
}
LevelSelectionWindow::~LevelSelectionWindow()
{
Resources::drawSet.remove(this);
Resources::deleteSet.add(backButton);
for(int i = 0; i < levelsNumber; i++)
Resources::deleteSet.add(levelButtons[i]);
Resources::deleteSet.add(infoLabel);
}
void LevelSelectionWindow::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(*backButton);
for(int i = 0; i < levelsNumber; i++)
{
target.draw(*levelButtons[i]);
}
target.draw(*infoLabel);
}
void LevelSelectionWindow::back(MenuButton* sender)
{
Resources::drawSet.remove(this);
Resources::deleteSet.add(this);
GameModeMenu* gameModeMenu = new GameModeMenu;
Resources::drawSet.add(*gameModeMenu);
}
void LevelSelectionWindow::levelButtonMouseEnter(MenuButton* sender)
{
}
void LevelSelectionWindow::levelSelected(MenuButton* sender)
{
int selected_id = sender->id;
Resources::deleteSet.add(this);
Game* game = new Game(mode, selected_id);
Resources::drawSet.add(*game);
}
|
#include <Pythia8/Pythia.h>
#include <fmt/core.h>
#include <fmt/format.h>
auto main() -> int {
Pythia8::SigmaPr
fmt::print("{}", "hello");
return 0;
}
|
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <iomanip>
#include <climits>
using namespace std;
int getBitNum(unsigned long long int n)
{
int ans = 0;
while (n)
{
ans++;
n >>= 1;
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
long long int n, k;
cin >> n >> k;
if (k == 1)
{
cout << n << endl;
}
else
{
unsigned long long int ans = (unsigned long long int)1 << getBitNum(n);
cout << ans - 1 << endl;
}
return 0;
}
|
/******************************************************************************
* Copyright (c) 2017 Philipp Schubert.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of LICENSE.txt.
*
* Contributors:
* Philipp Schubert and others
*****************************************************************************/
#include <string>
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/raw_ostream.h"
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h"
namespace psr {
std::string toString(const DataFlowAnalysisType &D) {
switch (D) {
default:
#define DATA_FLOW_ANALYSIS_TYPES(NAME, CMDFLAG, TYPE) \
case DataFlowAnalysisType::TYPE: \
return NAME; \
break;
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.def"
}
}
DataFlowAnalysisType toDataFlowAnalysisType(const std::string &S) {
DataFlowAnalysisType Type = llvm::StringSwitch<DataFlowAnalysisType>(S)
#define DATA_FLOW_ANALYSIS_TYPES(NAME, CMDFLAG, TYPE) \
.Case(NAME, DataFlowAnalysisType::TYPE)
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.def"
.Default(DataFlowAnalysisType::None);
if (Type == DataFlowAnalysisType::None) {
Type = llvm::StringSwitch<DataFlowAnalysisType>(S)
#define DATA_FLOW_ANALYSIS_TYPES(NAME, CMDFLAG, TYPE) \
.Case(CMDFLAG, DataFlowAnalysisType::TYPE)
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.def"
.Default(DataFlowAnalysisType::None);
}
return Type;
}
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const DataFlowAnalysisType &D) {
return OS << toString(D);
}
} // namespace psr
|
// Copyright (c) 2014-2019, The Motif Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// FIXME: move this into a full wallet2 unit test suite, if possible
#include "gtest/gtest.h"
#include "wallet/wallet2.h"
static crypto::hash make_hash(uint64_t n)
{
union
{
crypto::hash hash;
uint64_t n;
} hash;
hash.hash = crypto::null_hash;
hash.n = n;
return hash.hash;
}
TEST(hashchain, empty)
{
tools::hashchain hashchain;
ASSERT_EQ(hashchain.size(), 0);
ASSERT_EQ(hashchain.offset(), 0);
}
TEST(hashchain, genesis)
{
tools::hashchain hashchain;
hashchain.push_back(make_hash(1));
ASSERT_EQ(hashchain.size(), 1);
ASSERT_EQ(hashchain.genesis(), make_hash(1));
hashchain.push_back(make_hash(2));
ASSERT_EQ(hashchain.size(), 2);
ASSERT_EQ(hashchain.genesis(), make_hash(1));
}
TEST(hashchain, push_back)
{
tools::hashchain hashchain;
hashchain.push_back(make_hash(1));
hashchain.push_back(make_hash(2));
hashchain.push_back(make_hash(3));
ASSERT_EQ(hashchain[0], make_hash(1));
ASSERT_EQ(hashchain[1], make_hash(2));
ASSERT_EQ(hashchain[2], make_hash(3));
}
TEST(hashchain, clear_empty)
{
tools::hashchain hashchain;
ASSERT_TRUE(hashchain.empty());
hashchain.push_back(make_hash(1));
ASSERT_FALSE(hashchain.empty());
hashchain.push_back(make_hash(2));
ASSERT_FALSE(hashchain.empty());
hashchain.clear();
ASSERT_TRUE(hashchain.empty());
}
TEST(hashchain, crop)
{
tools::hashchain hashchain;
hashchain.push_back(make_hash(1));
hashchain.push_back(make_hash(2));
hashchain.push_back(make_hash(3));
ASSERT_EQ(hashchain.size(), 3);
ASSERT_EQ(hashchain[0], make_hash(1));
ASSERT_EQ(hashchain[1], make_hash(2));
ASSERT_EQ(hashchain[2], make_hash(3));
hashchain.crop(3);
ASSERT_EQ(hashchain.size(), 3);
hashchain.crop(2);
ASSERT_EQ(hashchain.size(), 2);
ASSERT_EQ(hashchain[0], make_hash(1));
ASSERT_EQ(hashchain[1], make_hash(2));
ASSERT_EQ(hashchain.genesis(), make_hash(1));
hashchain.crop(0);
ASSERT_TRUE(hashchain.empty());
ASSERT_EQ(hashchain.size(), 0);
hashchain.push_back(make_hash(5));
ASSERT_EQ(hashchain.genesis(), make_hash(5));
ASSERT_EQ(hashchain.size(), 1);
}
TEST(hashchain, trim)
{
tools::hashchain hashchain;
hashchain.push_back(make_hash(1));
hashchain.push_back(make_hash(2));
hashchain.push_back(make_hash(3));
ASSERT_EQ(hashchain.offset(), 0);
hashchain.trim(2);
ASSERT_EQ(hashchain.offset(), 2);
ASSERT_EQ(hashchain.size(), 3);
ASSERT_EQ(hashchain[2], make_hash(3));
hashchain.trim(3);
ASSERT_EQ(hashchain.offset(), 2); // never gets it empty
ASSERT_EQ(hashchain.size(), 3);
ASSERT_FALSE(hashchain.empty());
ASSERT_EQ(hashchain.genesis(), make_hash(1));
}
|
//
// cpp11/can_require_concept_not_applicable_unsupported.cpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/asio/require_concept.hpp>
#include <cassert>
template <int>
struct prop
{
};
template <int>
struct object
{
};
int main()
{
static_assert(!boost::asio::can_require_concept<object<1>, prop<2>>::value, "");
static_assert(!boost::asio::can_require_concept<const object<1>, prop<2>>::value, "");
}
|
#pragma once
#include "common_srv/Block.hpp"
#include <math.h>
#include "ControllerMessage.hpp"
#include "PID_values.hpp"
#include "common_srv/FloatMsg.hpp"
#include "Controller.hpp"
#include "common_srv/Vector3DMessage.hpp"
#include "common_srv/FloatMsg.hpp"
#include "ButterFilter_2nd_200Hz.hpp"
#include "SwitchOutMsg.hpp"
#include "logger.hpp"
#include "common_srv/IntegerMsg.hpp"
#include "InputPort.hpp"
#include "OutputPort.hpp"
class PIDController : public Controller{
private:
controller_type _controller_type;
SwitchOutMsg m_switchout_msg;
block_id _id;
FloatMsg _command_msg;
ButterFilter_2nd_200Hz _filter;
float _filter_y;
Port* _input_port_0;
Port* _input_port_1;
Port* _input_port_2;
Port* _output_port;
std::vector<Port*> _ports;
//Chehadeh's code
PID_parameters _parameters;
bool i_term, d_term, dd_term; //Comparing against booleans is faster
float _dt;
bool en_pv_derivation = true, en_anti_windup = false;
void set_internal_sw(PID_parameters pid_para_x);
//---------------
public:
enum ports_id {IP_0_DATA, IP_1_UPDATE, IP_2_RESET, OP_0_DATA};
void process(DataMessage* t_msg, Port* t_port);
std::vector<Port*> getPorts();
//Chehadeh's code
float prev_err = 0, prev2_err = 0, prev_pv_rate = 0, accum_u = 0, accum_I = 0;
void initialize(PID_parameters);
float pid_inc(float err, float pv_first, float pv_second=-1);
float pid_direct(float err, float pv_first, float pv_second=-1);
void set_I_term(float);
//---------------
void update_params(PID_parameters*);
enum receiving_channels {ch_update, ch_reset};
void switchIn(DataMessage*);
DataMessage* switchOut();
void receiveMsgData(DataMessage* t_msg);
void reset();
DataMessage* runTask(DataMessage*);
controller_type getControllerType(){ return _controller_type; }
block_id getID(){ return _id; }
//TODO Send a message to Switcher
//TODO Receive a message from Switcher
PIDController(block_id t_id);
~PIDController();
};
|
//-----------------------------------------------
//
// This file is part of the Siv3D Engine.
//
// Copyright (c) 2008-2019 Ryo Suzuki
// Copyright (c) 2016-2019 OpenSiv3D Project
//
// Licensed under the MIT License.
//
//-----------------------------------------------
# pragma once
# include <freetype/ft2build.h>
# include <freetype/ftoutln.h>
# include FT_FREETYPE_H
# include FT_SYNTHESIS_H
# include FT_TRUETYPE_TABLES_H
# include <harfbuzz/hb.h>
# include <harfbuzz/hb-ft.h>
# include <Siv3D/HashTable.hpp>
# include <Siv3D/Image.hpp>
# include <Siv3D/Font.hpp>
# include <Siv3D/ByteArray.hpp>
# include <Siv3D/DynamicTexture.hpp>
# include "FontFace.hpp"
# if SIV3D_PLATFORM(WINDOWS)
# include <Siv3D/Windows.hpp>
namespace s3d
{
class FontResourceHolder
{
private:
int64 m_size = 0;
const void* m_pResource = nullptr;
public:
FontResourceHolder() = default;
FontResourceHolder(const FilePath& path)
{
HMODULE hModule = ::GetModuleHandleW(nullptr);
const std::wstring pathW = path.toWstr();
if (HRSRC hrs = ::FindResourceW(hModule, &pathW[1], L"FILE"))
{
if (HGLOBAL resource = ::LoadResource(hModule, hrs))
{
m_pResource = ::LockResource(resource);
m_size = ::SizeofResource(hModule, hrs);
}
}
}
~FontResourceHolder()
{
m_pResource = nullptr;
m_size = 0;
}
const void* data() const
{
return m_pResource;
}
int64 size() const
{
return m_size;
}
};
}
# endif
namespace s3d
{
struct GlyphInfo
{
Rect bitmapRect = { 0,0,0,0 };
Point offset = { 0,0 };
int32 bearingY = 0;
int32 xAdvance = 0;
int32 yAdvance = 0;
int32 width = 0;
};
class FontData
{
private:
using char32VH = uint32;
static constexpr uint32 Horizontal = 0;
static constexpr uint32 Vertical = 1u << 31u;
using CommonGlyphIndex = uint32;
# if SIV3D_PLATFORM(WINDOWS)
FontResourceHolder m_resource;
# endif
HashTable<char32VH, CommonGlyphIndex> m_glyphVHIndexTable;
HashTable<uint16, uint16> m_verticalTable;
bool m_verticalTableInitialized = false;
FontFace m_faceText;
FontFace m_faceEmoji;
Array<GlyphInfo> m_glyphs;
Optional<CommonGlyphIndex> m_tofuIndex;
static constexpr int32 padding = 2;
String m_familyName;
String m_styleName;
int32 m_fontSize = 0;
int32 m_lineSpacing = 0;
int32 m_ascender = 0;
int32 m_descender = 0;
int32 m_tabWidth = 0;
bool m_bold = false;
bool m_italic = false;
bool m_noBitmap = true;
Point m_penPos = { 0, padding };
Image m_image;
bool m_hasDirty = false;
DynamicTexture m_texture;
bool m_initialized = false;
void generateVerticalTable();
bool render(const String& codePoints);
bool renderVertical(const String& codePoints);
bool renderGlyph(FT_Face face, FT_UInt glyphIndex);
void paintGlyph(FT_Face face, FT_UInt glyphIndex, Image& image, Image& tmpImage, bool overwrite, const Point& penPos, const Color& color, int32& width, int32& xAdvance) const;
void renderIfDirty();
public:
struct Null {};
FontData() = default;
FontData(Null, FT_Library library);
FontData(FT_Library library, const FilePath& filePath, const FilePath& emojiFilePath, const int32 fontSize, FontStyle style);
~FontData();
bool isInitialized() const noexcept;
const String& getFamilyName() const;
const String& getStyleName() const;
int32 getFontSize() const noexcept;
int32 getAscent() const noexcept;
int32 getDescent() const noexcept;
Array<Glyph> getGlyphs(const String& codePoints);
Array<Glyph> getVerticalGlyphs(const String& codePoints);
OutlineGlyph getOutlineGlyph(char32 codePoint);
const Texture& getTexture();
RectF getBoundingRect(const String& codePoints, double lineSpacingScale);
RectF getRegion(const String& codePoints, double lineSpacingScale);
Array<int32> getXAdvances(const String& codePoints);
RectF draw(const String& codePoints, const Vec2& pos, const ColorF& color, double lineSpacingScale);
bool draw(const String& codePoints, const RectF& area, const ColorF& color, double lineSpacingScale);
Rect paint(Image& dst, bool overwrite, const String& codePoints, const Point& pos, const Color& color, double lineSpacingScale) const;
};
}
|
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/registration/ndt.h>
#include <pcl/filters/approximate_voxel_grid.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <boost/thread/thread.hpp>
int
main (int argc, char** argv)
{
// Loading first scan of room.
pcl::PointCloud<pcl::PointXYZ>::Ptr target_cloud (new pcl::PointCloud<pcl::PointXYZ>);
if (pcl::io::loadPCDFile<pcl::PointXYZ> ("room_scan1.pcd", *target_cloud) == -1)
{
PCL_ERROR ("Couldn't read file room_scan1.pcd \n");
return (-1);
}
std::cout << "Loaded " << target_cloud->size () << " data points from room_scan1.pcd" << std::endl;
// Loading second scan of room from new perspective.
pcl::PointCloud<pcl::PointXYZ>::Ptr input_cloud (new pcl::PointCloud<pcl::PointXYZ>);
if (pcl::io::loadPCDFile<pcl::PointXYZ> ("room_scan2.pcd", *input_cloud) == -1)
{
PCL_ERROR ("Couldn't read file room_scan2.pcd \n");
return (-1);
}
std::cout << "Loaded " << input_cloud->size () << " data points from room_scan2.pcd" << std::endl;
// Filtering input scan to roughly 10% of original size to increase speed of registration.
pcl::PointCloud<pcl::PointXYZ>::Ptr filtered_cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::ApproximateVoxelGrid<pcl::PointXYZ> approximate_voxel_filter;
approximate_voxel_filter.setLeafSize (0.2, 0.2, 0.2);
approximate_voxel_filter.setInputCloud (input_cloud);
approximate_voxel_filter.filter (*filtered_cloud);
std::cout << "Filtered cloud contains " << filtered_cloud->size ()
<< " data points from room_scan2.pcd" << std::endl;
// Initializing Normal Distributions Transform (NDT).
pcl::NormalDistributionsTransform<pcl::PointXYZ, pcl::PointXYZ> ndt;
// Setting scale dependent NDT parameters
// Setting minimum transformation difference for termination condition.
ndt.setTransformationEpsilon (0.01);
// Setting maximum step size for More-Thuente line search.
ndt.setStepSize (0.1);
//Setting Resolution of NDT grid structure (VoxelGridCovariance).
ndt.setResolution (1.0);
// Setting max number of registration iterations.
ndt.setMaximumIterations (35);
// Setting point cloud to be aligned.
ndt.setInputSource (filtered_cloud);
// Setting point cloud to be aligned to.
ndt.setInputTarget (target_cloud);
// Set initial alignment estimate found using robot odometry.
Eigen::AngleAxisf init_rotation (0.6931, Eigen::Vector3f::UnitZ ());
Eigen::Translation3f init_translation (1.79387, 0.720047, 0);
Eigen::Matrix4f init_guess = (init_translation * init_rotation).matrix ();
// Calculating required rigid transform to align the input cloud to the target cloud.
pcl::PointCloud<pcl::PointXYZ>::Ptr output_cloud (new pcl::PointCloud<pcl::PointXYZ>);
ndt.align (*output_cloud, init_guess);
std::cout << "Normal Distributions Transform has converged:" << ndt.hasConverged ()
<< " score: " << ndt.getFitnessScore () << std::endl;
// Transforming unfiltered, input cloud using found transform.
pcl::transformPointCloud (*input_cloud, *output_cloud, ndt.getFinalTransformation ());
// Saving transformed input cloud.
pcl::io::savePCDFileASCII ("room_scan2_transformed.pcd", *output_cloud);
// Initializing point cloud visualizer
boost::shared_ptr<pcl::visualization::PCLVisualizer>
viewer_final (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer_final->setBackgroundColor (0, 0, 0);
// Coloring and visualizing target cloud (red).
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ>
target_color (target_cloud, 255, 0, 0);
viewer_final->addPointCloud<pcl::PointXYZ> (target_cloud, target_color, "target cloud");
viewer_final->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
1, "target cloud");
// Coloring and visualizing transformed input cloud (green).
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ>
output_color (output_cloud, 0, 255, 0);
viewer_final->addPointCloud<pcl::PointXYZ> (output_cloud, output_color, "output cloud");
viewer_final->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE,
1, "output cloud");
// Starting visualizer
viewer_final->addCoordinateSystem (1.0, "global");
viewer_final->initCameraParameters ();
// Wait until visualizer window is closed.
while (!viewer_final->wasStopped ())
{
viewer_final->spinOnce (100);
boost::this_thread::sleep (boost::posix_time::microseconds (100000));
}
return (0);
}
|
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program 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 3 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, see <https://www.gnu.org/licenses/>.
*
*/
/**
* stepper_dac.cpp - To set stepper current via DAC
*/
#include "../../inc/MarlinConfig.h"
#if HAS_MOTOR_CURRENT_DAC
#include "stepper_dac.h"
#include "../../MarlinCore.h" // for SP_X_LBL...
bool dac_present = false;
constexpr xyze_uint8_t dac_order = DAC_STEPPER_ORDER;
xyze_uint_t dac_channel_pct = DAC_MOTOR_CURRENT_DEFAULT;
StepperDAC stepper_dac;
int StepperDAC::init() {
#if PIN_EXISTS(DAC_DISABLE)
OUT_WRITE(DAC_DISABLE_PIN, LOW); // set pin low to enable DAC
#endif
mcp4728.init();
if (mcp4728.simpleCommand(RESET)) return -1;
dac_present = true;
mcp4728.setVref_all(DAC_STEPPER_VREF);
mcp4728.setGain_all(DAC_STEPPER_GAIN);
if (mcp4728.getDrvPct(0) < 1 || mcp4728.getDrvPct(1) < 1 || mcp4728.getDrvPct(2) < 1 || mcp4728.getDrvPct(3) < 1) {
mcp4728.setDrvPct(dac_channel_pct);
mcp4728.eepromWrite();
}
return 0;
}
void StepperDAC::set_current_value(const uint8_t channel, uint16_t val) {
if (!dac_present) return;
NOMORE(val, uint16_t(DAC_STEPPER_MAX));
mcp4728.analogWrite(dac_order[channel], val);
mcp4728.simpleCommand(UPDATE);
}
void StepperDAC::set_current_percent(const uint8_t channel, float val) {
set_current_value(channel, _MIN(val, 100.0f) * (DAC_STEPPER_MAX) / 100.0f);
}
static float dac_perc(int8_t n) { return mcp4728.getDrvPct(dac_order[n]); }
static float dac_amps(int8_t n) { return mcp4728.getValue(dac_order[n]) * 0.125 * RECIPROCAL(DAC_STEPPER_SENSE * 1000); }
uint8_t StepperDAC::get_current_percent(const AxisEnum axis) { return mcp4728.getDrvPct(dac_order[axis]); }
void StepperDAC::set_current_percents(xyze_uint8_t &pct) {
LOOP_LOGICAL_AXES(i) dac_channel_pct[i] = pct[dac_order[i]];
mcp4728.setDrvPct(dac_channel_pct);
}
void StepperDAC::print_values() {
if (!dac_present) return;
SERIAL_ECHO_MSG("Stepper current values in % (Amps):");
SERIAL_ECHO_START();
SERIAL_ECHOPGM_P(SP_X_LBL, dac_perc(X_AXIS), PSTR(" ("), dac_amps(X_AXIS), PSTR(")"));
#if HAS_Y_AXIS
SERIAL_ECHOPGM_P(SP_Y_LBL, dac_perc(Y_AXIS), PSTR(" ("), dac_amps(Y_AXIS), PSTR(")"));
#endif
#if HAS_Z_AXIS
SERIAL_ECHOPGM_P(SP_Z_LBL, dac_perc(Z_AXIS), PSTR(" ("), dac_amps(Z_AXIS), PSTR(")"));
#endif
#if HAS_EXTRUDERS
SERIAL_ECHOLNPGM_P(SP_E_LBL, dac_perc(E_AXIS), PSTR(" ("), dac_amps(E_AXIS), PSTR(")"));
#endif
}
void StepperDAC::commit_eeprom() {
if (!dac_present) return;
mcp4728.eepromWrite();
}
#endif // HAS_MOTOR_CURRENT_DAC
|
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include <limits>
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))
namespace cv
{
//////////////////////////// Bayer Pattern -> RGB conversion /////////////////////////////
template<typename T>
class SIMDBayerStubInterpolator_
{
public:
int bayer2Gray(const T*, int, T*, int, int, int, int) const
{
return 0;
}
int bayer2RGB(const T*, int, T*, int, int) const
{
return 0;
}
int bayer2RGBA(const T*, int, T*, int, int) const
{
return 0;
}
int bayer2RGB_EA(const T*, int, T*, int, int) const
{
return 0;
}
};
#if CV_SSE2
class SIMDBayerInterpolator_8u
{
public:
SIMDBayerInterpolator_8u()
{
use_simd = checkHardwareSupport(CV_CPU_SSE2);
}
int bayer2Gray(const uchar* bayer, int bayer_step, uchar* dst,
int width, int bcoeff, int gcoeff, int rcoeff) const
{
if( !use_simd )
return 0;
__m128i _b2y = _mm_set1_epi16((short)(rcoeff*2));
__m128i _g2y = _mm_set1_epi16((short)(gcoeff*2));
__m128i _r2y = _mm_set1_epi16((short)(bcoeff*2));
const uchar* bayer_end = bayer + width;
for( ; bayer <= bayer_end - 18; bayer += 14, dst += 14 )
{
__m128i r0 = _mm_loadu_si128((const __m128i*)bayer);
__m128i r1 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step));
__m128i r2 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step*2));
__m128i b1 = _mm_add_epi16(_mm_srli_epi16(_mm_slli_epi16(r0, 8), 7),
_mm_srli_epi16(_mm_slli_epi16(r2, 8), 7));
__m128i b0 = _mm_add_epi16(b1, _mm_srli_si128(b1, 2));
b1 = _mm_slli_epi16(_mm_srli_si128(b1, 2), 1);
__m128i g0 = _mm_add_epi16(_mm_srli_epi16(r0, 7), _mm_srli_epi16(r2, 7));
__m128i g1 = _mm_srli_epi16(_mm_slli_epi16(r1, 8), 7);
g0 = _mm_add_epi16(g0, _mm_add_epi16(g1, _mm_srli_si128(g1, 2)));
g1 = _mm_slli_epi16(_mm_srli_si128(g1, 2), 2);
r0 = _mm_srli_epi16(r1, 8);
r1 = _mm_slli_epi16(_mm_add_epi16(r0, _mm_srli_si128(r0, 2)), 2);
r0 = _mm_slli_epi16(r0, 3);
g0 = _mm_add_epi16(_mm_mulhi_epi16(b0, _b2y), _mm_mulhi_epi16(g0, _g2y));
g1 = _mm_add_epi16(_mm_mulhi_epi16(b1, _b2y), _mm_mulhi_epi16(g1, _g2y));
g0 = _mm_add_epi16(g0, _mm_mulhi_epi16(r0, _r2y));
g1 = _mm_add_epi16(g1, _mm_mulhi_epi16(r1, _r2y));
g0 = _mm_srli_epi16(g0, 2);
g1 = _mm_srli_epi16(g1, 2);
g0 = _mm_packus_epi16(g0, g0);
g1 = _mm_packus_epi16(g1, g1);
g0 = _mm_unpacklo_epi8(g0, g1);
_mm_storeu_si128((__m128i*)dst, g0);
}
return (int)(bayer - (bayer_end - width));
}
int bayer2RGB(const uchar* bayer, int bayer_step, uchar* dst, int width, int blue) const
{
if( !use_simd )
return 0;
/*
B G B G | B G B G | B G B G | B G B G
G R G R | G R G R | G R G R | G R G R
B G B G | B G B G | B G B G | B G B G
*/
__m128i delta1 = _mm_set1_epi16(1), delta2 = _mm_set1_epi16(2);
__m128i mask = _mm_set1_epi16(blue < 0 ? -1 : 0), z = _mm_setzero_si128();
__m128i masklo = _mm_set1_epi16(0x00ff);
const uchar* bayer_end = bayer + width;
for( ; bayer <= bayer_end - 18; bayer += 14, dst += 42 )
{
__m128i r0 = _mm_loadu_si128((const __m128i*)bayer);
__m128i r1 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step));
__m128i r2 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step*2));
__m128i b1 = _mm_add_epi16(_mm_and_si128(r0, masklo), _mm_and_si128(r2, masklo));
__m128i nextb1 = _mm_srli_si128(b1, 2);
__m128i b0 = _mm_add_epi16(b1, nextb1);
b1 = _mm_srli_epi16(_mm_add_epi16(nextb1, delta1), 1);
b0 = _mm_srli_epi16(_mm_add_epi16(b0, delta2), 2);
// b0 b2 ... b14 b1 b3 ... b15
b0 = _mm_packus_epi16(b0, b1);
__m128i g0 = _mm_add_epi16(_mm_srli_epi16(r0, 8), _mm_srli_epi16(r2, 8));
__m128i g1 = _mm_and_si128(r1, masklo);
g0 = _mm_add_epi16(g0, _mm_add_epi16(g1, _mm_srli_si128(g1, 2)));
g1 = _mm_srli_si128(g1, 2);
g0 = _mm_srli_epi16(_mm_add_epi16(g0, delta2), 2);
// g0 g2 ... g14 g1 g3 ... g15
g0 = _mm_packus_epi16(g0, g1);
r0 = _mm_srli_epi16(r1, 8);
r1 = _mm_add_epi16(r0, _mm_srli_si128(r0, 2));
r1 = _mm_srli_epi16(_mm_add_epi16(r1, delta1), 1);
// r0 r2 ... r14 r1 r3 ... r15
r0 = _mm_packus_epi16(r0, r1);
b1 = _mm_and_si128(_mm_xor_si128(b0, r0), mask);
b0 = _mm_xor_si128(b0, b1);
r0 = _mm_xor_si128(r0, b1);
// b1 g1 b3 g3 b5 g5...
b1 = _mm_unpackhi_epi8(b0, g0);
// b0 g0 b2 g2 b4 g4 ....
b0 = _mm_unpacklo_epi8(b0, g0);
// r1 0 r3 0 r5 0 ...
r1 = _mm_unpackhi_epi8(r0, z);
// r0 0 r2 0 r4 0 ...
r0 = _mm_unpacklo_epi8(r0, z);
// 0 b0 g0 r0 0 b2 g2 r2 ...
g0 = _mm_slli_si128(_mm_unpacklo_epi16(b0, r0), 1);
// 0 b8 g8 r8 0 b10 g10 r10 ...
g1 = _mm_slli_si128(_mm_unpackhi_epi16(b0, r0), 1);
// b1 g1 r1 0 b3 g3 r3 0 ...
r0 = _mm_unpacklo_epi16(b1, r1);
// b9 g9 r9 0 b11 g11 r11 0 ...
r1 = _mm_unpackhi_epi16(b1, r1);
// 0 b0 g0 r0 b1 g1 r1 0 ...
b0 = _mm_srli_si128(_mm_unpacklo_epi32(g0, r0), 1);
// 0 b4 g4 r4 b5 g5 r5 0 ...
b1 = _mm_srli_si128(_mm_unpackhi_epi32(g0, r0), 1);
_mm_storel_epi64((__m128i*)(dst-1+0), b0);
_mm_storel_epi64((__m128i*)(dst-1+6*1), _mm_srli_si128(b0, 8));
_mm_storel_epi64((__m128i*)(dst-1+6*2), b1);
_mm_storel_epi64((__m128i*)(dst-1+6*3), _mm_srli_si128(b1, 8));
// 0 b8 g8 r8 b9 g9 r9 0 ...
g0 = _mm_srli_si128(_mm_unpacklo_epi32(g1, r1), 1);
// 0 b12 g12 r12 b13 g13 r13 0 ...
g1 = _mm_srli_si128(_mm_unpackhi_epi32(g1, r1), 1);
_mm_storel_epi64((__m128i*)(dst-1+6*4), g0);
_mm_storel_epi64((__m128i*)(dst-1+6*5), _mm_srli_si128(g0, 8));
_mm_storel_epi64((__m128i*)(dst-1+6*6), g1);
}
return (int)(bayer - (bayer_end - width));
}
int bayer2RGBA(const uchar*, int, uchar*, int, int) const
{
return 0;
}
int bayer2RGB_EA(const uchar* bayer, int bayer_step, uchar* dst, int width, int blue) const
{
if (!use_simd)
return 0;
const uchar* bayer_end = bayer + width;
__m128i masklow = _mm_set1_epi16(0x00ff);
__m128i delta1 = _mm_set1_epi16(1), delta2 = _mm_set1_epi16(2);
__m128i full = _mm_set1_epi16(-1), z = _mm_setzero_si128();
__m128i mask = _mm_set1_epi16(blue > 0 ? -1 : 0);
for ( ; bayer <= bayer_end - 18; bayer += 14, dst += 42)
{
/*
B G B G | B G B G | B G B G | B G B G
G R G R | G R G R | G R G R | G R G R
B G B G | B G B G | B G B G | B G B G
*/
__m128i r0 = _mm_loadu_si128((const __m128i*)bayer);
__m128i r1 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step));
__m128i r2 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step*2));
__m128i b1 = _mm_add_epi16(_mm_and_si128(r0, masklow), _mm_and_si128(r2, masklow));
__m128i nextb1 = _mm_srli_si128(b1, 2);
__m128i b0 = _mm_add_epi16(b1, nextb1);
b1 = _mm_srli_epi16(_mm_add_epi16(nextb1, delta1), 1);
b0 = _mm_srli_epi16(_mm_add_epi16(b0, delta2), 2);
// b0 b2 ... b14 b1 b3 ... b15
b0 = _mm_packus_epi16(b0, b1);
// vertical sum
__m128i r0g = _mm_srli_epi16(r0, 8);
__m128i r2g = _mm_srli_epi16(r2, 8);
__m128i sumv = _mm_srli_epi16(_mm_add_epi16(_mm_add_epi16(r0g, r2g), delta1), 1);
// gorizontal sum
__m128i g1 = _mm_and_si128(masklow, r1);
__m128i nextg1 = _mm_srli_si128(g1, 2);
__m128i sumg = _mm_srli_epi16(_mm_add_epi16(_mm_add_epi16(g1, nextg1), delta1), 1);
// gradients
__m128i gradv = _mm_adds_epi16(_mm_subs_epu16(r0g, r2g), _mm_subs_epu16(r2g, r0g));
__m128i gradg = _mm_adds_epi16(_mm_subs_epu16(nextg1, g1), _mm_subs_epu16(g1, nextg1));
__m128i gmask = _mm_cmpgt_epi16(gradg, gradv);
__m128i g0 = _mm_add_epi16(_mm_and_si128(gmask, sumv), _mm_and_si128(sumg, _mm_xor_si128(gmask, full)));
// g0 g2 ... g14 g1 g3 ...
g0 = _mm_packus_epi16(g0, nextg1);
r0 = _mm_srli_epi16(r1, 8);
r1 = _mm_add_epi16(r0, _mm_srli_si128(r0, 2));
r1 = _mm_srli_epi16(_mm_add_epi16(r1, delta1), 1);
// r0 r2 ... r14 r1 r3 ... r15
r0 = _mm_packus_epi16(r0, r1);
b1 = _mm_and_si128(_mm_xor_si128(b0, r0), mask);
b0 = _mm_xor_si128(b0, b1);
r0 = _mm_xor_si128(r0, b1);
// b1 g1 b3 g3 b5 g5...
b1 = _mm_unpackhi_epi8(b0, g0);
// b0 g0 b2 g2 b4 g4 ....
b0 = _mm_unpacklo_epi8(b0, g0);
// r1 0 r3 0 r5 0 ...
r1 = _mm_unpackhi_epi8(r0, z);
// r0 0 r2 0 r4 0 ...
r0 = _mm_unpacklo_epi8(r0, z);
// 0 b0 g0 r0 0 b2 g2 r2 ...
g0 = _mm_slli_si128(_mm_unpacklo_epi16(b0, r0), 1);
// 0 b8 g8 r8 0 b10 g10 r10 ...
g1 = _mm_slli_si128(_mm_unpackhi_epi16(b0, r0), 1);
// b1 g1 r1 0 b3 g3 r3 0 ...
r0 = _mm_unpacklo_epi16(b1, r1);
// b9 g9 r9 0 b11 g11 r11 0 ...
r1 = _mm_unpackhi_epi16(b1, r1);
// 0 b0 g0 r0 b1 g1 r1 0 ...
b0 = _mm_srli_si128(_mm_unpacklo_epi32(g0, r0), 1);
// 0 b4 g4 r4 b5 g5 r5 0 ...
b1 = _mm_srli_si128(_mm_unpackhi_epi32(g0, r0), 1);
_mm_storel_epi64((__m128i*)(dst+0), b0);
_mm_storel_epi64((__m128i*)(dst+6*1), _mm_srli_si128(b0, 8));
_mm_storel_epi64((__m128i*)(dst+6*2), b1);
_mm_storel_epi64((__m128i*)(dst+6*3), _mm_srli_si128(b1, 8));
// 0 b8 g8 r8 b9 g9 r9 0 ...
g0 = _mm_srli_si128(_mm_unpacklo_epi32(g1, r1), 1);
// 0 b12 g12 r12 b13 g13 r13 0 ...
g1 = _mm_srli_si128(_mm_unpackhi_epi32(g1, r1), 1);
_mm_storel_epi64((__m128i*)(dst+6*4), g0);
_mm_storel_epi64((__m128i*)(dst+6*5), _mm_srli_si128(g0, 8));
_mm_storel_epi64((__m128i*)(dst+6*6), g1);
}
return int(bayer - (bayer_end - width));
}
bool use_simd;
};
#elif CV_NEON
class SIMDBayerInterpolator_8u
{
public:
SIMDBayerInterpolator_8u()
{
}
int bayer2Gray(const uchar* bayer, int bayer_step, uchar* dst,
int width, int bcoeff, int gcoeff, int rcoeff) const
{
/*
B G B G | B G B G | B G B G | B G B G
G R G R | G R G R | G R G R | G R G R
B G B G | B G B G | B G B G | B G B G
*/
uint16x8_t masklo = vdupq_n_u16(255);
const uchar* bayer_end = bayer + width;
for( ; bayer <= bayer_end - 18; bayer += 14, dst += 14 )
{
uint16x8_t r0 = vld1q_u16((const ushort*)bayer);
uint16x8_t r1 = vld1q_u16((const ushort*)(bayer + bayer_step));
uint16x8_t r2 = vld1q_u16((const ushort*)(bayer + bayer_step*2));
uint16x8_t b1_ = vaddq_u16(vandq_u16(r0, masklo), vandq_u16(r2, masklo));
uint16x8_t b1 = vextq_u16(b1_, b1_, 1);
uint16x8_t b0 = vaddq_u16(b1_, b1);
// b0 = b0 b2 b4 ...
// b1 = b1 b3 b5 ...
uint16x8_t g0 = vaddq_u16(vshrq_n_u16(r0, 8), vshrq_n_u16(r2, 8));
uint16x8_t g1 = vandq_u16(r1, masklo);
g0 = vaddq_u16(g0, vaddq_u16(g1, vextq_u16(g1, g1, 1)));
g1 = vshlq_n_u16(vextq_u16(g1, g1, 1), 2);
// g0 = b0 b2 b4 ...
// g1 = b1 b3 b5 ...
r0 = vshrq_n_u16(r1, 8);
r1 = vaddq_u16(r0, vextq_u16(r0, r0, 1));
r0 = vshlq_n_u16(r0, 2);
// r0 = r0 r2 r4 ...
// r1 = r1 r3 r5 ...
b0 = vreinterpretq_u16_s16(vqdmulhq_n_s16(vreinterpretq_s16_u16(b0), (short)(rcoeff*2)));
b1 = vreinterpretq_u16_s16(vqdmulhq_n_s16(vreinterpretq_s16_u16(b1), (short)(rcoeff*4)));
g0 = vreinterpretq_u16_s16(vqdmulhq_n_s16(vreinterpretq_s16_u16(g0), (short)(gcoeff*2)));
g1 = vreinterpretq_u16_s16(vqdmulhq_n_s16(vreinterpretq_s16_u16(g1), (short)(gcoeff*2)));
r0 = vreinterpretq_u16_s16(vqdmulhq_n_s16(vreinterpretq_s16_u16(r0), (short)(bcoeff*2)));
r1 = vreinterpretq_u16_s16(vqdmulhq_n_s16(vreinterpretq_s16_u16(r1), (short)(bcoeff*4)));
g0 = vaddq_u16(vaddq_u16(g0, b0), r0);
g1 = vaddq_u16(vaddq_u16(g1, b1), r1);
uint8x8x2_t p = vzip_u8(vrshrn_n_u16(g0, 2), vrshrn_n_u16(g1, 2));
vst1_u8(dst, p.val[0]);
vst1_u8(dst + 8, p.val[1]);
}
return (int)(bayer - (bayer_end - width));
}
int bayer2RGB(const uchar* bayer, int bayer_step, uchar* dst, int width, int blue) const
{
/*
B G B G | B G B G | B G B G | B G B G
G R G R | G R G R | G R G R | G R G R
B G B G | B G B G | B G B G | B G B G
*/
uint16x8_t masklo = vdupq_n_u16(255);
uint8x16x3_t pix;
const uchar* bayer_end = bayer + width;
for( ; bayer <= bayer_end - 18; bayer += 14, dst += 42 )
{
uint16x8_t r0 = vld1q_u16((const ushort*)bayer);
uint16x8_t r1 = vld1q_u16((const ushort*)(bayer + bayer_step));
uint16x8_t r2 = vld1q_u16((const ushort*)(bayer + bayer_step*2));
uint16x8_t b1 = vaddq_u16(vandq_u16(r0, masklo), vandq_u16(r2, masklo));
uint16x8_t nextb1 = vextq_u16(b1, b1, 1);
uint16x8_t b0 = vaddq_u16(b1, nextb1);
// b0 b1 b2 ...
uint8x8x2_t bb = vzip_u8(vrshrn_n_u16(b0, 2), vrshrn_n_u16(nextb1, 1));
pix.val[1-blue] = vcombine_u8(bb.val[0], bb.val[1]);
uint16x8_t g0 = vaddq_u16(vshrq_n_u16(r0, 8), vshrq_n_u16(r2, 8));
uint16x8_t g1 = vandq_u16(r1, masklo);
g0 = vaddq_u16(g0, vaddq_u16(g1, vextq_u16(g1, g1, 1)));
g1 = vextq_u16(g1, g1, 1);
// g0 g1 g2 ...
uint8x8x2_t gg = vzip_u8(vrshrn_n_u16(g0, 2), vmovn_u16(g1));
pix.val[1] = vcombine_u8(gg.val[0], gg.val[1]);
r0 = vshrq_n_u16(r1, 8);
r1 = vaddq_u16(r0, vextq_u16(r0, r0, 1));
// r0 r1 r2 ...
uint8x8x2_t rr = vzip_u8(vmovn_u16(r0), vrshrn_n_u16(r1, 1));
pix.val[1+blue] = vcombine_u8(rr.val[0], rr.val[1]);
vst3q_u8(dst-1, pix);
}
return (int)(bayer - (bayer_end - width));
}
int bayer2RGBA(const uchar* bayer, int bayer_step, uchar* dst, int width, int blue) const
{
/*
B G B G | B G B G | B G B G | B G B G
G R G R | G R G R | G R G R | G R G R
B G B G | B G B G | B G B G | B G B G
*/
uint16x8_t masklo = vdupq_n_u16(255);
uint8x16x4_t pix;
const uchar* bayer_end = bayer + width;
pix.val[3] = vdupq_n_u8(255);
for( ; bayer <= bayer_end - 18; bayer += 14, dst += 56 )
{
uint16x8_t r0 = vld1q_u16((const ushort*)bayer);
uint16x8_t r1 = vld1q_u16((const ushort*)(bayer + bayer_step));
uint16x8_t r2 = vld1q_u16((const ushort*)(bayer + bayer_step*2));
uint16x8_t b1 = vaddq_u16(vandq_u16(r0, masklo), vandq_u16(r2, masklo));
uint16x8_t nextb1 = vextq_u16(b1, b1, 1);
uint16x8_t b0 = vaddq_u16(b1, nextb1);
// b0 b1 b2 ...
uint8x8x2_t bb = vzip_u8(vrshrn_n_u16(b0, 2), vrshrn_n_u16(nextb1, 1));
pix.val[1-blue] = vcombine_u8(bb.val[0], bb.val[1]);
uint16x8_t g0 = vaddq_u16(vshrq_n_u16(r0, 8), vshrq_n_u16(r2, 8));
uint16x8_t g1 = vandq_u16(r1, masklo);
g0 = vaddq_u16(g0, vaddq_u16(g1, vextq_u16(g1, g1, 1)));
g1 = vextq_u16(g1, g1, 1);
// g0 g1 g2 ...
uint8x8x2_t gg = vzip_u8(vrshrn_n_u16(g0, 2), vmovn_u16(g1));
pix.val[1] = vcombine_u8(gg.val[0], gg.val[1]);
r0 = vshrq_n_u16(r1, 8);
r1 = vaddq_u16(r0, vextq_u16(r0, r0, 1));
// r0 r1 r2 ...
uint8x8x2_t rr = vzip_u8(vmovn_u16(r0), vrshrn_n_u16(r1, 1));
pix.val[1+blue] = vcombine_u8(rr.val[0], rr.val[1]);
vst4q_u8(dst-1, pix);
}
return (int)(bayer - (bayer_end - width));
}
int bayer2RGB_EA(const uchar*, int, uchar*, int, int) const
{
return 0;
}
};
#else
typedef SIMDBayerStubInterpolator_<uchar> SIMDBayerInterpolator_8u;
#endif
template<typename T, class SIMDInterpolator>
class Bayer2Gray_Invoker :
public ParallelLoopBody
{
public:
Bayer2Gray_Invoker(const Mat& _srcmat, Mat& _dstmat, int _start_with_green, bool _brow,
const Size& _size, int _bcoeff, int _rcoeff) :
ParallelLoopBody(), srcmat(_srcmat), dstmat(_dstmat), Start_with_green(_start_with_green),
Brow(_brow), size(_size), Bcoeff(_bcoeff), Rcoeff(_rcoeff)
{
}
virtual void operator ()(const Range& range) const
{
SIMDInterpolator vecOp;
const int G2Y = 9617;
const int SHIFT = 14;
const T* bayer0 = (const T*)srcmat.data;
int bayer_step = (int)(srcmat.step/sizeof(T));
T* dst0 = (T*)dstmat.data;
int dst_step = (int)(dstmat.step/sizeof(T));
int bcoeff = Bcoeff, rcoeff = Rcoeff;
int start_with_green = Start_with_green;
bool brow = Brow;
dst0 += dst_step + 1;
if (range.start % 2)
{
brow = !brow;
std::swap(bcoeff, rcoeff);
start_with_green = !start_with_green;
}
bayer0 += range.start * bayer_step;
dst0 += range.start * dst_step;
for(int i = range.start ; i < range.end; ++i, bayer0 += bayer_step, dst0 += dst_step )
{
unsigned t0, t1, t2;
const T* bayer = bayer0;
T* dst = dst0;
const T* bayer_end = bayer + size.width;
if( size.width <= 0 )
{
dst[-1] = dst[size.width] = 0;
continue;
}
if( start_with_green )
{
t0 = (bayer[1] + bayer[bayer_step*2+1])*rcoeff;
t1 = (bayer[bayer_step] + bayer[bayer_step+2])*bcoeff;
t2 = bayer[bayer_step+1]*(2*G2Y);
dst[0] = (T)CV_DESCALE(t0 + t1 + t2, SHIFT+1);
bayer++;
dst++;
}
int delta = vecOp.bayer2Gray(bayer, bayer_step, dst, size.width, bcoeff, G2Y, rcoeff);
bayer += delta;
dst += delta;
for( ; bayer <= bayer_end - 2; bayer += 2, dst += 2 )
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] + bayer[bayer_step*2+2])*rcoeff;
t1 = (bayer[1] + bayer[bayer_step] + bayer[bayer_step+2] + bayer[bayer_step*2+1])*G2Y;
t2 = bayer[bayer_step+1]*(4*bcoeff);
dst[0] = (T)CV_DESCALE(t0 + t1 + t2, SHIFT+2);
t0 = (bayer[2] + bayer[bayer_step*2+2])*rcoeff;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3])*bcoeff;
t2 = bayer[bayer_step+2]*(2*G2Y);
dst[1] = (T)CV_DESCALE(t0 + t1 + t2, SHIFT+1);
}
if( bayer < bayer_end )
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] + bayer[bayer_step*2+2])*rcoeff;
t1 = (bayer[1] + bayer[bayer_step] + bayer[bayer_step+2] + bayer[bayer_step*2+1])*G2Y;
t2 = bayer[bayer_step+1]*(4*bcoeff);
dst[0] = (T)CV_DESCALE(t0 + t1 + t2, SHIFT+2);
bayer++;
dst++;
}
dst0[-1] = dst0[0];
dst0[size.width] = dst0[size.width-1];
brow = !brow;
std::swap(bcoeff, rcoeff);
start_with_green = !start_with_green;
}
}
private:
Mat srcmat;
Mat dstmat;
int Start_with_green;
bool Brow;
Size size;
int Bcoeff, Rcoeff;
};
template<typename T, typename SIMDInterpolator>
static void Bayer2Gray_( const Mat& srcmat, Mat& dstmat, int code )
{
const int R2Y = 4899;
const int B2Y = 1868;
Size size = srcmat.size();
int bcoeff = B2Y, rcoeff = R2Y;
int start_with_green = code == CV_BayerGB2GRAY || code == CV_BayerGR2GRAY;
bool brow = true;
if( code != CV_BayerBG2GRAY && code != CV_BayerGB2GRAY )
{
brow = false;
std::swap(bcoeff, rcoeff);
}
size.height -= 2;
size.width -= 2;
if (size.height > 0)
{
Range range(0, size.height);
Bayer2Gray_Invoker<T, SIMDInterpolator> invoker(srcmat, dstmat,
start_with_green, brow, size, bcoeff, rcoeff);
parallel_for_(range, invoker, dstmat.total()/static_cast<double>(1<<16));
}
size = dstmat.size();
T* dst0 = (T*)dstmat.data;
int dst_step = (int)(dstmat.step/sizeof(T));
if( size.height > 2 )
for( int i = 0; i < size.width; i++ )
{
dst0[i] = dst0[i + dst_step];
dst0[i + (size.height-1)*dst_step] = dst0[i + (size.height-2)*dst_step];
}
else
for( int i = 0; i < size.width; i++ )
dst0[i] = dst0[i + (size.height-1)*dst_step] = 0;
}
template <typename T>
struct Alpha
{
static T value() { return std::numeric_limits<T>::max(); }
};
template <>
struct Alpha<float>
{
static float value() { return 1.0f; }
};
template <typename T, typename SIMDInterpolator>
class Bayer2RGB_Invoker :
public ParallelLoopBody
{
public:
Bayer2RGB_Invoker(const Mat& _srcmat, Mat& _dstmat, int _start_with_green, int _blue, const Size& _size) :
ParallelLoopBody(),
srcmat(_srcmat), dstmat(_dstmat), Start_with_green(_start_with_green), Blue(_blue), size(_size)
{
}
virtual void operator() (const Range& range) const
{
SIMDInterpolator vecOp;
T alpha = Alpha<T>::value();
int dcn = dstmat.channels();
int dcn2 = dcn << 1;
int bayer_step = (int)(srcmat.step/sizeof(T));
const T* bayer0 = reinterpret_cast<const T*>(srcmat.data) + bayer_step * range.start;
int dst_step = (int)(dstmat.step/sizeof(T));
T* dst0 = reinterpret_cast<T*>(dstmat.data) + (range.start + 1) * dst_step + dcn + 1;
int blue = Blue, start_with_green = Start_with_green;
if (range.start % 2)
{
blue = -blue;
start_with_green = !start_with_green;
}
for (int i = range.start; i < range.end; bayer0 += bayer_step, dst0 += dst_step, ++i )
{
int t0, t1;
const T* bayer = bayer0;
T* dst = dst0;
const T* bayer_end = bayer + size.width;
// in case of when size.width <= 2
if( size.width <= 0 )
{
if (dcn == 3)
{
dst[-4] = dst[-3] = dst[-2] = dst[size.width*dcn-1] =
dst[size.width*dcn] = dst[size.width*dcn+1] = 0;
}
else
{
dst[-5] = dst[-4] = dst[-3] = dst[size.width*dcn-1] =
dst[size.width*dcn] = dst[size.width*dcn+1] = 0;
dst[-2] = dst[size.width*dcn+2] = alpha;
}
continue;
}
if( start_with_green )
{
t0 = (bayer[1] + bayer[bayer_step*2+1] + 1) >> 1;
t1 = (bayer[bayer_step] + bayer[bayer_step+2] + 1) >> 1;
dst[-blue] = (T)t0;
dst[0] = bayer[bayer_step+1];
dst[blue] = (T)t1;
if (dcn == 4)
dst[2] = alpha; // alpha channel
bayer++;
dst += dcn;
}
// simd optimization only for dcn == 3
int delta = dcn == 4 ?
vecOp.bayer2RGBA(bayer, bayer_step, dst, size.width, blue) :
vecOp.bayer2RGB(bayer, bayer_step, dst, size.width, blue);
bayer += delta;
dst += delta*dcn;
if (dcn == 3) // Bayer to BGR
{
if( blue > 0 )
{
for( ; bayer <= bayer_end - 2; bayer += 2, dst += dcn2 )
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
bayer[bayer_step*2+2] + 2) >> 2;
t1 = (bayer[1] + bayer[bayer_step] +
bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
dst[-1] = (T)t0;
dst[0] = (T)t1;
dst[1] = bayer[bayer_step+1];
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
dst[2] = (T)t0;
dst[3] = bayer[bayer_step+2];
dst[4] = (T)t1;
}
}
else
{
for( ; bayer <= bayer_end - 2; bayer += 2, dst += dcn2 )
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
bayer[bayer_step*2+2] + 2) >> 2;
t1 = (bayer[1] + bayer[bayer_step] +
bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
dst[1] = (T)t0;
dst[0] = (T)t1;
dst[-1] = bayer[bayer_step+1];
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
dst[4] = (T)t0;
dst[3] = bayer[bayer_step+2];
dst[2] = (T)t1;
}
}
}
else // Bayer to BGRA
{
// if current row does not contain Blue pixels
if( blue > 0 )
{
for( ; bayer <= bayer_end - 2; bayer += 2, dst += dcn2 )
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
bayer[bayer_step*2+2] + 2) >> 2;
t1 = (bayer[1] + bayer[bayer_step] +
bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
dst[-1] = (T)t0;
dst[0] = (T)t1;
dst[1] = bayer[bayer_step+1];
dst[2] = alpha; // alpha channel
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
dst[3] = (T)t0;
dst[4] = bayer[bayer_step+2];
dst[5] = (T)t1;
dst[6] = alpha; // alpha channel
}
}
else // if current row contains Blue pixels
{
for( ; bayer <= bayer_end - 2; bayer += 2, dst += dcn2 )
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
bayer[bayer_step*2+2] + 2) >> 2;
t1 = (bayer[1] + bayer[bayer_step] +
bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
dst[-1] = bayer[bayer_step+1];
dst[0] = (T)t1;
dst[1] = (T)t0;
dst[2] = alpha; // alpha channel
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
dst[3] = (T)t1;
dst[4] = bayer[bayer_step+2];
dst[5] = (T)t0;
dst[6] = alpha; // alpha channel
}
}
}
// if skip one pixel at the end of row
if( bayer < bayer_end )
{
t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
bayer[bayer_step*2+2] + 2) >> 2;
t1 = (bayer[1] + bayer[bayer_step] +
bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
dst[-blue] = (T)t0;
dst[0] = (T)t1;
dst[blue] = bayer[bayer_step+1];
if (dcn == 4)
dst[2] = alpha; // alpha channel
bayer++;
dst += dcn;
}
// fill the last and the first pixels of row accordingly
if (dcn == 3)
{
dst0[-4] = dst0[-1];
dst0[-3] = dst0[0];
dst0[-2] = dst0[1];
dst0[size.width*dcn-1] = dst0[size.width*dcn-4];
dst0[size.width*dcn] = dst0[size.width*dcn-3];
dst0[size.width*dcn+1] = dst0[size.width*dcn-2];
}
else
{
dst0[-5] = dst0[-1];
dst0[-4] = dst0[0];
dst0[-3] = dst0[1];
dst0[-2] = dst0[2]; // alpha channel
dst0[size.width*dcn-1] = dst0[size.width*dcn-5];
dst0[size.width*dcn] = dst0[size.width*dcn-4];
dst0[size.width*dcn+1] = dst0[size.width*dcn-3];
dst0[size.width*dcn+2] = dst0[size.width*dcn-2]; // alpha channel
}
blue = -blue;
start_with_green = !start_with_green;
}
}
private:
Mat srcmat;
Mat dstmat;
int Start_with_green, Blue;
Size size;
};
template<typename T, class SIMDInterpolator>
static void Bayer2RGB_( const Mat& srcmat, Mat& dstmat, int code )
{
int dst_step = (int)(dstmat.step/sizeof(T));
Size size = srcmat.size();
int blue = code == CV_BayerBG2BGR || code == CV_BayerGB2BGR ? -1 : 1;
int start_with_green = code == CV_BayerGB2BGR || code == CV_BayerGR2BGR;
int dcn = dstmat.channels();
size.height -= 2;
size.width -= 2;
if (size.height > 0)
{
Range range(0, size.height);
Bayer2RGB_Invoker<T, SIMDInterpolator> invoker(srcmat, dstmat, start_with_green, blue, size);
parallel_for_(range, invoker, dstmat.total()/static_cast<double>(1<<16));
}
// filling the first and the last rows
size = dstmat.size();
T* dst0 = (T*)dstmat.data;
if( size.height > 2 )
for( int i = 0; i < size.width*dcn; i++ )
{
dst0[i] = dst0[i + dst_step];
dst0[i + (size.height-1)*dst_step] = dst0[i + (size.height-2)*dst_step];
}
else
for( int i = 0; i < size.width*dcn; i++ )
dst0[i] = dst0[i + (size.height-1)*dst_step] = 0;
}
/////////////////// Demosaicing using Variable Number of Gradients ///////////////////////
static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
{
const uchar* bayer = srcmat.data;
int bstep = (int)srcmat.step;
uchar* dst = dstmat.data;
int dststep = (int)dstmat.step;
Size size = srcmat.size();
int blueIdx = code == CV_BayerBG2BGR_VNG || code == CV_BayerGB2BGR_VNG ? 0 : 2;
bool greenCell0 = code != CV_BayerBG2BGR_VNG && code != CV_BayerRG2BGR_VNG;
// for too small images use the simple interpolation algorithm
if( MIN(size.width, size.height) < 8 )
{
Bayer2RGB_<uchar, SIMDBayerInterpolator_8u>( srcmat, dstmat, code );
return;
}
const int brows = 3, bcn = 7;
int N = size.width, N2 = N*2, N3 = N*3, N4 = N*4, N5 = N*5, N6 = N*6, N7 = N*7;
int i, bufstep = N7*bcn;
cv::AutoBuffer<ushort> _buf(bufstep*brows);
ushort* buf = (ushort*)_buf;
bayer += bstep*2;
#if CV_SSE2
bool haveSSE = cv::checkHardwareSupport(CV_CPU_SSE2);
#define _mm_absdiff_epu16(a,b) _mm_adds_epu16(_mm_subs_epu16(a, b), _mm_subs_epu16(b, a))
#endif
for( int y = 2; y < size.height - 4; y++ )
{
uchar* dstrow = dst + dststep*y + 6;
const uchar* srow;
for( int dy = (y == 2 ? -1 : 1); dy <= 1; dy++ )
{
ushort* brow = buf + ((y + dy - 1)%brows)*bufstep + 1;
srow = bayer + (y+dy)*bstep + 1;
for( i = 0; i < bcn; i++ )
brow[N*i-1] = brow[(N-2) + N*i] = 0;
i = 1;
#if CV_SSE2
if( haveSSE )
{
__m128i z = _mm_setzero_si128();
for( ; i <= N-9; i += 8, srow += 8, brow += 8 )
{
__m128i s1, s2, s3, s4, s6, s7, s8, s9;
s1 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow-1-bstep)),z);
s2 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow-bstep)),z);
s3 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow+1-bstep)),z);
s4 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow-1)),z);
s6 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow+1)),z);
s7 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow-1+bstep)),z);
s8 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow+bstep)),z);
s9 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow+1+bstep)),z);
__m128i b0, b1, b2, b3, b4, b5, b6;
b0 = _mm_adds_epu16(_mm_slli_epi16(_mm_absdiff_epu16(s2,s8),1),
_mm_adds_epu16(_mm_absdiff_epu16(s1, s7),
_mm_absdiff_epu16(s3, s9)));
b1 = _mm_adds_epu16(_mm_slli_epi16(_mm_absdiff_epu16(s4,s6),1),
_mm_adds_epu16(_mm_absdiff_epu16(s1, s3),
_mm_absdiff_epu16(s7, s9)));
b2 = _mm_slli_epi16(_mm_absdiff_epu16(s3,s7),1);
b3 = _mm_slli_epi16(_mm_absdiff_epu16(s1,s9),1);
_mm_storeu_si128((__m128i*)brow, b0);
_mm_storeu_si128((__m128i*)(brow + N), b1);
_mm_storeu_si128((__m128i*)(brow + N2), b2);
_mm_storeu_si128((__m128i*)(brow + N3), b3);
b4 = _mm_adds_epu16(b2,_mm_adds_epu16(_mm_absdiff_epu16(s2, s4),
_mm_absdiff_epu16(s6, s8)));
b5 = _mm_adds_epu16(b3,_mm_adds_epu16(_mm_absdiff_epu16(s2, s6),
_mm_absdiff_epu16(s4, s8)));
b6 = _mm_adds_epu16(_mm_adds_epu16(s2, s4), _mm_adds_epu16(s6, s8));
b6 = _mm_srli_epi16(b6, 1);
_mm_storeu_si128((__m128i*)(brow + N4), b4);
_mm_storeu_si128((__m128i*)(brow + N5), b5);
_mm_storeu_si128((__m128i*)(brow + N6), b6);
}
}
#endif
for( ; i < N-1; i++, srow++, brow++ )
{
brow[0] = (ushort)(std::abs(srow[-1-bstep] - srow[-1+bstep]) +
std::abs(srow[-bstep] - srow[+bstep])*2 +
std::abs(srow[1-bstep] - srow[1+bstep]));
brow[N] = (ushort)(std::abs(srow[-1-bstep] - srow[1-bstep]) +
std::abs(srow[-1] - srow[1])*2 +
std::abs(srow[-1+bstep] - srow[1+bstep]));
brow[N2] = (ushort)(std::abs(srow[+1-bstep] - srow[-1+bstep])*2);
brow[N3] = (ushort)(std::abs(srow[-1-bstep] - srow[1+bstep])*2);
brow[N4] = (ushort)(brow[N2] + std::abs(srow[-bstep] - srow[-1]) +
std::abs(srow[+bstep] - srow[1]));
brow[N5] = (ushort)(brow[N3] + std::abs(srow[-bstep] - srow[1]) +
std::abs(srow[+bstep] - srow[-1]));
brow[N6] = (ushort)((srow[-bstep] + srow[-1] + srow[1] + srow[+bstep])>>1);
}
}
const ushort* brow0 = buf + ((y - 2) % brows)*bufstep + 2;
const ushort* brow1 = buf + ((y - 1) % brows)*bufstep + 2;
const ushort* brow2 = buf + (y % brows)*bufstep + 2;
static const float scale[] = { 0.f, 0.5f, 0.25f, 0.1666666666667f, 0.125f, 0.1f, 0.08333333333f, 0.0714286f, 0.0625f };
srow = bayer + y*bstep + 2;
bool greenCell = greenCell0;
i = 2;
#if CV_SSE2
int limit = !haveSSE ? N-2 : greenCell ? std::min(3, N-2) : 2;
#else
int limit = N - 2;
#endif
do
{
for( ; i < limit; i++, srow++, brow0++, brow1++, brow2++, dstrow += 3 )
{
int gradN = brow0[0] + brow1[0];
int gradS = brow1[0] + brow2[0];
int gradW = brow1[N-1] + brow1[N];
int gradE = brow1[N] + brow1[N+1];
int minGrad = std::min(std::min(std::min(gradN, gradS), gradW), gradE);
int maxGrad = std::max(std::max(std::max(gradN, gradS), gradW), gradE);
int R, G, B;
if( !greenCell )
{
int gradNE = brow0[N4+1] + brow1[N4];
int gradSW = brow1[N4] + brow2[N4-1];
int gradNW = brow0[N5-1] + brow1[N5];
int gradSE = brow1[N5] + brow2[N5+1];
minGrad = std::min(std::min(std::min(std::min(minGrad, gradNE), gradSW), gradNW), gradSE);
maxGrad = std::max(std::max(std::max(std::max(maxGrad, gradNE), gradSW), gradNW), gradSE);
int T = minGrad + MAX(maxGrad/2, 1);
int Rs = 0, Gs = 0, Bs = 0, ng = 0;
if( gradN < T )
{
Rs += srow[-bstep*2] + srow[0];
Gs += srow[-bstep]*2;
Bs += srow[-bstep-1] + srow[-bstep+1];
ng++;
}
if( gradS < T )
{
Rs += srow[bstep*2] + srow[0];
Gs += srow[bstep]*2;
Bs += srow[bstep-1] + srow[bstep+1];
ng++;
}
if( gradW < T )
{
Rs += srow[-2] + srow[0];
Gs += srow[-1]*2;
Bs += srow[-bstep-1] + srow[bstep-1];
ng++;
}
if( gradE < T )
{
Rs += srow[2] + srow[0];
Gs += srow[1]*2;
Bs += srow[-bstep+1] + srow[bstep+1];
ng++;
}
if( gradNE < T )
{
Rs += srow[-bstep*2+2] + srow[0];
Gs += brow0[N6+1];
Bs += srow[-bstep+1]*2;
ng++;
}
if( gradSW < T )
{
Rs += srow[bstep*2-2] + srow[0];
Gs += brow2[N6-1];
Bs += srow[bstep-1]*2;
ng++;
}
if( gradNW < T )
{
Rs += srow[-bstep*2-2] + srow[0];
Gs += brow0[N6-1];
Bs += srow[-bstep+1]*2;
ng++;
}
if( gradSE < T )
{
Rs += srow[bstep*2+2] + srow[0];
Gs += brow2[N6+1];
Bs += srow[-bstep+1]*2;
ng++;
}
R = srow[0];
G = R + cvRound((Gs - Rs)*scale[ng]);
B = R + cvRound((Bs - Rs)*scale[ng]);
}
else
{
int gradNE = brow0[N2] + brow0[N2+1] + brow1[N2] + brow1[N2+1];
int gradSW = brow1[N2] + brow1[N2-1] + brow2[N2] + brow2[N2-1];
int gradNW = brow0[N3] + brow0[N3-1] + brow1[N3] + brow1[N3-1];
int gradSE = brow1[N3] + brow1[N3+1] + brow2[N3] + brow2[N3+1];
minGrad = std::min(std::min(std::min(std::min(minGrad, gradNE), gradSW), gradNW), gradSE);
maxGrad = std::max(std::max(std::max(std::max(maxGrad, gradNE), gradSW), gradNW), gradSE);
int T = minGrad + MAX(maxGrad/2, 1);
int Rs = 0, Gs = 0, Bs = 0, ng = 0;
if( gradN < T )
{
Rs += srow[-bstep*2-1] + srow[-bstep*2+1];
Gs += srow[-bstep*2] + srow[0];
Bs += srow[-bstep]*2;
ng++;
}
if( gradS < T )
{
Rs += srow[bstep*2-1] + srow[bstep*2+1];
Gs += srow[bstep*2] + srow[0];
Bs += srow[bstep]*2;
ng++;
}
if( gradW < T )
{
Rs += srow[-1]*2;
Gs += srow[-2] + srow[0];
Bs += srow[-bstep-2]+srow[bstep-2];
ng++;
}
if( gradE < T )
{
Rs += srow[1]*2;
Gs += srow[2] + srow[0];
Bs += srow[-bstep+2]+srow[bstep+2];
ng++;
}
if( gradNE < T )
{
Rs += srow[-bstep*2+1] + srow[1];
Gs += srow[-bstep+1]*2;
Bs += srow[-bstep] + srow[-bstep+2];
ng++;
}
if( gradSW < T )
{
Rs += srow[bstep*2-1] + srow[-1];
Gs += srow[bstep-1]*2;
Bs += srow[bstep] + srow[bstep-2];
ng++;
}
if( gradNW < T )
{
Rs += srow[-bstep*2-1] + srow[-1];
Gs += srow[-bstep-1]*2;
Bs += srow[-bstep-2]+srow[-bstep];
ng++;
}
if( gradSE < T )
{
Rs += srow[bstep*2+1] + srow[1];
Gs += srow[bstep+1]*2;
Bs += srow[bstep+2]+srow[bstep];
ng++;
}
G = srow[0];
R = G + cvRound((Rs - Gs)*scale[ng]);
B = G + cvRound((Bs - Gs)*scale[ng]);
}
dstrow[blueIdx] = cv::saturate_cast<uchar>(B);
dstrow[1] = cv::saturate_cast<uchar>(G);
dstrow[blueIdx^2] = cv::saturate_cast<uchar>(R);
greenCell = !greenCell;
}
#if CV_SSE2
if( !haveSSE )
break;
__m128i emask = _mm_set1_epi32(0x0000ffff),
omask = _mm_set1_epi32(0xffff0000),
z = _mm_setzero_si128(),
one = _mm_set1_epi16(1);
__m128 _0_5 = _mm_set1_ps(0.5f);
#define _mm_merge_epi16(a, b) _mm_or_si128(_mm_and_si128(a, emask), _mm_and_si128(b, omask)) //(aA_aA_aA_aA) * (bB_bB_bB_bB) => (bA_bA_bA_bA)
#define _mm_cvtloepi16_ps(a) _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(a,a), 16)) //(1,2,3,4,5,6,7,8) => (1f,2f,3f,4f)
#define _mm_cvthiepi16_ps(a) _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpackhi_epi16(a,a), 16)) //(1,2,3,4,5,6,7,8) => (5f,6f,7f,8f)
#define _mm_loadl_u8_s16(ptr, offset) _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)((ptr) + (offset))), z) //load 8 uchars to 8 shorts
// process 8 pixels at once
for( ; i <= N - 10; i += 8, srow += 8, brow0 += 8, brow1 += 8, brow2 += 8 )
{
//int gradN = brow0[0] + brow1[0];
__m128i gradN = _mm_adds_epi16(_mm_loadu_si128((__m128i*)brow0), _mm_loadu_si128((__m128i*)brow1));
//int gradS = brow1[0] + brow2[0];
__m128i gradS = _mm_adds_epi16(_mm_loadu_si128((__m128i*)brow1), _mm_loadu_si128((__m128i*)brow2));
//int gradW = brow1[N-1] + brow1[N];
__m128i gradW = _mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow1+N-1)), _mm_loadu_si128((__m128i*)(brow1+N)));
//int gradE = brow1[N+1] + brow1[N];
__m128i gradE = _mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow1+N+1)), _mm_loadu_si128((__m128i*)(brow1+N)));
//int minGrad = std::min(std::min(std::min(gradN, gradS), gradW), gradE);
//int maxGrad = std::max(std::max(std::max(gradN, gradS), gradW), gradE);
__m128i minGrad = _mm_min_epi16(_mm_min_epi16(gradN, gradS), _mm_min_epi16(gradW, gradE));
__m128i maxGrad = _mm_max_epi16(_mm_max_epi16(gradN, gradS), _mm_max_epi16(gradW, gradE));
__m128i grad0, grad1;
//int gradNE = brow0[N4+1] + brow1[N4];
//int gradNE = brow0[N2] + brow0[N2+1] + brow1[N2] + brow1[N2+1];
grad0 = _mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow0+N4+1)), _mm_loadu_si128((__m128i*)(brow1+N4)));
grad1 = _mm_adds_epi16( _mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow0+N2)), _mm_loadu_si128((__m128i*)(brow0+N2+1))),
_mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow1+N2)), _mm_loadu_si128((__m128i*)(brow1+N2+1))));
__m128i gradNE = _mm_merge_epi16(grad0, grad1);
//int gradSW = brow1[N4] + brow2[N4-1];
//int gradSW = brow1[N2] + brow1[N2-1] + brow2[N2] + brow2[N2-1];
grad0 = _mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow2+N4-1)), _mm_loadu_si128((__m128i*)(brow1+N4)));
grad1 = _mm_adds_epi16(_mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow2+N2)), _mm_loadu_si128((__m128i*)(brow2+N2-1))),
_mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow1+N2)), _mm_loadu_si128((__m128i*)(brow1+N2-1))));
__m128i gradSW = _mm_merge_epi16(grad0, grad1);
minGrad = _mm_min_epi16(_mm_min_epi16(minGrad, gradNE), gradSW);
maxGrad = _mm_max_epi16(_mm_max_epi16(maxGrad, gradNE), gradSW);
//int gradNW = brow0[N5-1] + brow1[N5];
//int gradNW = brow0[N3] + brow0[N3-1] + brow1[N3] + brow1[N3-1];
grad0 = _mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow0+N5-1)), _mm_loadu_si128((__m128i*)(brow1+N5)));
grad1 = _mm_adds_epi16(_mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow0+N3)), _mm_loadu_si128((__m128i*)(brow0+N3-1))),
_mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow1+N3)), _mm_loadu_si128((__m128i*)(brow1+N3-1))));
__m128i gradNW = _mm_merge_epi16(grad0, grad1);
//int gradSE = brow1[N5] + brow2[N5+1];
//int gradSE = brow1[N3] + brow1[N3+1] + brow2[N3] + brow2[N3+1];
grad0 = _mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow2+N5+1)), _mm_loadu_si128((__m128i*)(brow1+N5)));
grad1 = _mm_adds_epi16(_mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow2+N3)), _mm_loadu_si128((__m128i*)(brow2+N3+1))),
_mm_adds_epi16(_mm_loadu_si128((__m128i*)(brow1+N3)), _mm_loadu_si128((__m128i*)(brow1+N3+1))));
__m128i gradSE = _mm_merge_epi16(grad0, grad1);
minGrad = _mm_min_epi16(_mm_min_epi16(minGrad, gradNW), gradSE);
maxGrad = _mm_max_epi16(_mm_max_epi16(maxGrad, gradNW), gradSE);
//int T = minGrad + maxGrad/2;
__m128i T = _mm_adds_epi16(_mm_max_epi16(_mm_srli_epi16(maxGrad, 1), one), minGrad);
__m128i RGs = z, GRs = z, Bs = z, ng = z;
__m128i x0 = _mm_loadl_u8_s16(srow, +0 );
__m128i x1 = _mm_loadl_u8_s16(srow, -1 - bstep );
__m128i x2 = _mm_loadl_u8_s16(srow, -1 - bstep*2);
__m128i x3 = _mm_loadl_u8_s16(srow, - bstep );
__m128i x4 = _mm_loadl_u8_s16(srow, +1 - bstep*2);
__m128i x5 = _mm_loadl_u8_s16(srow, +1 - bstep );
__m128i x6 = _mm_loadl_u8_s16(srow, +2 - bstep );
__m128i x7 = _mm_loadl_u8_s16(srow, +1 );
__m128i x8 = _mm_loadl_u8_s16(srow, +2 + bstep );
__m128i x9 = _mm_loadl_u8_s16(srow, +1 + bstep );
__m128i x10 = _mm_loadl_u8_s16(srow, +1 + bstep*2);
__m128i x11 = _mm_loadl_u8_s16(srow, + bstep );
__m128i x12 = _mm_loadl_u8_s16(srow, -1 + bstep*2);
__m128i x13 = _mm_loadl_u8_s16(srow, -1 + bstep );
__m128i x14 = _mm_loadl_u8_s16(srow, -2 + bstep );
__m128i x15 = _mm_loadl_u8_s16(srow, -1 );
__m128i x16 = _mm_loadl_u8_s16(srow, -2 - bstep );
__m128i t0, t1, mask;
// gradN ***********************************************
mask = _mm_cmpgt_epi16(T, gradN); // mask = T>gradN
ng = _mm_sub_epi16(ng, mask); // ng += (T>gradN)
t0 = _mm_slli_epi16(x3, 1); // srow[-bstep]*2
t1 = _mm_adds_epi16(_mm_loadl_u8_s16(srow, -bstep*2), x0); // srow[-bstep*2] + srow[0]
// RGs += (srow[-bstep*2] + srow[0]) * (T>gradN)
RGs = _mm_adds_epi16(RGs, _mm_and_si128(t1, mask));
// GRs += {srow[-bstep]*2; (srow[-bstep*2-1] + srow[-bstep*2+1])} * (T>gradN)
GRs = _mm_adds_epi16(GRs, _mm_and_si128(_mm_merge_epi16(t0, _mm_adds_epi16(x2,x4)), mask));
// Bs += {(srow[-bstep-1]+srow[-bstep+1]); srow[-bstep]*2 } * (T>gradN)
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_adds_epi16(x1,x5), t0), mask));
// gradNE **********************************************
mask = _mm_cmpgt_epi16(T, gradNE); // mask = T>gradNE
ng = _mm_sub_epi16(ng, mask); // ng += (T>gradNE)
t0 = _mm_slli_epi16(x5, 1); // srow[-bstep+1]*2
t1 = _mm_adds_epi16(_mm_loadl_u8_s16(srow, -bstep*2+2), x0); // srow[-bstep*2+2] + srow[0]
// RGs += {(srow[-bstep*2+2] + srow[0]); srow[-bstep+1]*2} * (T>gradNE)
RGs = _mm_adds_epi16(RGs, _mm_and_si128(_mm_merge_epi16(t1, t0), mask));
// GRs += {brow0[N6+1]; (srow[-bstep*2+1] + srow[1])} * (T>gradNE)
GRs = _mm_adds_epi16(GRs, _mm_and_si128(_mm_merge_epi16(_mm_loadu_si128((__m128i*)(brow0+N6+1)), _mm_adds_epi16(x4,x7)), mask));
// Bs += {srow[-bstep+1]*2; (srow[-bstep] + srow[-bstep+2])} * (T>gradNE)
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(t0,_mm_adds_epi16(x3,x6)), mask));
// gradE ***********************************************
mask = _mm_cmpgt_epi16(T, gradE); // mask = T>gradE
ng = _mm_sub_epi16(ng, mask); // ng += (T>gradE)
t0 = _mm_slli_epi16(x7, 1); // srow[1]*2
t1 = _mm_adds_epi16(_mm_loadl_u8_s16(srow, 2), x0); // srow[2] + srow[0]
// RGs += (srow[2] + srow[0]) * (T>gradE)
RGs = _mm_adds_epi16(RGs, _mm_and_si128(t1, mask));
// GRs += (srow[1]*2) * (T>gradE)
GRs = _mm_adds_epi16(GRs, _mm_and_si128(t0, mask));
// Bs += {(srow[-bstep+1]+srow[bstep+1]); (srow[-bstep+2]+srow[bstep+2])} * (T>gradE)
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_adds_epi16(x5,x9), _mm_adds_epi16(x6,x8)), mask));
// gradSE **********************************************
mask = _mm_cmpgt_epi16(T, gradSE); // mask = T>gradSE
ng = _mm_sub_epi16(ng, mask); // ng += (T>gradSE)
t0 = _mm_slli_epi16(x9, 1); // srow[bstep+1]*2
t1 = _mm_adds_epi16(_mm_loadl_u8_s16(srow, bstep*2+2), x0); // srow[bstep*2+2] + srow[0]
// RGs += {(srow[bstep*2+2] + srow[0]); srow[bstep+1]*2} * (T>gradSE)
RGs = _mm_adds_epi16(RGs, _mm_and_si128(_mm_merge_epi16(t1, t0), mask));
// GRs += {brow2[N6+1]; (srow[1]+srow[bstep*2+1])} * (T>gradSE)
GRs = _mm_adds_epi16(GRs, _mm_and_si128(_mm_merge_epi16(_mm_loadu_si128((__m128i*)(brow2+N6+1)), _mm_adds_epi16(x7,x10)), mask));
// Bs += {srow[-bstep+1]*2; (srow[bstep+2]+srow[bstep])} * (T>gradSE)
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_slli_epi16(x5, 1), _mm_adds_epi16(x8,x11)), mask));
// gradS ***********************************************
mask = _mm_cmpgt_epi16(T, gradS); // mask = T>gradS
ng = _mm_sub_epi16(ng, mask); // ng += (T>gradS)
t0 = _mm_slli_epi16(x11, 1); // srow[bstep]*2
t1 = _mm_adds_epi16(_mm_loadl_u8_s16(srow,bstep*2), x0); // srow[bstep*2]+srow[0]
// RGs += (srow[bstep*2]+srow[0]) * (T>gradS)
RGs = _mm_adds_epi16(RGs, _mm_and_si128(t1, mask));
// GRs += {srow[bstep]*2; (srow[bstep*2+1]+srow[bstep*2-1])} * (T>gradS)
GRs = _mm_adds_epi16(GRs, _mm_and_si128(_mm_merge_epi16(t0, _mm_adds_epi16(x10,x12)), mask));
// Bs += {(srow[bstep+1]+srow[bstep-1]); srow[bstep]*2} * (T>gradS)
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_adds_epi16(x9,x13), t0), mask));
// gradSW **********************************************
mask = _mm_cmpgt_epi16(T, gradSW); // mask = T>gradSW
ng = _mm_sub_epi16(ng, mask); // ng += (T>gradSW)
t0 = _mm_slli_epi16(x13, 1); // srow[bstep-1]*2
t1 = _mm_adds_epi16(_mm_loadl_u8_s16(srow, bstep*2-2), x0); // srow[bstep*2-2]+srow[0]
// RGs += {(srow[bstep*2-2]+srow[0]); srow[bstep-1]*2} * (T>gradSW)
RGs = _mm_adds_epi16(RGs, _mm_and_si128(_mm_merge_epi16(t1, t0), mask));
// GRs += {brow2[N6-1]; (srow[bstep*2-1]+srow[-1])} * (T>gradSW)
GRs = _mm_adds_epi16(GRs, _mm_and_si128(_mm_merge_epi16(_mm_loadu_si128((__m128i*)(brow2+N6-1)), _mm_adds_epi16(x12,x15)), mask));
// Bs += {srow[bstep-1]*2; (srow[bstep]+srow[bstep-2])} * (T>gradSW)
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(t0,_mm_adds_epi16(x11,x14)), mask));
// gradW ***********************************************
mask = _mm_cmpgt_epi16(T, gradW); // mask = T>gradW
ng = _mm_sub_epi16(ng, mask); // ng += (T>gradW)
t0 = _mm_slli_epi16(x15, 1); // srow[-1]*2
t1 = _mm_adds_epi16(_mm_loadl_u8_s16(srow, -2), x0); // srow[-2]+srow[0]
// RGs += (srow[-2]+srow[0]) * (T>gradW)
RGs = _mm_adds_epi16(RGs, _mm_and_si128(t1, mask));
// GRs += (srow[-1]*2) * (T>gradW)
GRs = _mm_adds_epi16(GRs, _mm_and_si128(t0, mask));
// Bs += {(srow[-bstep-1]+srow[bstep-1]); (srow[bstep-2]+srow[-bstep-2])} * (T>gradW)
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_adds_epi16(x1,x13), _mm_adds_epi16(x14,x16)), mask));
// gradNW **********************************************
mask = _mm_cmpgt_epi16(T, gradNW); // mask = T>gradNW
ng = _mm_sub_epi16(ng, mask); // ng += (T>gradNW)
t0 = _mm_slli_epi16(x1, 1); // srow[-bstep-1]*2
t1 = _mm_adds_epi16(_mm_loadl_u8_s16(srow,-bstep*2-2), x0); // srow[-bstep*2-2]+srow[0]
// RGs += {(srow[-bstep*2-2]+srow[0]); srow[-bstep-1]*2} * (T>gradNW)
RGs = _mm_adds_epi16(RGs, _mm_and_si128(_mm_merge_epi16(t1, t0), mask));
// GRs += {brow0[N6-1]; (srow[-bstep*2-1]+srow[-1])} * (T>gradNW)
GRs = _mm_adds_epi16(GRs, _mm_and_si128(_mm_merge_epi16(_mm_loadu_si128((__m128i*)(brow0+N6-1)), _mm_adds_epi16(x2,x15)), mask));
// Bs += {srow[-bstep-1]*2; (srow[-bstep]+srow[-bstep-2])} * (T>gradNW)
Bs = _mm_adds_epi16(Bs, _mm_and_si128(_mm_merge_epi16(_mm_slli_epi16(x5, 1),_mm_adds_epi16(x3,x16)), mask));
__m128 ngf0 = _mm_div_ps(_0_5, _mm_cvtloepi16_ps(ng));
__m128 ngf1 = _mm_div_ps(_0_5, _mm_cvthiepi16_ps(ng));
// now interpolate r, g & b
t0 = _mm_subs_epi16(GRs, RGs);
t1 = _mm_subs_epi16(Bs, RGs);
t0 = _mm_add_epi16(x0, _mm_packs_epi32(
_mm_cvtps_epi32(_mm_mul_ps(_mm_cvtloepi16_ps(t0), ngf0)),
_mm_cvtps_epi32(_mm_mul_ps(_mm_cvthiepi16_ps(t0), ngf1))));
t1 = _mm_add_epi16(x0, _mm_packs_epi32(
_mm_cvtps_epi32(_mm_mul_ps(_mm_cvtloepi16_ps(t1), ngf0)),
_mm_cvtps_epi32(_mm_mul_ps(_mm_cvthiepi16_ps(t1), ngf1))));
x1 = _mm_merge_epi16(x0, t0);
x2 = _mm_merge_epi16(t0, x0);
uchar R[8], G[8], B[8];
_mm_storel_epi64(blueIdx ? (__m128i*)B : (__m128i*)R, _mm_packus_epi16(x1, z));
_mm_storel_epi64((__m128i*)G, _mm_packus_epi16(x2, z));
_mm_storel_epi64(blueIdx ? (__m128i*)R : (__m128i*)B, _mm_packus_epi16(t1, z));
for( int j = 0; j < 8; j++, dstrow += 3 )
{
dstrow[0] = B[j]; dstrow[1] = G[j]; dstrow[2] = R[j];
}
}
#endif
limit = N - 2;
}
while( i < N - 2 );
for( i = 0; i < 6; i++ )
{
dst[dststep*y + 5 - i] = dst[dststep*y + 8 - i];
dst[dststep*y + (N - 2)*3 + i] = dst[dststep*y + (N - 3)*3 + i];
}
greenCell0 = !greenCell0;
blueIdx ^= 2;
}
for( i = 0; i < size.width*3; i++ )
{
dst[i] = dst[i + dststep] = dst[i + dststep*2];
dst[i + dststep*(size.height-4)] =
dst[i + dststep*(size.height-3)] =
dst[i + dststep*(size.height-2)] =
dst[i + dststep*(size.height-1)] = dst[i + dststep*(size.height-5)];
}
}
//////////////////////////////// Edge-Aware Demosaicing //////////////////////////////////
template <typename T, typename SIMDInterpolator>
class Bayer2RGB_EdgeAware_T_Invoker :
public cv::ParallelLoopBody
{
public:
Bayer2RGB_EdgeAware_T_Invoker(const Mat& _src, Mat& _dst, const Size& _size,
int _blue, int _start_with_green) :
ParallelLoopBody(),
src(_src), dst(_dst), size(_size), Blue(_blue), Start_with_green(_start_with_green)
{
}
virtual void operator()(const Range& range) const
{
int dcn = dst.channels();
int dcn2 = dcn<<1;
int start_with_green = Start_with_green, blue = Blue;
int sstep = int(src.step / src.elemSize1()), dstep = int(dst.step / dst.elemSize1());
SIMDInterpolator vecOp;
const T* S = reinterpret_cast<const T*>(src.data + (range.start + 1) * src.step) + 1;
T* D = reinterpret_cast<T*>(dst.data + (range.start + 1) * dst.step) + dcn;
if (range.start % 2)
{
start_with_green ^= 1;
blue ^= 1;
}
// to BGR
for (int y = range.start; y < range.end; ++y)
{
int x = 1;
if (start_with_green)
{
D[blue<<1] = (S[-sstep] + S[sstep]) >> 1;
D[1] = S[0];
D[2-(blue<<1)] = (S[-1] + S[1]) >> 1;
D += dcn;
++S;
++x;
}
int delta = vecOp.bayer2RGB_EA(S - sstep - 1, sstep, D, size.width, blue);
x += delta;
S += delta;
D += dcn * delta;
if (blue)
for (; x < size.width; x += 2, S += 2, D += dcn2)
{
D[0] = S[0];
D[1] = (std::abs(S[-1] - S[1]) > std::abs(S[sstep] - S[-sstep]) ? (S[sstep] + S[-sstep] + 1) : (S[-1] + S[1] + 1)) >> 1;
D[2] = (S[-sstep-1] + S[-sstep+1] + S[sstep-1] + S[sstep+1]) >> 2;
D[3] = (S[0] + S[2] + 1) >> 1;
D[4] = S[1];
D[5] = (S[-sstep+1] + S[sstep+1] + 1) >> 1;
}
else
for (; x < size.width; x += 2, S += 2, D += dcn2)
{
D[0] = (S[-sstep-1] + S[-sstep+1] + S[sstep-1] + S[sstep+1] + 2) >> 2;
D[1] = (std::abs(S[-1] - S[1]) > std::abs(S[sstep] - S[-sstep]) ? (S[sstep] + S[-sstep] + 1) : (S[-1] + S[1] + 1)) >> 1;
D[2] = S[0];
D[3] = (S[-sstep+1] + S[sstep+1] + 1) >> 1;
D[4] = S[1];
D[5] = (S[0] + S[2] + 1) >> 1;
}
if (x <= size.width)
{
D[blue<<1] = (S[-sstep-1] + S[-sstep+1] + S[sstep-1] + S[sstep+1] + 2) >> 2;
D[1] = (std::abs(S[-1] - S[1]) > std::abs(S[sstep] - S[-sstep]) ? (S[sstep] + S[-sstep] + 1) : (S[-1] + S[1] + 1)) >> 1;
D[2-(blue<<1)] = S[0];
D += dcn;
++S;
}
for (int i = 0; i < dcn; ++i)
{
D[i] = D[-dcn + i];
D[-dstep+dcn+i] = D[-dstep+(dcn<<1)+i];
}
start_with_green ^= 1;
blue ^= 1;
S += 2;
D += dcn2;
}
}
private:
Mat src;
Mat dst;
Size size;
int Blue, Start_with_green;
};
template <typename T, typename SIMDInterpolator>
static void Bayer2RGB_EdgeAware_T(const Mat& src, Mat& dst, int code)
{
Size size = src.size();
// for small sizes
if (size.width <= 2 || size.height <= 2)
{
dst = Scalar::all(0);
return;
}
size.width -= 2;
size.height -= 2;
int start_with_green = code == CV_BayerGB2BGR_EA || code == CV_BayerGR2BGR_EA ? 1 : 0;
int blue = code == CV_BayerGB2BGR_EA || code == CV_BayerBG2BGR_EA ? 1 : 0;
if (size.height > 0)
{
Bayer2RGB_EdgeAware_T_Invoker<T, SIMDInterpolator> invoker(src, dst, size, blue, start_with_green);
Range range(0, size.height);
parallel_for_(range, invoker, dst.total()/static_cast<double>(1<<16));
}
size = dst.size();
size.width *= dst.channels();
size_t dstep = dst.step / dst.elemSize1();
T* firstRow = reinterpret_cast<T*>(dst.data);
T* lastRow = reinterpret_cast<T*>(dst.data) + (size.height-1) * dstep;
if (size.height > 2)
{
for (int x = 0; x < size.width; ++x)
{
firstRow[x] = (firstRow+dstep)[x];
lastRow[x] = (lastRow-dstep)[x];
}
}
else
for (int x = 0; x < size.width; ++x)
firstRow[x] = lastRow[x] = 0;
}
} // end namespace cv
//////////////////////////////////////////////////////////////////////////////////////////
// The main Demosaicing function //
//////////////////////////////////////////////////////////////////////////////////////////
void cv::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn)
{
Mat src = _src.getMat(), dst;
Size sz = src.size();
int scn = src.channels(), depth = src.depth();
CV_Assert(depth == CV_8U || depth == CV_16U);
CV_Assert(!src.empty());
switch (code)
{
case CV_BayerBG2GRAY: case CV_BayerGB2GRAY: case CV_BayerRG2GRAY: case CV_BayerGR2GRAY:
if (dcn <= 0)
dcn = 1;
CV_Assert( scn == 1 && dcn == 1 );
_dst.create(sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
if( depth == CV_8U )
Bayer2Gray_<uchar, SIMDBayerInterpolator_8u>(src, dst, code);
else if( depth == CV_16U )
Bayer2Gray_<ushort, SIMDBayerStubInterpolator_<ushort> >(src, dst, code);
else
CV_Error(CV_StsUnsupportedFormat, "Bayer->Gray demosaicing only supports 8u and 16u types");
break;
case CV_BayerBG2BGR: case CV_BayerGB2BGR: case CV_BayerRG2BGR: case CV_BayerGR2BGR:
case CV_BayerBG2BGR_VNG: case CV_BayerGB2BGR_VNG: case CV_BayerRG2BGR_VNG: case CV_BayerGR2BGR_VNG:
{
if (dcn <= 0)
dcn = 3;
CV_Assert( scn == 1 && (dcn == 3 || dcn == 4) );
_dst.create(sz, CV_MAKE_TYPE(depth, dcn));
Mat dst_ = _dst.getMat();
if( code == CV_BayerBG2BGR || code == CV_BayerGB2BGR ||
code == CV_BayerRG2BGR || code == CV_BayerGR2BGR )
{
if( depth == CV_8U )
Bayer2RGB_<uchar, SIMDBayerInterpolator_8u>(src, dst_, code);
else if( depth == CV_16U )
Bayer2RGB_<ushort, SIMDBayerStubInterpolator_<ushort> >(src, dst_, code);
else
CV_Error(CV_StsUnsupportedFormat, "Bayer->RGB demosaicing only supports 8u and 16u types");
}
else
{
CV_Assert( depth == CV_8U );
Bayer2RGB_VNG_8u(src, dst_, code);
}
}
break;
case CV_BayerBG2BGR_EA: case CV_BayerGB2BGR_EA: case CV_BayerRG2BGR_EA: case CV_BayerGR2BGR_EA:
if (dcn <= 0)
dcn = 3;
CV_Assert(scn == 1 && dcn == 3);
_dst.create(sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
if (depth == CV_8U)
Bayer2RGB_EdgeAware_T<uchar, SIMDBayerInterpolator_8u>(src, dst, code);
else if (depth == CV_16U)
Bayer2RGB_EdgeAware_T<ushort, SIMDBayerStubInterpolator_<ushort> >(src, dst, code);
else
CV_Error(CV_StsUnsupportedFormat, "Bayer->RGB Edge-Aware demosaicing only currently supports 8u and 16u types");
break;
default:
CV_Error( CV_StsBadFlag, "Unknown / unsupported color conversion code" );
}
}
|
#include "duckdb/common/types/hugeint.hpp"
#include "duckdb/common/exception.hpp"
#include "duckdb/common/algorithm.hpp"
#include "duckdb/common/limits.hpp"
#include <cmath>
using namespace std;
namespace duckdb {
//===--------------------------------------------------------------------===//
// String Conversion
//===--------------------------------------------------------------------===//
hugeint_t Hugeint::PowersOfTen[] {
hugeint_t(1),
hugeint_t(10),
hugeint_t(100),
hugeint_t(1000),
hugeint_t(10000),
hugeint_t(100000),
hugeint_t(1000000),
hugeint_t(10000000),
hugeint_t(100000000),
hugeint_t(1000000000),
hugeint_t(10000000000),
hugeint_t(100000000000),
hugeint_t(1000000000000),
hugeint_t(10000000000000),
hugeint_t(100000000000000),
hugeint_t(1000000000000000),
hugeint_t(10000000000000000),
hugeint_t(100000000000000000),
hugeint_t(1000000000000000000),
hugeint_t(1000000000000000000) * hugeint_t(10),
hugeint_t(1000000000000000000) * hugeint_t(100),
hugeint_t(1000000000000000000) * hugeint_t(1000),
hugeint_t(1000000000000000000) * hugeint_t(10000),
hugeint_t(1000000000000000000) * hugeint_t(100000),
hugeint_t(1000000000000000000) * hugeint_t(1000000),
hugeint_t(1000000000000000000) * hugeint_t(10000000),
hugeint_t(1000000000000000000) * hugeint_t(100000000),
hugeint_t(1000000000000000000) * hugeint_t(1000000000),
hugeint_t(1000000000000000000) * hugeint_t(10000000000),
hugeint_t(1000000000000000000) * hugeint_t(100000000000),
hugeint_t(1000000000000000000) * hugeint_t(1000000000000),
hugeint_t(1000000000000000000) * hugeint_t(10000000000000),
hugeint_t(1000000000000000000) * hugeint_t(100000000000000),
hugeint_t(1000000000000000000) * hugeint_t(1000000000000000),
hugeint_t(1000000000000000000) * hugeint_t(10000000000000000),
hugeint_t(1000000000000000000) * hugeint_t(100000000000000000),
hugeint_t(1000000000000000000) * hugeint_t(1000000000000000000),
hugeint_t(1000000000000000000) * hugeint_t(1000000000000000000) * hugeint_t(10),
hugeint_t(1000000000000000000) * hugeint_t(1000000000000000000) * hugeint_t(100)
};
static uint8_t positive_hugeint_highest_bit(hugeint_t bits) {
uint8_t out = 0;
if (bits.upper){
out = 64;
uint64_t up = bits.upper;
while (up){
up >>= 1;
out++;
}
}
else{
uint64_t low = bits.lower;
while (low){
low >>= 1;
out++;
}
}
return out;
}
static bool positive_hugeint_is_bit_set(hugeint_t lhs, uint8_t bit_position) {
if (bit_position < 64) {
return lhs.lower & (uint64_t(1) << uint64_t(bit_position));
} else {
return lhs.upper & (uint64_t(1) << uint64_t(bit_position - 64));
}
}
hugeint_t positive_hugeint_leftshift(hugeint_t lhs, uint32_t amount) {
assert(amount > 0 && amount < 64);
hugeint_t result;
result.lower = lhs.lower << amount;
result.upper = (lhs.upper << amount) + (lhs.lower >> (64 - amount));
return result;
}
hugeint_t Hugeint::DivModPositive(hugeint_t lhs, uint64_t rhs, uint64_t &remainder) {
assert(lhs.upper >= 0);
// DivMod code adapted from:
// https://github.com/calccrypto/uint128_t/blob/master/uint128_t.cpp
// initialize the result and remainder to 0
hugeint_t div_result;
div_result.lower = 0;
div_result.upper = 0;
remainder = 0;
uint8_t highest_bit_set = positive_hugeint_highest_bit(lhs);
// now iterate over the amount of bits that are set in the LHS
for(uint8_t x = highest_bit_set; x > 0; x--) {
// left-shift the current result and remainder by 1
div_result = positive_hugeint_leftshift(div_result, 1);
remainder <<= 1;
// we get the value of the bit at position X, where position 0 is the least-significant bit
if (positive_hugeint_is_bit_set(lhs, x - 1)) {
// increment the remainder
remainder++;
}
if (remainder >= rhs) {
// the remainder has passed the division multiplier: add one to the divide result
remainder -= rhs;
div_result.lower++;
if (div_result.lower == 0) {
// overflow
div_result.upper++;
}
}
}
return div_result;
}
string Hugeint::ToString(hugeint_t input) {
uint64_t remainder;
string result;
bool negative = input.upper < 0;
if (negative) {
NegateInPlace(input);
}
while(true) {
if (!input.lower && !input.upper) {
break;
}
input = Hugeint::DivModPositive(input, 10, remainder);
result = string(1, '0' + remainder) + result;
}
if (result.empty()) {
// value is zero
return "0";
}
return negative ? "-" + result : result;
}
//===--------------------------------------------------------------------===//
// Multiply
//===--------------------------------------------------------------------===//
bool Hugeint::TryMultiply(hugeint_t lhs, hugeint_t rhs, hugeint_t &result) {
// Multiply code adapted from:
// https://github.com/calccrypto/uint128_t/blob/master/uint128_t.cpp
bool lhs_negative = lhs.upper < 0;
bool rhs_negative = rhs.upper < 0;
if (lhs_negative) {
NegateInPlace(lhs);
}
if (rhs_negative) {
NegateInPlace(rhs);
}
// split values into 4 32-bit parts
uint64_t top[4] = {uint64_t(lhs.upper) >> 32, uint64_t(lhs.upper) & 0xffffffff, lhs.lower >> 32, lhs.lower & 0xffffffff};
uint64_t bottom[4] = {uint64_t(rhs.upper) >> 32, uint64_t(rhs.upper) & 0xffffffff, rhs.lower >> 32, rhs.lower & 0xffffffff};
uint64_t products[4][4];
// multiply each component of the values
for(int y = 3; y > -1; y--){
for(int x = 3; x > -1; x--){
products[3 - x][y] = top[x] * bottom[y];
}
}
// first row
uint64_t fourth32 = (products[0][3] & 0xffffffff);
uint64_t third32 = (products[0][2] & 0xffffffff) + (products[0][3] >> 32);
uint64_t second32 = (products[0][1] & 0xffffffff) + (products[0][2] >> 32);
uint64_t first32 = (products[0][0] & 0xffffffff) + (products[0][1] >> 32);
// second row
third32 += (products[1][3] & 0xffffffff);
second32 += (products[1][2] & 0xffffffff) + (products[1][3] >> 32);
first32 += (products[1][1] & 0xffffffff) + (products[1][2] >> 32);
// third row
second32 += (products[2][3] & 0xffffffff);
first32 += (products[2][2] & 0xffffffff) + (products[2][3] >> 32);
// fourth row
first32 += (products[3][3] & 0xffffffff);
// move carry to next digit
third32 += fourth32 >> 32;
second32 += third32 >> 32;
first32 += second32 >> 32;
if (products[3][3] & 0xffffff80000000 || first32 & 0xffffff80000000) {
return false;
}
// remove carry from current digit
fourth32 &= 0xffffffff;
third32 &= 0xffffffff;
second32 &= 0xffffffff;
first32 &= 0xffffffff;
// combine components
result.lower = (third32 << 32) | fourth32;
result.upper = (first32 << 32) | second32;
if (lhs_negative ^ rhs_negative) {
NegateInPlace(result);
}
return true;
}
hugeint_t Hugeint::Multiply(hugeint_t lhs, hugeint_t rhs) {
hugeint_t result;
if (!TryMultiply(lhs, rhs, result)) {
throw OutOfRangeException("Overflow in HUGEINT multiplication!");
}
return result;
}
//===--------------------------------------------------------------------===//
// Divide
//===--------------------------------------------------------------------===//
hugeint_t Hugeint::DivMod(hugeint_t lhs, hugeint_t rhs, hugeint_t &remainder) {
// division by zero not allowed
assert(!(rhs.upper == 0 && rhs.lower == 0));
bool lhs_negative = lhs.upper < 0;
bool rhs_negative = rhs.upper < 0;
if (lhs_negative) {
Hugeint::NegateInPlace(lhs);
}
if (rhs_negative) {
Hugeint::NegateInPlace(rhs);
}
// DivMod code adapted from:
// https://github.com/calccrypto/uint128_t/blob/master/uint128_t.cpp
// initialize the result and remainder to 0
hugeint_t div_result;
div_result.lower = 0;
div_result.upper = 0;
remainder.lower = 0;
remainder.upper = 0;
uint8_t highest_bit_set = positive_hugeint_highest_bit(lhs);
// now iterate over the amount of bits that are set in the LHS
for(uint8_t x = highest_bit_set; x > 0; x--) {
// left-shift the current result and remainder by 1
div_result = positive_hugeint_leftshift(div_result, 1);
remainder = positive_hugeint_leftshift(remainder, 1);
// we get the value of the bit at position X, where position 0 is the least-significant bit
if (positive_hugeint_is_bit_set(lhs, x - 1)) {
// increment the remainder
Hugeint::AddInPlace(remainder, 1);
}
if (Hugeint::GreaterThanEquals(remainder, rhs)) {
// the remainder has passed the division multiplier: add one to the divide result
remainder = Hugeint::Subtract(remainder, rhs);
Hugeint::AddInPlace(div_result, 1);
}
}
if (lhs_negative ^ rhs_negative) {
Hugeint::NegateInPlace(div_result);
}
if (lhs_negative) {
Hugeint::NegateInPlace(remainder);
}
return div_result;
}
hugeint_t Hugeint::Divide(hugeint_t lhs, hugeint_t rhs) {
hugeint_t remainder;
return Hugeint::DivMod(lhs, rhs, remainder);
}
hugeint_t Hugeint::Modulo(hugeint_t lhs, hugeint_t rhs) {
hugeint_t remainder;
Hugeint::DivMod(lhs, rhs, remainder);
return remainder;
}
//===--------------------------------------------------------------------===//
// Add/Subtract
//===--------------------------------------------------------------------===//
bool Hugeint::AddInPlace(hugeint_t &lhs, hugeint_t rhs) {
int overflow = lhs.lower + rhs.lower < lhs.lower;
if (rhs.upper >= 0) {
// RHS is positive: check for overflow
if (lhs.upper > (std::numeric_limits<int64_t>::max() - (rhs.upper + overflow))) {
return false;
}
} else {
// RHS is negative: check for underflow
if (lhs.upper < std::numeric_limits<int64_t>::min() - (rhs.upper + overflow)) {
return false;
}
}
lhs.upper = lhs.upper + overflow + rhs.upper;
lhs.lower += rhs.lower;
if (lhs.upper == std::numeric_limits<int64_t>::min() && lhs.lower == 0) {
return false;
}
return true;
}
bool Hugeint::SubtractInPlace(hugeint_t &lhs, hugeint_t rhs) {
// underflow
int underflow = lhs.lower - rhs.lower > lhs.lower;
if (rhs.upper >= 0) {
// RHS is positive: check for underflow
if (lhs.upper < (std::numeric_limits<int64_t>::min() + rhs.upper + underflow)) {
return false;
}
} else {
// RHS is negative: check for overflow
if (lhs.upper >= (std::numeric_limits<int64_t>::max() + rhs.upper + underflow - 1)) {
return false;
}
}
lhs.upper = lhs.upper - rhs.upper - underflow;
lhs.lower -= rhs.lower;
if (lhs.upper == std::numeric_limits<int64_t>::min() && lhs.lower == 0) {
return false;
}
return true;
}
hugeint_t Hugeint::Add(hugeint_t lhs, hugeint_t rhs) {
if (!AddInPlace(lhs, rhs)) {
throw OutOfRangeException("Overflow in HUGEINT addition");
}
return lhs;
}
hugeint_t Hugeint::Subtract(hugeint_t lhs, hugeint_t rhs) {
if (!SubtractInPlace(lhs, rhs)) {
throw OutOfRangeException("Underflow in HUGEINT addition");
}
return lhs;
}
//===--------------------------------------------------------------------===//
// Hugeint Cast/Conversion
//===--------------------------------------------------------------------===//
template<class DST>
bool hugeint_try_cast_integer(hugeint_t input, DST &result) {
switch(input.upper) {
case 0:
// positive number: check if the positive number is in range
if (input.lower <= uint64_t(NumericLimits<DST>::Maximum())) {
result = DST(input.lower);
return true;
}
break;
case -1:
// negative number: check if the negative number is in range
if (input.lower > NumericLimits<uint64_t>::Maximum() - uint64_t(NumericLimits<DST>::Maximum())) {
result = -DST(NumericLimits<uint64_t>::Maximum() - input.lower + 1);
return true;
}
break;
default:
break;
}
return false;
}
template<> bool Hugeint::TryCast(hugeint_t input, int8_t &result) {
return hugeint_try_cast_integer<int8_t>(input, result);
}
template<> bool Hugeint::TryCast(hugeint_t input, int16_t &result) {
return hugeint_try_cast_integer<int16_t>(input, result);
}
template<> bool Hugeint::TryCast(hugeint_t input, int32_t &result) {
return hugeint_try_cast_integer<int32_t>(input, result);
}
template<> bool Hugeint::TryCast(hugeint_t input, int64_t &result) {
return hugeint_try_cast_integer<int64_t>(input, result);
}
template<> bool Hugeint::TryCast(hugeint_t input, float &result) {
double dbl_result;
Hugeint::TryCast(input, dbl_result);
result = (float) dbl_result;
return true;
}
template<> bool Hugeint::TryCast(hugeint_t input, double &result) {
switch(input.upper) {
case -1:
// special case for upper = -1 to avoid rounding issues in small negative numbers
result = -double(NumericLimits<uint64_t>::Maximum() - input.lower + 1);
break;
default:
result = double(input.lower) + double(input.upper) * double(NumericLimits<uint64_t>::Maximum());
break;
}
return true;
}
template<class DST>
hugeint_t hugeint_convert_integer(DST input) {
hugeint_t result;
result.lower = (uint64_t) input;
result.upper = (input < 0) * -1;
return result;
}
template<> hugeint_t Hugeint::Convert(int8_t value) {
return hugeint_convert_integer<int8_t>(value);
}
template<> hugeint_t Hugeint::Convert(int16_t value) {
return hugeint_convert_integer<int16_t>(value);
}
template<> hugeint_t Hugeint::Convert(int32_t value) {
return hugeint_convert_integer<int32_t>(value);
}
template<> hugeint_t Hugeint::Convert(int64_t value) {
return hugeint_convert_integer<int64_t>(value);
}
template<> hugeint_t Hugeint::Convert(float value) {
return Hugeint::Convert<double>(value);
}
template<> hugeint_t Hugeint::Convert(double value) {
if (value <= -170141183460469231731687303715884105728.0 || value >= 170141183460469231731687303715884105727.0) {
throw OutOfRangeException("Double out of range of HUGEINT");
}
hugeint_t result;
bool negative = value < 0;
if (negative) {
value = -value;
}
result.lower = (uint64_t) fmod(value, double(NumericLimits<uint64_t>::Maximum()));
result.upper = (uint64_t) (value / double(NumericLimits<uint64_t>::Maximum()));
if (negative) {
NegateInPlace(result);
}
return result;
}
//===--------------------------------------------------------------------===//
// hugeint_t operators
//===--------------------------------------------------------------------===//
hugeint_t::hugeint_t(int64_t value) {
auto result = Hugeint::Convert(value);
this->lower = result.lower;
this->upper = result.upper;
}
bool hugeint_t::operator==(const hugeint_t &rhs) const {
return Hugeint::Equals(*this, rhs);
}
bool hugeint_t::operator!=(const hugeint_t &rhs) const {
return Hugeint::NotEquals(*this, rhs);
}
bool hugeint_t::operator<(const hugeint_t &rhs) const {
return Hugeint::LessThan(*this, rhs);
}
bool hugeint_t::operator<=(const hugeint_t &rhs) const {
return Hugeint::LessThanEquals(*this, rhs);
}
bool hugeint_t::operator>(const hugeint_t &rhs) const {
return Hugeint::GreaterThan(*this, rhs);
}
bool hugeint_t::operator>=(const hugeint_t &rhs) const {
return Hugeint::GreaterThanEquals(*this, rhs);
}
hugeint_t hugeint_t::operator+(const hugeint_t & rhs) const {
return Hugeint::Add(*this, rhs);
}
hugeint_t hugeint_t::operator-(const hugeint_t & rhs) const {
return Hugeint::Subtract(*this, rhs);
}
hugeint_t hugeint_t::operator*(const hugeint_t & rhs) const {
return Hugeint::Multiply(*this, rhs);
}
hugeint_t hugeint_t::operator/(const hugeint_t & rhs) const {
return Hugeint::Divide(*this, rhs);
}
hugeint_t hugeint_t::operator%(const hugeint_t & rhs) const {
return Hugeint::Modulo(*this, rhs);
}
hugeint_t hugeint_t::operator-() const {
return Hugeint::Negate(*this);
}
hugeint_t hugeint_t::operator>>(const hugeint_t & rhs) const {
if (upper < 0) {
return hugeint_t(0);
}
hugeint_t result;
const uint64_t shift = rhs.lower;
if (rhs.upper != 0 || shift >= 128) {
return hugeint_t(0);
} else if (shift == 64) {
result.upper = 0;
result.lower = upper;
} else if (shift == 0) {
return *this;
} else if (shift < 64) {
// perform upper shift in unsigned integer, and mask away the most significant bit
result.lower = (uint64_t(upper) << (64 - shift)) + (lower >> shift);
result.upper = uint64_t(upper) >> shift;
} else {
assert(shift < 128);
result.lower = uint64_t(upper) >> (shift - 64);
result.upper = 0;
}
return result;
}
hugeint_t hugeint_t::operator<<(const hugeint_t & rhs) const {
if (upper < 0) {
return hugeint_t(0);
}
hugeint_t result;
const uint64_t shift = rhs.lower;
if (rhs.upper != 0 || shift >= 128) {
return hugeint_t(0);
} else if (shift == 64) {
result.upper = lower;
result.lower = 0;
} else if (shift == 0) {
return *this;
} else if (shift < 64) {
// perform upper shift in unsigned integer, and mask away the most significant bit
uint64_t upper_shift = ((uint64_t(upper) << shift) + (lower >> (64 - shift))) & 0x7FFFFFFFFFFFFFFF;
result.lower = lower << shift;
result.upper = upper_shift;
} else {
assert(shift < 128);
result.lower = 0;
result.upper = (lower << (shift - 64)) & 0x7FFFFFFFFFFFFFFF;
}
return result;
}
hugeint_t hugeint_t::operator&(const hugeint_t & rhs) const {
hugeint_t result;
result.lower = lower & rhs.lower;
result.upper = upper & rhs.upper;
return result;
}
hugeint_t hugeint_t::operator|(const hugeint_t & rhs) const {
hugeint_t result;
result.lower = lower | rhs.lower;
result.upper = upper | rhs.upper;
return result;
}
hugeint_t hugeint_t::operator^(const hugeint_t & rhs) const {
hugeint_t result;
result.lower = lower ^ rhs.lower;
result.upper = upper ^ rhs.upper;
return result;
}
hugeint_t hugeint_t::operator~() const {
hugeint_t result;
result.lower = ~lower;
result.upper = ~upper;
return result;
}
hugeint_t & hugeint_t::operator+=(const hugeint_t & rhs) {
Hugeint::AddInPlace(*this, rhs);
return *this;
}
hugeint_t & hugeint_t::operator-=(const hugeint_t & rhs) {
Hugeint::SubtractInPlace(*this, rhs);
return *this;
}
hugeint_t & hugeint_t::operator*=(const hugeint_t & rhs) {
*this = Hugeint::Multiply(*this, rhs);
return *this;
}
hugeint_t & hugeint_t::operator/=(const hugeint_t & rhs) {
*this = Hugeint::Divide(*this, rhs);
return *this;
}
hugeint_t & hugeint_t::operator%=(const hugeint_t & rhs) {
*this = Hugeint::Modulo(*this, rhs);
return *this;
}
hugeint_t & hugeint_t::operator>>=(const hugeint_t & rhs) {
*this = *this >> rhs;
return *this;
}
hugeint_t & hugeint_t::operator<<=(const hugeint_t & rhs) {
*this = *this << rhs;
return *this;
}
hugeint_t & hugeint_t::operator&=(const hugeint_t & rhs) {
lower &= rhs.lower;
upper &= rhs.upper;
return *this;
}
hugeint_t & hugeint_t::operator|=(const hugeint_t & rhs) {
lower |= rhs.lower;
upper |= rhs.upper;
return *this;
}
hugeint_t & hugeint_t::operator^=(const hugeint_t & rhs) {
lower ^= rhs.lower;
upper ^= rhs.upper;
return *this;
}
string hugeint_t::ToString() {
return Hugeint::ToString(*this);
}
}
|
#include "BatteryIcon.hpp"
#include "Assets/Icons.hpp"
namespace Pages::Elements
{
bool BatteryIcon::check_dependencies_changed()
{
bool battery_changed = battery_state().new_value_available();
bool blink_changed = false;
if (battery_state().is_valid() && battery_state().get() == BATTERY_CRITICAL)
{
blink_changed = blink_state().new_value_available();
}
return battery_changed || blink_changed;
}
void BatteryIcon::render(Adafruit_SSD1306 &display)
{
if (!battery_state().is_valid())
{
return;
}
if (battery_state().get() == BATTERY_CRITICAL)
{
if (blink_state().get())
{
draw_battery_icon(display, display.width() - 5, 0, 0);
}
}
else
{
draw_battery_icon(display, display.width() - 5, 0, int(battery_state().get()) - 1);
}
}
}
|
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
//
// 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.
//
////////////////////////////////////////////////////////////
#ifndef SFML_EVENT_HPP
#define SFML_EVENT_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <SFML/Window/Joystick.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <SFML/Window/Mouse.hpp>
namespace sf
{
////////////////////////////////////////////////////////////
/// \brief Defines a system event and its parameters
///
////////////////////////////////////////////////////////////
class Event
{
public :
////////////////////////////////////////////////////////////
/// \brief Size events parameters (Resized)
///
////////////////////////////////////////////////////////////
struct SizeEvent
{
unsigned int width; ///< New width, in pixels
unsigned int height; ///< New height, in pixels
};
////////////////////////////////////////////////////////////
/// \brief Keyboard event parameters (KeyPressed, KeyReleased)
///
////////////////////////////////////////////////////////////
struct KeyEvent
{
Keyboard::Key code; ///< Code of the key that has been pressed
bool alt; ///< Is the Alt key pressed?
bool control; ///< Is the Control key pressed?
bool shift; ///< Is the Shift key pressed?
bool system; ///< Is the System key pressed?
};
////////////////////////////////////////////////////////////
/// \brief Text event parameters (TextEntered)
///
////////////////////////////////////////////////////////////
struct TextEvent
{
Uint32 unicode; ///< UTF-32 unicode value of the character
};
////////////////////////////////////////////////////////////
/// \brief Mouse move event parameters (MouseMoved)
///
////////////////////////////////////////////////////////////
struct MouseMoveEvent
{
int x; ///< X position of the mouse pointer, relative to the left of the owner window
int y; ///< Y position of the mouse pointer, relative to the top of the owner window
};
////////////////////////////////////////////////////////////
/// \brief Mouse buttons events parameters
/// (MouseButtonPressed, MouseButtonReleased)
///
////////////////////////////////////////////////////////////
struct MouseButtonEvent
{
Mouse::Button button; ///< Code of the button that has been pressed
int x; ///< X position of the mouse pointer, relative to the left of the owner window
int y; ///< Y position of the mouse pointer, relative to the top of the owner window
};
////////////////////////////////////////////////////////////
/// \brief Mouse wheel events parameters (MouseWheelMoved)
///
////////////////////////////////////////////////////////////
struct MouseWheelEvent
{
int delta; ///< Number of ticks the wheel has moved (positive is up, negative is down)
int x; ///< X position of the mouse pointer, relative to the left of the owner window
int y; ///< Y position of the mouse pointer, relative to the top of the owner window
};
////////////////////////////////////////////////////////////
/// \brief Joystick connection events parameters
/// (JoystickConnected, JoystickDisconnected)
///
////////////////////////////////////////////////////////////
struct JoystickConnectEvent
{
unsigned int joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
};
////////////////////////////////////////////////////////////
/// \brief Joystick axis move event parameters (JoystickMoved)
///
////////////////////////////////////////////////////////////
struct JoystickMoveEvent
{
unsigned int joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
Joystick::Axis axis; ///< Axis on which the joystick moved
float position; ///< New position on the axis (in range [-100 .. 100])
};
////////////////////////////////////////////////////////////
/// \brief Joystick buttons events parameters
/// (JoystickButtonPressed, JoystickButtonReleased)
///
////////////////////////////////////////////////////////////
struct JoystickButtonEvent
{
unsigned int joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])
unsigned int button; ///< Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])
};
////////////////////////////////////////////////////////////
/// \brief Enumeration of the different types of events
///
////////////////////////////////////////////////////////////
enum EventType
{
Closed, ///< The window requested to be closed (no data)
Resized, ///< The window was resized (data in event.size)
LostFocus, ///< The window lost the focus (no data)
GainedFocus, ///< The window gained the focus (no data)
TextEntered, ///< A character was entered (data in event.text)
KeyPressed, ///< A key was pressed (data in event.key)
KeyReleased, ///< A key was released (data in event.key)
MouseWheelMoved, ///< The mouse wheel was scrolled (data in event.mouseWheel)
MouseButtonPressed, ///< A mouse button was pressed (data in event.mouseButton)
MouseButtonReleased, ///< A mouse button was released (data in event.mouseButton)
MouseMoved, ///< The mouse cursor moved (data in event.mouseMove)
MouseEntered, ///< The mouse cursor entered the area of the window (no data)
MouseLeft, ///< The mouse cursor left the area of the window (no data)
JoystickButtonPressed, ///< A joystick button was pressed (data in event.joystickButton)
JoystickButtonReleased, ///< A joystick button was released (data in event.joystickButton)
JoystickMoved, ///< The joystick moved along an axis (data in event.joystickMove)
JoystickConnected, ///< A joystick was connected (data in event.joystickConnect)
JoystickDisconnected, ///< A joystick was disconnected (data in event.joystickConnect)
Count ///< Keep last -- the total number of event types
};
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
EventType type; ///< Type of the event
union
{
SizeEvent size; ///< Size event parameters (Event::Resized)
KeyEvent key; ///< Key event parameters (Event::KeyPressed, Event::KeyReleased)
TextEvent text; ///< Text event parameters (Event::TextEntered)
MouseMoveEvent mouseMove; ///< Mouse move event parameters (Event::MouseMoved)
MouseButtonEvent mouseButton; ///< Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased)
MouseWheelEvent mouseWheel; ///< Mouse wheel event parameters (Event::MouseWheelMoved)
JoystickMoveEvent joystickMove; ///< Joystick move event parameters (Event::JoystickMoved)
JoystickButtonEvent joystickButton; ///< Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased)
JoystickConnectEvent joystickConnect; ///< Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected)
};
};
} // namespace sf
#endif // SFML_EVENT_HPP
////////////////////////////////////////////////////////////
/// \class sf::Event
/// \ingroup window
///
/// sf::Event holds all the informations about a system event
/// that just happened. Events are retrieved using the
/// sf::Window::pollEvent and sf::Window::waitEvent functions.
///
/// A sf::Event instance contains the type of the event
/// (mouse moved, key pressed, window closed, ...) as well
/// as the details about this particular event. Please note that
/// the event parameters are defined in a union, which means that
/// only the member matching the type of the event will be properly
/// filled; all other members will have undefined values and must not
/// be read if the type of the event doesn't match. For example,
/// if you received a KeyPressed event, then you must read the
/// event.key member, all other members such as event.MouseMove
/// or event.text will have undefined values.
///
/// Usage example:
/// \code
/// sf::Event event;
/// while (window.pollEvent(event))
/// {
/// // Request for closing the window
/// if (event.type == sf::Event::Closed)
/// window.close();
///
/// // The escape key was pressed
/// if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
/// window.close();
///
/// // The window was resized
/// if (event.type == sf::Event::Resized)
/// doSomethingWithTheNewSize(event.size.width, event.size.height);
///
/// // etc ...
/// }
/// \endcode
///
////////////////////////////////////////////////////////////
|
#include <maplab-common/test/testing-entrypoint.h>
#include <aslam/common/memory.h>
#include <aslam/frames/visual-nframe.h>
#include <gtest/gtest.h>
#include <map-resources/resource-common.h>
#include "vi-map/unique-id.h"
#include "vi-map/vertex.h"
namespace vi_map {
class VertexResourcesTest : public ::testing::Test {
public:
VertexResourcesTest() {}
uint kFrameIdx0 = 0;
uint kFrameIdx1 = 1;
uint kFrameIdx2 = 2;
uint kInvalidFrameIdx = 99;
backend::ResourceType kType0 = backend::ResourceType::kRawImage;
backend::ResourceType kType1 = backend::ResourceType::kRawDepthMap;
backend::ResourceType kType2 = backend::ResourceType::kImageForDepthMap;
backend::ResourceType kUnusedType = backend::ResourceType::kOptimizedDepthMap;
backend::ResourceType kInvalidType = backend::ResourceType::kCount;
backend::ResourceId kResourceId0;
backend::ResourceId kResourceId1;
backend::ResourceId kResourceId2;
backend::ResourceId kResourceId3;
backend::ResourceId kResourceId4;
backend::ResourceId kUnusedResourceId;
Vertex::UniquePtr vertex_;
virtual void SetUp() {
vertex_ = aligned_unique<Vertex>();
aslam::NFramesId id;
vertex_->n_frame_.reset(new aslam::VisualNFrame(id, 3));
common::generateId(&kResourceId0);
common::generateId(&kResourceId1);
common::generateId(&kResourceId2);
common::generateId(&kResourceId3);
common::generateId(&kResourceId4);
common::generateId(&kUnusedResourceId);
vertex_->resource_map_.resize(3);
vertex_->resource_map_.at(kFrameIdx0)[kType0].insert(kResourceId0);
vertex_->resource_map_.at(kFrameIdx0)[kType0].insert(kResourceId1);
vertex_->resource_map_.at(kFrameIdx1)[kType1].insert(kResourceId2);
vertex_->resource_map_.at(kFrameIdx2)[kType1].insert(kResourceId3);
vertex_->resource_map_.at(kFrameIdx2)[kType2].insert(kResourceId4);
}
};
TEST_F(VertexResourcesTest, TestHasFrameResourceWithId) {
EXPECT_FALSE(vertex_->hasFrameResourceWithId(kFrameIdx0, kUnusedResourceId));
EXPECT_FALSE(vertex_->hasFrameResourceWithId(kFrameIdx0, kResourceId3));
EXPECT_TRUE(vertex_->hasFrameResourceWithId(kFrameIdx0, kResourceId0));
EXPECT_TRUE(vertex_->hasFrameResourceWithId(kFrameIdx0, kResourceId1));
EXPECT_TRUE(vertex_->hasFrameResourceWithId(kFrameIdx1, kResourceId2));
EXPECT_TRUE(vertex_->hasFrameResourceWithId(kFrameIdx2, kResourceId3));
EXPECT_TRUE(vertex_->hasFrameResourceWithId(kFrameIdx2, kResourceId4));
}
TEST_F(VertexResourcesTest, TestHasFrameResourceOfType) {
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kUnusedType));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType1));
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType0));
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType1));
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType1));
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType2));
}
TEST_F(VertexResourcesTest, TestGetNumFrameResourcesOfType) {
EXPECT_EQ(0u, vertex_->getNumFrameResourcesOfType(kFrameIdx0, kUnusedType));
EXPECT_EQ(0u, vertex_->getNumFrameResourcesOfType(kFrameIdx0, kType1));
EXPECT_EQ(2u, vertex_->getNumFrameResourcesOfType(kFrameIdx0, kType0));
EXPECT_EQ(1u, vertex_->getNumFrameResourcesOfType(kFrameIdx1, kType1));
EXPECT_EQ(1u, vertex_->getNumFrameResourcesOfType(kFrameIdx2, kType1));
EXPECT_EQ(1u, vertex_->getNumFrameResourcesOfType(kFrameIdx2, kType2));
}
TEST_F(VertexResourcesTest, TestGetFrameResourceIdsOfType) {
backend::ResourceIdSet resource_ids_0;
backend::ResourceIdSet resource_ids_1;
vertex_->getFrameResourceIdsOfType(kFrameIdx0, kType0, &resource_ids_0);
EXPECT_EQ(2u, resource_ids_0.size());
EXPECT_EQ(1u, resource_ids_0.count(kResourceId0));
EXPECT_EQ(1u, resource_ids_0.count(kResourceId1));
vertex_->getFrameResourceIdsOfType(kFrameIdx1, kType0, &resource_ids_1);
EXPECT_EQ(0u, resource_ids_1.size());
}
TEST_F(VertexResourcesTest, TestAddFrameResourceIdOfType) {
backend::ResourceIdSet resource_ids_before;
vertex_->getFrameResourceIdsOfType(
kFrameIdx0, kUnusedType, &resource_ids_before);
EXPECT_EQ(0u, resource_ids_before.size());
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kUnusedType));
vertex_->addFrameResourceIdOfType(kFrameIdx0, kUnusedType, kUnusedResourceId);
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx0, kUnusedType));
backend::ResourceIdSet resource_ids_after;
vertex_->getFrameResourceIdsOfType(
kFrameIdx0, kUnusedType, &resource_ids_after);
EXPECT_EQ(1u, resource_ids_after.size());
EXPECT_EQ(1u, resource_ids_after.count(kUnusedResourceId));
}
TEST_F(VertexResourcesTest, TestDeleteFrameResourceIdsOfType) {
vertex_->deleteFrameResourceIdsOfType(kFrameIdx2, kType1);
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType0));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType1));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType2));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType0));
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType1));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType2));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType0));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType1));
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType2));
}
TEST_F(VertexResourcesTest, TestDeleteAllFrameResourceInfoForOneFrame) {
vertex_->deleteAllFrameResourceInfo(kFrameIdx2);
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType0));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType1));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType2));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType0));
EXPECT_TRUE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType1));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType2));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType0));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType1));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType2));
}
TEST_F(VertexResourcesTest, TestDeleteAllFrameResourceInfo) {
vertex_->deleteAllFrameResourceInfo();
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType0));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType1));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx0, kType2));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType0));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType1));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx1, kType2));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType0));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType1));
EXPECT_FALSE(vertex_->hasFrameResourceOfType(kFrameIdx2, kType2));
}
} // namespace vi_map
MAPLAB_UNITTEST_ENTRYPOINT
|
// Copyright (c) 2014-2017 The Adn Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "activemasternode.h"
#include "consensus/validation.h"
#include "darksend.h"
#include "init.h"
#include "governance.h"
#include "masternode.h"
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "masternodeman.h"
#include "util.h"
#include <boost/lexical_cast.hpp>
CMasternode::CMasternode() :
vin(),
addr(),
pubKeyCollateralAddress(),
pubKeyMasternode(),
lastPing(),
vchSig(),
sigTime(GetAdjustedTime()),
nLastDsq(0),
nTimeLastChecked(0),
nTimeLastPaid(0),
nTimeLastWatchdogVote(0),
nActiveState(MASTERNODE_ENABLED),
nCacheCollateralBlock(0),
nBlockLastPaid(0),
nProtocolVersion(PROTOCOL_VERSION),
nPoSeBanScore(0),
nPoSeBanHeight(0),
fAllowMixingTx(true),
fUnitTest(false)
{}
CMasternode::CMasternode(CService addrNew, CTxIn vinNew, CPubKey pubKeyCollateralAddressNew, CPubKey pubKeyMasternodeNew, int nProtocolVersionIn) :
vin(vinNew),
addr(addrNew),
pubKeyCollateralAddress(pubKeyCollateralAddressNew),
pubKeyMasternode(pubKeyMasternodeNew),
lastPing(),
vchSig(),
sigTime(GetAdjustedTime()),
nLastDsq(0),
nTimeLastChecked(0),
nTimeLastPaid(0),
nTimeLastWatchdogVote(0),
nActiveState(MASTERNODE_ENABLED),
nCacheCollateralBlock(0),
nBlockLastPaid(0),
nProtocolVersion(nProtocolVersionIn),
nPoSeBanScore(0),
nPoSeBanHeight(0),
fAllowMixingTx(true),
fUnitTest(false)
{}
CMasternode::CMasternode(const CMasternode& other) :
vin(other.vin),
addr(other.addr),
pubKeyCollateralAddress(other.pubKeyCollateralAddress),
pubKeyMasternode(other.pubKeyMasternode),
lastPing(other.lastPing),
vchSig(other.vchSig),
sigTime(other.sigTime),
nLastDsq(other.nLastDsq),
nTimeLastChecked(other.nTimeLastChecked),
nTimeLastPaid(other.nTimeLastPaid),
nTimeLastWatchdogVote(other.nTimeLastWatchdogVote),
nActiveState(other.nActiveState),
nCacheCollateralBlock(other.nCacheCollateralBlock),
nBlockLastPaid(other.nBlockLastPaid),
nProtocolVersion(other.nProtocolVersion),
nPoSeBanScore(other.nPoSeBanScore),
nPoSeBanHeight(other.nPoSeBanHeight),
fAllowMixingTx(other.fAllowMixingTx),
fUnitTest(other.fUnitTest)
{}
CMasternode::CMasternode(const CMasternodeBroadcast& mnb) :
vin(mnb.vin),
addr(mnb.addr),
pubKeyCollateralAddress(mnb.pubKeyCollateralAddress),
pubKeyMasternode(mnb.pubKeyMasternode),
lastPing(mnb.lastPing),
vchSig(mnb.vchSig),
sigTime(mnb.sigTime),
nLastDsq(0),
nTimeLastChecked(0),
nTimeLastPaid(0),
nTimeLastWatchdogVote(mnb.sigTime),
nActiveState(mnb.nActiveState),
nCacheCollateralBlock(0),
nBlockLastPaid(0),
nProtocolVersion(mnb.nProtocolVersion),
nPoSeBanScore(0),
nPoSeBanHeight(0),
fAllowMixingTx(true),
fUnitTest(false)
{}
//
// When a new masternode broadcast is sent, update our information
//
bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb)
{
if(mnb.sigTime <= sigTime && !mnb.fRecovery) return false;
pubKeyMasternode = mnb.pubKeyMasternode;
sigTime = mnb.sigTime;
vchSig = mnb.vchSig;
nProtocolVersion = mnb.nProtocolVersion;
addr = mnb.addr;
nPoSeBanScore = 0;
nPoSeBanHeight = 0;
nTimeLastChecked = 0;
int nDos = 0;
if(mnb.lastPing == CMasternodePing() || (mnb.lastPing != CMasternodePing() && mnb.lastPing.CheckAndUpdate(this, true, nDos))) {
lastPing = mnb.lastPing;
mnodeman.mapSeenMasternodePing.insert(std::make_pair(lastPing.GetHash(), lastPing));
}
// if it matches our Masternode privkey...
if(fMasterNode && pubKeyMasternode == activeMasternode.pubKeyMasternode) {
nPoSeBanScore = -MASTERNODE_POSE_BAN_MAX_SCORE;
if(nProtocolVersion == PROTOCOL_VERSION) {
// ... and PROTOCOL_VERSION, then we've been remotely activated ...
activeMasternode.ManageState();
} else {
// ... otherwise we need to reactivate our node, do not add it to the list and do not relay
// but also do not ban the node we get this message from
LogPrintf("CMasternode::UpdateFromNewBroadcast -- wrong PROTOCOL_VERSION, re-activate your MN: message nProtocolVersion=%d PROTOCOL_VERSION=%d\n", nProtocolVersion, PROTOCOL_VERSION);
return false;
}
}
return true;
}
//
// Deterministically calculate a given "score" for a Masternode depending on how close it's hash is to
// the proof of work for that block. The further away they are the better, the furthest will win the election
// and get paid this block
//
arith_uint256 CMasternode::CalculateScore(const uint256& blockHash)
{
uint256 aux = ArithToUint256(UintToArith256(vin.prevout.hash) + vin.prevout.n);
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << blockHash;
arith_uint256 hash2 = UintToArith256(ss.GetHash());
CHashWriter ss2(SER_GETHASH, PROTOCOL_VERSION);
ss2 << blockHash;
ss2 << aux;
arith_uint256 hash3 = UintToArith256(ss2.GetHash());
return (hash3 > hash2 ? hash3 - hash2 : hash2 - hash3);
}
void CMasternode::Check(bool fForce)
{
LOCK(cs);
if(ShutdownRequested()) return;
if(!fForce && (GetTime() - nTimeLastChecked < MASTERNODE_CHECK_SECONDS)) return;
nTimeLastChecked = GetTime();
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state\n", vin.prevout.ToStringShort(), GetStateString());
//once spent, stop doing the checks
if(IsOutpointSpent()) return;
int nHeight = 0;
if(!fUnitTest) {
TRY_LOCK(cs_main, lockMain);
if(!lockMain) return;
CCoins coins;
if(!pcoinsTip->GetCoins(vin.prevout.hash, coins) ||
(unsigned int)vin.prevout.n>=coins.vout.size() ||
coins.vout[vin.prevout.n].IsNull()) {
nActiveState = MASTERNODE_OUTPOINT_SPENT;
LogPrint("masternode", "CMasternode::Check -- Failed to find Masternode UTXO, masternode=%s\n", vin.prevout.ToStringShort());
return;
}
nHeight = chainActive.Height();
}
if(IsPoSeBanned()) {
if(nHeight < nPoSeBanHeight) return; // too early?
// Otherwise give it a chance to proceed further to do all the usual checks and to change its state.
// Masternode still will be on the edge and can be banned back easily if it keeps ignoring mnverify
// or connect attempts. Will require few mnverify messages to strengthen its position in mn list.
LogPrintf("CMasternode::Check -- Masternode %s is unbanned and back in list now\n", vin.prevout.ToStringShort());
DecreasePoSeBanScore();
} else if(nPoSeBanScore >= MASTERNODE_POSE_BAN_MAX_SCORE) {
nActiveState = MASTERNODE_POSE_BAN;
// ban for the whole payment cycle
nPoSeBanHeight = nHeight + mnodeman.size();
LogPrintf("CMasternode::Check -- Masternode %s is banned till block %d now\n", vin.prevout.ToStringShort(), nPoSeBanHeight);
return;
}
int nActiveStatePrev = nActiveState;
bool fOurMasternode = fMasterNode && activeMasternode.pubKeyMasternode == pubKeyMasternode;
// masternode doesn't meet payment protocol requirements ...
bool fRequireUpdate = nProtocolVersion < mnpayments.GetMinMasternodePaymentsProto() ||
// or it's our own node and we just updated it to the new protocol but we are still waiting for activation ...
(fOurMasternode && nProtocolVersion < PROTOCOL_VERSION);
if(fRequireUpdate) {
nActiveState = MASTERNODE_UPDATE_REQUIRED;
if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
}
return;
}
// keep old masternodes on start, give them a chance to receive updates...
bool fWaitForPing = !masternodeSync.IsMasternodeListSynced() && !IsPingedWithin(MASTERNODE_MIN_MNP_SECONDS);
//
// REMOVE AFTER MIGRATION TO 12.1
//
// Old nodes don't send pings on dseg, so they could switch to one of the expired states
// if we were offline for too long even if they are actually enabled for the rest
// of the network. Postpone their check for MASTERNODE_MIN_MNP_SECONDS seconds.
// This could be usefull for 12.1 migration, can be removed after it's done.
static int64_t nTimeStart = GetTime();
if(nProtocolVersion < 70204) {
if(!masternodeSync.IsMasternodeListSynced()) nTimeStart = GetTime();
fWaitForPing = GetTime() - nTimeStart < MASTERNODE_MIN_MNP_SECONDS;
}
//
// END REMOVE
//
if(fWaitForPing && !fOurMasternode) {
// ...but if it was already expired before the initial check - return right away
if(IsExpired() || IsWatchdogExpired() || IsNewStartRequired()) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state, waiting for ping\n", vin.prevout.ToStringShort(), GetStateString());
return;
}
}
// don't expire if we are still in "waiting for ping" mode unless it's our own masternode
if(!fWaitForPing || fOurMasternode) {
if(!IsPingedWithin(MASTERNODE_NEW_START_REQUIRED_SECONDS)) {
nActiveState = MASTERNODE_NEW_START_REQUIRED;
if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
}
return;
}
bool fWatchdogActive = masternodeSync.IsSynced() && mnodeman.IsWatchdogActive();
bool fWatchdogExpired = (fWatchdogActive && ((GetTime() - nTimeLastWatchdogVote) > MASTERNODE_WATCHDOG_MAX_SECONDS));
LogPrint("masternode", "CMasternode::Check -- outpoint=%s, nTimeLastWatchdogVote=%d, GetTime()=%d, fWatchdogExpired=%d\n",
vin.prevout.ToStringShort(), nTimeLastWatchdogVote, GetTime(), fWatchdogExpired);
if(fWatchdogExpired) {
nActiveState = MASTERNODE_WATCHDOG_EXPIRED;
if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
}
return;
}
if(!IsPingedWithin(MASTERNODE_EXPIRATION_SECONDS)) {
nActiveState = MASTERNODE_EXPIRED;
if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
}
return;
}
}
if(lastPing.sigTime - sigTime < MASTERNODE_MIN_MNP_SECONDS) {
nActiveState = MASTERNODE_PRE_ENABLED;
if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
}
return;
}
nActiveState = MASTERNODE_ENABLED; // OK
if(nActiveStatePrev != nActiveState) {
LogPrint("masternode", "CMasternode::Check -- Masternode %s is in %s state now\n", vin.prevout.ToStringShort(), GetStateString());
}
}
bool CMasternode::IsValidNetAddr()
{
return IsValidNetAddr(addr);
}
bool CMasternode::IsValidNetAddr(CService addrIn)
{
// TODO: regtest is fine with any addresses for now,
// should probably be a bit smarter if one day we start to implement tests for this
return Params().NetworkIDString() == CBaseChainParams::REGTEST ||
(addrIn.IsIPv4() && IsReachable(addrIn) && addrIn.IsRoutable());
}
masternode_info_t CMasternode::GetInfo()
{
masternode_info_t info;
info.vin = vin;
info.addr = addr;
info.pubKeyCollateralAddress = pubKeyCollateralAddress;
info.pubKeyMasternode = pubKeyMasternode;
info.sigTime = sigTime;
info.nLastDsq = nLastDsq;
info.nTimeLastChecked = nTimeLastChecked;
info.nTimeLastPaid = nTimeLastPaid;
info.nTimeLastWatchdogVote = nTimeLastWatchdogVote;
info.nActiveState = nActiveState;
info.nProtocolVersion = nProtocolVersion;
info.fInfoValid = true;
return info;
}
std::string CMasternode::StateToString(int nStateIn)
{
switch(nStateIn) {
case MASTERNODE_PRE_ENABLED: return "PRE_ENABLED";
case MASTERNODE_ENABLED: return "ENABLED";
case MASTERNODE_EXPIRED: return "EXPIRED";
case MASTERNODE_OUTPOINT_SPENT: return "OUTPOINT_SPENT";
case MASTERNODE_UPDATE_REQUIRED: return "UPDATE_REQUIRED";
case MASTERNODE_WATCHDOG_EXPIRED: return "WATCHDOG_EXPIRED";
case MASTERNODE_NEW_START_REQUIRED: return "NEW_START_REQUIRED";
case MASTERNODE_POSE_BAN: return "POSE_BAN";
default: return "UNKNOWN";
}
}
std::string CMasternode::GetStateString() const
{
return StateToString(nActiveState);
}
std::string CMasternode::GetStatus() const
{
// TODO: return smth a bit more human readable here
return GetStateString();
}
int CMasternode::GetCollateralAge()
{
int nHeight;
{
TRY_LOCK(cs_main, lockMain);
if(!lockMain || !chainActive.Tip()) return -1;
nHeight = chainActive.Height();
}
if (nCacheCollateralBlock == 0) {
int nInputAge = GetInputAge(vin);
if(nInputAge > 0) {
nCacheCollateralBlock = nHeight - nInputAge;
} else {
return nInputAge;
}
}
return nHeight - nCacheCollateralBlock;
}
void CMasternode::UpdateLastPaid(const CBlockIndex *pindex, int nMaxBlocksToScanBack)
{
if(!pindex) return;
const CBlockIndex *BlockReading = pindex;
CScript mnpayee = GetScriptForDestination(pubKeyCollateralAddress.GetID());
// LogPrint("masternode", "CMasternode::UpdateLastPaidBlock -- searching for block with payment to %s\n", vin.prevout.ToStringShort());
LOCK(cs_mapMasternodeBlocks);
for (int i = 0; BlockReading && BlockReading->nHeight > nBlockLastPaid && i < nMaxBlocksToScanBack; i++) {
if(mnpayments.mapMasternodeBlocks.count(BlockReading->nHeight) &&
mnpayments.mapMasternodeBlocks[BlockReading->nHeight].HasPayeeWithVotes(mnpayee, 2))
{
CBlock block;
if(!ReadBlockFromDisk(block, BlockReading, Params().GetConsensus())) // shouldn't really happen
continue;
CAmount nMasternodePayment = GetMasternodePayment(BlockReading->nHeight, block.vtx[0].GetValueOut());
BOOST_FOREACH(CTxOut txout, block.vtx[0].vout)
if(mnpayee == txout.scriptPubKey && nMasternodePayment == txout.nValue) {
nBlockLastPaid = BlockReading->nHeight;
nTimeLastPaid = BlockReading->nTime;
LogPrint("masternode", "CMasternode::UpdateLastPaidBlock -- searching for block with payment to %s -- found new %d\n", vin.prevout.ToStringShort(), nBlockLastPaid);
return;
}
}
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
BlockReading = BlockReading->pprev;
}
// Last payment for this masternode wasn't found in latest mnpayments blocks
// or it was found in mnpayments blocks but wasn't found in the blockchain.
// LogPrint("masternode", "CMasternode::UpdateLastPaidBlock -- searching for block with payment to %s -- keeping old %d\n", vin.prevout.ToStringShort(), nBlockLastPaid);
}
bool CMasternodeBroadcast::Create(std::string strService, std::string strKeyMasternode, std::string strTxHash, std::string strOutputIndex, std::string& strErrorRet, CMasternodeBroadcast &mnbRet, bool fOffline)
{
CTxIn txin;
CPubKey pubKeyCollateralAddressNew;
CKey keyCollateralAddressNew;
CPubKey pubKeyMasternodeNew;
CKey keyMasternodeNew;
//need correct blocks to send ping
if(!fOffline && !masternodeSync.IsBlockchainSynced()) {
strErrorRet = "Sync in progress. Must wait until sync is complete to start Masternode";
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
return false;
}
if(!darkSendSigner.GetKeysFromSecret(strKeyMasternode, keyMasternodeNew, pubKeyMasternodeNew)) {
strErrorRet = strprintf("Invalid masternode key %s", strKeyMasternode);
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
return false;
}
if(!pwalletMain->GetMasternodeVinAndKeys(txin, pubKeyCollateralAddressNew, keyCollateralAddressNew, strTxHash, strOutputIndex)) {
strErrorRet = strprintf("Could not allocate txin %s:%s for masternode %s", strTxHash, strOutputIndex, strService);
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
return false;
}
CService service = CService(strService);
int mainnetDefaultPort = Params(CBaseChainParams::MAIN).GetDefaultPort();
if(Params().NetworkIDString() == CBaseChainParams::MAIN) {
if(service.GetPort() != mainnetDefaultPort) {
strErrorRet = strprintf("Invalid port %u for masternode %s, only %d is supported on mainnet.", service.GetPort(), strService, mainnetDefaultPort);
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
return false;
}
} else if (service.GetPort() == mainnetDefaultPort) {
strErrorRet = strprintf("Invalid port %u for masternode %s, %d is the only supported on mainnet.", service.GetPort(), strService, mainnetDefaultPort);
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
return false;
}
return Create(txin, CService(strService), keyCollateralAddressNew, pubKeyCollateralAddressNew, keyMasternodeNew, pubKeyMasternodeNew, strErrorRet, mnbRet);
}
bool CMasternodeBroadcast::Create(CTxIn txin, CService service, CKey keyCollateralAddressNew, CPubKey pubKeyCollateralAddressNew, CKey keyMasternodeNew, CPubKey pubKeyMasternodeNew, std::string &strErrorRet, CMasternodeBroadcast &mnbRet)
{
// wait for reindex and/or import to finish
if (fImporting || fReindex) return false;
LogPrint("masternode", "CMasternodeBroadcast::Create -- pubKeyCollateralAddressNew = %s, pubKeyMasternodeNew.GetID() = %s\n",
CBitcoinAddress(pubKeyCollateralAddressNew.GetID()).ToString(),
pubKeyMasternodeNew.GetID().ToString());
CMasternodePing mnp(txin);
if(!mnp.Sign(keyMasternodeNew, pubKeyMasternodeNew)) {
strErrorRet = strprintf("Failed to sign ping, masternode=%s", txin.prevout.ToStringShort());
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
mnbRet = CMasternodeBroadcast();
return false;
}
mnbRet = CMasternodeBroadcast(service, txin, pubKeyCollateralAddressNew, pubKeyMasternodeNew, PROTOCOL_VERSION);
if(!mnbRet.IsValidNetAddr()) {
strErrorRet = strprintf("Invalid IP address, masternode=%s", txin.prevout.ToStringShort());
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
mnbRet = CMasternodeBroadcast();
return false;
}
mnbRet.lastPing = mnp;
if(!mnbRet.Sign(keyCollateralAddressNew)) {
strErrorRet = strprintf("Failed to sign broadcast, masternode=%s", txin.prevout.ToStringShort());
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
mnbRet = CMasternodeBroadcast();
return false;
}
return true;
}
bool CMasternodeBroadcast::SimpleCheck(int& nDos)
{
nDos = 0;
// make sure addr is valid
if(!IsValidNetAddr()) {
LogPrintf("CMasternodeBroadcast::SimpleCheck -- Invalid addr, rejected: masternode=%s addr=%s\n",
vin.prevout.ToStringShort(), addr.ToString());
return false;
}
// make sure signature isn't in the future (past is OK)
if (sigTime > GetAdjustedTime() + 60 * 60) {
LogPrintf("CMasternodeBroadcast::SimpleCheck -- Signature rejected, too far into the future: masternode=%s\n", vin.prevout.ToStringShort());
nDos = 1;
return false;
}
// empty ping or incorrect sigTime/unknown blockhash
if(lastPing == CMasternodePing() || !lastPing.SimpleCheck(nDos)) {
// one of us is probably forked or smth, just mark it as expired and check the rest of the rules
nActiveState = MASTERNODE_EXPIRED;
}
if(nProtocolVersion < mnpayments.GetMinMasternodePaymentsProto()) {
LogPrintf("CMasternodeBroadcast::SimpleCheck -- ignoring outdated Masternode: masternode=%s nProtocolVersion=%d\n", vin.prevout.ToStringShort(), nProtocolVersion);
return false;
}
CScript pubkeyScript;
pubkeyScript = GetScriptForDestination(pubKeyCollateralAddress.GetID());
if(pubkeyScript.size() != 25) {
LogPrintf("CMasternodeBroadcast::SimpleCheck -- pubKeyCollateralAddress has the wrong size\n");
nDos = 100;
return false;
}
CScript pubkeyScript2;
pubkeyScript2 = GetScriptForDestination(pubKeyMasternode.GetID());
if(pubkeyScript2.size() != 25) {
LogPrintf("CMasternodeBroadcast::SimpleCheck -- pubKeyMasternode has the wrong size\n");
nDos = 100;
return false;
}
if(!vin.scriptSig.empty()) {
LogPrintf("CMasternodeBroadcast::SimpleCheck -- Ignore Not Empty ScriptSig %s\n",vin.ToString());
nDos = 100;
return false;
}
int mainnetDefaultPort = Params(CBaseChainParams::MAIN).GetDefaultPort();
if(Params().NetworkIDString() == CBaseChainParams::MAIN) {
if(addr.GetPort() != mainnetDefaultPort) return false;
} else if(addr.GetPort() == mainnetDefaultPort) return false;
return true;
}
bool CMasternodeBroadcast::Update(CMasternode* pmn, int& nDos)
{
nDos = 0;
if(pmn->sigTime == sigTime && !fRecovery) {
// mapSeenMasternodeBroadcast in CMasternodeMan::CheckMnbAndUpdateMasternodeList should filter legit duplicates
// but this still can happen if we just started, which is ok, just do nothing here.
return false;
}
// this broadcast is older than the one that we already have - it's bad and should never happen
// unless someone is doing something fishy
if(pmn->sigTime > sigTime) {
LogPrintf("CMasternodeBroadcast::Update -- Bad sigTime %d (existing broadcast is at %d) for Masternode %s %s\n",
sigTime, pmn->sigTime, vin.prevout.ToStringShort(), addr.ToString());
return false;
}
pmn->Check();
// masternode is banned by PoSe
if(pmn->IsPoSeBanned()) {
LogPrintf("CMasternodeBroadcast::Update -- Banned by PoSe, masternode=%s\n", vin.prevout.ToStringShort());
return false;
}
// IsVnAssociatedWithPubkey is validated once in CheckOutpoint, after that they just need to match
if(pmn->pubKeyCollateralAddress != pubKeyCollateralAddress) {
LogPrintf("CMasternodeBroadcast::Update -- Got mismatched pubKeyCollateralAddress and vin\n");
nDos = 33;
return false;
}
if (!CheckSignature(nDos)) {
LogPrintf("CMasternodeBroadcast::Update -- CheckSignature() failed, masternode=%s\n", vin.prevout.ToStringShort());
return false;
}
// if ther was no masternode broadcast recently or if it matches our Masternode privkey...
if(!pmn->IsBroadcastedWithin(MASTERNODE_MIN_MNB_SECONDS) || (fMasterNode && pubKeyMasternode == activeMasternode.pubKeyMasternode)) {
// take the newest entry
LogPrintf("CMasternodeBroadcast::Update -- Got UPDATED Masternode entry: addr=%s\n", addr.ToString());
if(pmn->UpdateFromNewBroadcast((*this))) {
pmn->Check();
Relay();
}
masternodeSync.AddedMasternodeList();
}
return true;
}
bool CMasternodeBroadcast::CheckOutpoint(int& nDos)
{
// we are a masternode with the same vin (i.e. already activated) and this mnb is ours (matches our Masternode privkey)
// so nothing to do here for us
if(fMasterNode && vin.prevout == activeMasternode.vin.prevout && pubKeyMasternode == activeMasternode.pubKeyMasternode) {
return false;
}
if (!CheckSignature(nDos)) {
LogPrintf("CMasternodeBroadcast::CheckOutpoint -- CheckSignature() failed, masternode=%s\n", vin.prevout.ToStringShort());
return false;
}
{
TRY_LOCK(cs_main, lockMain);
if(!lockMain) {
// not mnb fault, let it to be checked again later
LogPrint("masternode", "CMasternodeBroadcast::CheckOutpoint -- Failed to aquire lock, addr=%s", addr.ToString());
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());
return false;
}
CCoins coins;
if(!pcoinsTip->GetCoins(vin.prevout.hash, coins) ||
(unsigned int)vin.prevout.n>=coins.vout.size() ||
coins.vout[vin.prevout.n].IsNull()) {
LogPrint("masternode", "CMasternodeBroadcast::CheckOutpoint -- Failed to find Masternode UTXO, masternode=%s\n", vin.prevout.ToStringShort());
return false;
}
if(coins.vout[vin.prevout.n].nValue != 1000 * COIN) {
LogPrint("masternode", "CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO should have 1000 ADN, masternode=%s\n", vin.prevout.ToStringShort());
return false;
}
if(chainActive.Height() - coins.nHeight + 1 < Params().GetConsensus().nMasternodeMinimumConfirmations) {
LogPrintf("CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO must have at least %d confirmations, masternode=%s\n",
Params().GetConsensus().nMasternodeMinimumConfirmations, vin.prevout.ToStringShort());
// maybe we miss few blocks, let this mnb to be checked again later
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());
return false;
}
}
LogPrint("masternode", "CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO verified\n");
// make sure the vout that was signed is related to the transaction that spawned the Masternode
// - this is expensive, so it's only done once per Masternode
if(!darkSendSigner.IsVinAssociatedWithPubkey(vin, pubKeyCollateralAddress)) {
LogPrintf("CMasternodeMan::CheckOutpoint -- Got mismatched pubKeyCollateralAddress and vin\n");
nDos = 33;
return false;
}
// verify that sig time is legit in past
// should be at least not earlier than block when 1000 ADN tx got nMasternodeMinimumConfirmations
uint256 hashBlock = uint256();
CTransaction tx2;
GetTransaction(vin.prevout.hash, tx2, Params().GetConsensus(), hashBlock, true);
{
LOCK(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pMNIndex = (*mi).second; // block for 1000 ADN tx -> 1 confirmation
CBlockIndex* pConfIndex = chainActive[pMNIndex->nHeight + Params().GetConsensus().nMasternodeMinimumConfirmations - 1]; // block where tx got nMasternodeMinimumConfirmations
if(pConfIndex->GetBlockTime() > sigTime) {
LogPrintf("CMasternodeBroadcast::CheckOutpoint -- Bad sigTime %d (%d conf block is at %d) for Masternode %s %s\n",
sigTime, Params().GetConsensus().nMasternodeMinimumConfirmations, pConfIndex->GetBlockTime(), vin.prevout.ToStringShort(), addr.ToString());
return false;
}
}
}
return true;
}
bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
{
std::string strError;
std::string strMessage;
sigTime = GetAdjustedTime();
strMessage = addr.ToString(false) + boost::lexical_cast<std::string>(sigTime) +
pubKeyCollateralAddress.GetID().ToString() + pubKeyMasternode.GetID().ToString() +
boost::lexical_cast<std::string>(nProtocolVersion);
if(!darkSendSigner.SignMessage(strMessage, vchSig, keyCollateralAddress)) {
LogPrintf("CMasternodeBroadcast::Sign -- SignMessage() failed\n");
return false;
}
if(!darkSendSigner.VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)) {
LogPrintf("CMasternodeBroadcast::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
return true;
}
bool CMasternodeBroadcast::CheckSignature(int& nDos)
{
std::string strMessage;
std::string strError = "";
nDos = 0;
//
// REMOVE AFTER MIGRATION TO 12.1
//
if(nProtocolVersion < 70201) {
std::string vchPubkeyCollateralAddress(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end());
std::string vchPubkeyMasternode(pubKeyMasternode.begin(), pubKeyMasternode.end());
strMessage = addr.ToString(false) + boost::lexical_cast<std::string>(sigTime) +
vchPubkeyCollateralAddress + vchPubkeyMasternode + boost::lexical_cast<std::string>(nProtocolVersion);
LogPrint("masternode", "CMasternodeBroadcast::CheckSignature -- sanitized strMessage: %s pubKeyCollateralAddress address: %s sig: %s\n",
SanitizeString(strMessage), CBitcoinAddress(pubKeyCollateralAddress.GetID()).ToString(),
EncodeBase64(&vchSig[0], vchSig.size()));
if(!darkSendSigner.VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)) {
if(addr.ToString() != addr.ToString(false)) {
// maybe it's wrong format, try again with the old one
strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) +
vchPubkeyCollateralAddress + vchPubkeyMasternode + boost::lexical_cast<std::string>(nProtocolVersion);
LogPrint("masternode", "CMasternodeBroadcast::CheckSignature -- second try, sanitized strMessage: %s pubKeyCollateralAddress address: %s sig: %s\n",
SanitizeString(strMessage), CBitcoinAddress(pubKeyCollateralAddress.GetID()).ToString(),
EncodeBase64(&vchSig[0], vchSig.size()));
if(!darkSendSigner.VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)) {
// didn't work either
LogPrintf("CMasternodeBroadcast::CheckSignature -- Got bad Masternode announce signature, second try, sanitized error: %s\n",
SanitizeString(strError));
// don't ban for old masternodes, their sigs could be broken because of the bug
return false;
}
} else {
// nope, sig is actually wrong
LogPrintf("CMasternodeBroadcast::CheckSignature -- Got bad Masternode announce signature, sanitized error: %s\n",
SanitizeString(strError));
// don't ban for old masternodes, their sigs could be broken because of the bug
return false;
}
}
} else {
//
// END REMOVE
//
strMessage = addr.ToString(false) + boost::lexical_cast<std::string>(sigTime) +
pubKeyCollateralAddress.GetID().ToString() + pubKeyMasternode.GetID().ToString() +
boost::lexical_cast<std::string>(nProtocolVersion);
LogPrint("masternode", "CMasternodeBroadcast::CheckSignature -- strMessage: %s pubKeyCollateralAddress address: %s sig: %s\n", strMessage, CBitcoinAddress(pubKeyCollateralAddress.GetID()).ToString(), EncodeBase64(&vchSig[0], vchSig.size()));
if(!darkSendSigner.VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)){
LogPrintf("CMasternodeBroadcast::CheckSignature -- Got bad Masternode announce signature, error: %s\n", strError);
nDos = 100;
return false;
}
}
return true;
}
void CMasternodeBroadcast::Relay()
{
CInv inv(MSG_MASTERNODE_ANNOUNCE, GetHash());
RelayInv(inv);
}
CMasternodePing::CMasternodePing(CTxIn& vinNew)
{
LOCK(cs_main);
if (!chainActive.Tip() || chainActive.Height() < 12) return;
vin = vinNew;
blockHash = chainActive[chainActive.Height() - 12]->GetBlockHash();
sigTime = GetAdjustedTime();
vchSig = std::vector<unsigned char>();
}
bool CMasternodePing::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
{
std::string strError;
std::string strMasterNodeSignMessage;
sigTime = GetAdjustedTime();
std::string strMessage = vin.ToString() + blockHash.ToString() + boost::lexical_cast<std::string>(sigTime);
if(!darkSendSigner.SignMessage(strMessage, vchSig, keyMasternode)) {
LogPrintf("CMasternodePing::Sign -- SignMessage() failed\n");
return false;
}
if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
LogPrintf("CMasternodePing::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
return true;
}
bool CMasternodePing::CheckSignature(CPubKey& pubKeyMasternode, int &nDos)
{
std::string strMessage = vin.ToString() + blockHash.ToString() + boost::lexical_cast<std::string>(sigTime);
std::string strError = "";
nDos = 0;
if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
LogPrintf("CMasternodePing::CheckSignature -- Got bad Masternode ping signature, masternode=%s, error: %s\n", vin.prevout.ToStringShort(), strError);
nDos = 33;
return false;
}
return true;
}
bool CMasternodePing::SimpleCheck(int& nDos)
{
// don't ban by default
nDos = 0;
if (sigTime > GetAdjustedTime() + 60 * 60) {
LogPrintf("CMasternodePing::SimpleCheck -- Signature rejected, too far into the future, masternode=%s\n", vin.prevout.ToStringShort());
nDos = 1;
return false;
}
{
LOCK(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(blockHash);
if (mi == mapBlockIndex.end()) {
LogPrint("masternode", "CMasternodePing::SimpleCheck -- Masternode ping is invalid, unknown block hash: masternode=%s blockHash=%s\n", vin.prevout.ToStringShort(), blockHash.ToString());
// maybe we stuck or forked so we shouldn't ban this node, just fail to accept this ping
// TODO: or should we also request this block?
return false;
}
}
LogPrint("masternode", "CMasternodePing::SimpleCheck -- Masternode ping verified: masternode=%s blockHash=%s sigTime=%d\n", vin.prevout.ToStringShort(), blockHash.ToString(), sigTime);
return true;
}
bool CMasternodePing::CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, int& nDos)
{
// don't ban by default
nDos = 0;
if (!SimpleCheck(nDos)) {
return false;
}
if (pmn == NULL) {
LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- Couldn't find Masternode entry, masternode=%s\n", vin.prevout.ToStringShort());
return false;
}
if(!fFromNewBroadcast) {
if (pmn->IsUpdateRequired()) {
LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- masternode protocol is outdated, masternode=%s\n", vin.prevout.ToStringShort());
return false;
}
if (pmn->IsNewStartRequired()) {
LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- masternode is completely expired, new start is required, masternode=%s\n", vin.prevout.ToStringShort());
return false;
}
}
{
LOCK(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(blockHash);
if ((*mi).second && (*mi).second->nHeight < chainActive.Height() - 24) {
LogPrintf("CMasternodePing::CheckAndUpdate -- Masternode ping is invalid, block hash is too old: masternode=%s blockHash=%s\n", vin.prevout.ToStringShort(), blockHash.ToString());
// nDos = 1;
return false;
}
}
LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- New ping: masternode=%s blockHash=%s sigTime=%d\n", vin.prevout.ToStringShort(), blockHash.ToString(), sigTime);
// LogPrintf("mnping - Found corresponding mn for vin: %s\n", vin.prevout.ToStringShort());
// update only if there is no known ping for this masternode or
// last ping was more then MASTERNODE_MIN_MNP_SECONDS-60 ago comparing to this one
if (pmn->IsPingedWithin(MASTERNODE_MIN_MNP_SECONDS - 60, sigTime)) {
LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- Masternode ping arrived too early, masternode=%s\n", vin.prevout.ToStringShort());
//nDos = 1; //disable, this is happening frequently and causing banned peers
return false;
}
if (!CheckSignature(pmn->pubKeyMasternode, nDos)) return false;
// so, ping seems to be ok, let's store it
LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- Masternode ping accepted, masternode=%s\n", vin.prevout.ToStringShort());
pmn->lastPing = *this;
// and update mnodeman.mapSeenMasternodeBroadcast.lastPing which is probably outdated
CMasternodeBroadcast mnb(*pmn);
uint256 hash = mnb.GetHash();
if (mnodeman.mapSeenMasternodeBroadcast.count(hash)) {
mnodeman.mapSeenMasternodeBroadcast[hash].second.lastPing = *this;
}
pmn->Check(true); // force update, ignoring cache
if (!pmn->IsEnabled()) return false;
LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- Masternode ping acceepted and relayed, masternode=%s\n", vin.prevout.ToStringShort());
Relay();
return true;
}
void CMasternodePing::Relay()
{
CInv inv(MSG_MASTERNODE_PING, GetHash());
RelayInv(inv);
}
void CMasternode::AddGovernanceVote(uint256 nGovernanceObjectHash)
{
if(mapGovernanceObjectsVotedOn.count(nGovernanceObjectHash)) {
mapGovernanceObjectsVotedOn[nGovernanceObjectHash]++;
} else {
mapGovernanceObjectsVotedOn.insert(std::make_pair(nGovernanceObjectHash, 1));
}
}
void CMasternode::RemoveGovernanceObject(uint256 nGovernanceObjectHash)
{
std::map<uint256, int>::iterator it = mapGovernanceObjectsVotedOn.find(nGovernanceObjectHash);
if(it == mapGovernanceObjectsVotedOn.end()) {
return;
}
mapGovernanceObjectsVotedOn.erase(it);
}
void CMasternode::UpdateWatchdogVoteTime()
{
LOCK(cs);
nTimeLastWatchdogVote = GetTime();
}
/**
* FLAG GOVERNANCE ITEMS AS DIRTY
*
* - When masternode come and go on the network, we must flag the items they voted on to recalc it's cached flags
*
*/
void CMasternode::FlagGovernanceItemsAsDirty()
{
std::vector<uint256> vecDirty;
{
std::map<uint256, int>::iterator it = mapGovernanceObjectsVotedOn.begin();
while(it != mapGovernanceObjectsVotedOn.end()) {
vecDirty.push_back(it->first);
++it;
}
}
for(size_t i = 0; i < vecDirty.size(); ++i) {
mnodeman.AddDirtyGovernanceObjectHash(vecDirty[i]);
}
}
|
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi, <lganzzzo@gmail.com>
*
* 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 "./Object.hpp"
|
#include "ModuleWindow.h"
#include "WholesomeEvent.h"
#include <SDL2/SDL_vulkan.h>
ModuleWindow::ModuleWindow() : Module(), window(nullptr, SDL_DestroyWindow)
{
DEBUG::LOG("CREATING MODULE WINDOW", nullptr);
}
ModuleWindow::~ModuleWindow()
{
}
ENGINE_STATUS ModuleWindow::Init()
{
ENGINE_STATUS ret = ENGINE_STATUS::SUCCESS;
std::string_view name{ "Wholesome Engine" };
//Init SDL
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
DEBUG::LOG("[ERROR] Could not Init SDL % ", SDL_GetError());
return ENGINE_STATUS::FAIL;
}
DEBUG::LOG("[SUCCESS] SDL Init Successfully", nullptr);
//Create Window
window.reset(SDL_CreateWindow(name.data(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_VULKAN));
if (window == nullptr)
{
DEBUG::LOG("[ERROR] Could not Create Window % ", SDL_GetError());
return ENGINE_STATUS::FAIL;
}
DEBUG::LOG("[SUCCESS] SDL Window Created Successfully", nullptr);
//Send event to render
BroadcastEvent(WEWindowCreation{ *window });
return ret;
}
ENGINE_STATUS ModuleWindow::CleanUp()
{
DEBUG::LOG("...Cleaning Window...", nullptr);
window.reset(nullptr);
SDL_Quit();
return ENGINE_STATUS::SUCCESS;
}
//void ModuleWindow::OnEventRecieved(const WESurfaceCreation& event_recieved)
//{
// if (SDL_Vulkan_CreateSurface(window.get(), event_recieved.vulkan_instance, &c_surface) != SDL_TRUE)
// {
// DEBUG::LOG("[ERROR] VULKAN SURFACE CREATION FAILURE: %", SDL_GetError());
// }
// else DEBUG::LOG("[SUCCESS] SDL_Vulkan_CreateSurface successfully", nullptr);
//
//
//}
|
// Copyright 2019 ETH Zürich, Thomas Schöps
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#include "badslam/kernel_verify_count.h"
#include "badslam/cuda_util.cuh"
#include "badslam/kernels.h"
#include "badslam/keyframe.h"
#include "badslam/surfel_projection.cuh"
#include "badslam/surfel_projection.h"
namespace vis {
void DebugVerifySurfelCount(
cudaStream_t stream,
u32 surfel_count,
u32 surfels_size,
const CUDABuffer<float>& surfels) {
// NOTE: Repeated allocation of this buffer is probably slow, but this should
// not matter since this is a debug function.
CUDABuffer<u32> count_buffer(1, 1);
count_buffer.Clear(0, stream);
CallCountValidSurfelsCUDAKernel(
stream,
surfels_size,
surfels.ToCUDA(),
count_buffer.ToCUDA());
u32 count;
count_buffer.DownloadAsync(stream, &count);
cudaStreamSynchronize(stream);
CHECK_EQ(count, surfel_count);
LOG(INFO) << "DebugVerifySurfelCount: ok";
}
}
|
// -*-c++-*-
/*!
\file self_intercept_v13.cpp
\brief self intercept predictor for rcssserver v13+ Source File
*/
/*
*Copyright:
Copyright (C) Hidehisa AKIYAMA
This code 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 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*EndCopyright:
*/
/////////////////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "self_intercept_v13.h"
#include "world_model.h"
#include "intercept_table.h"
#include "self_object.h"
#include "ball_object.h"
#include <rcsc/common/logger.h>
#include <rcsc/common/server_param.h>
#include <rcsc/common/player_type.h>
#include <rcsc/geom/segment_2d.h>
#include <rcsc/geom/vector_2d.h>
#include <rcsc/soccer_math.h>
#include <rcsc/math_util.h>
#include <rcsc/timer.h>
// #define DEBUG_PROFILE
// #define DEBUG_PRINT
// #define DEBUG_PRINT_ONE_STEP
// #define DEBUG_PRINT_SHORT_STEP
// #define DEBUG_PRINT_LONG_STEP
// #define DEBUG_PRINT_LONG_STEP_LEVEL_1
// #define DEBUG_PRINT_LONG_STEP_LEVEL_2
// #define DEBUG_PRINT_LONG_STEP_LEVEL_3
namespace rcsc {
namespace {
//const double control_area_buf = 0.1;
const double control_area_buf = 0.15; // 2009-07-03
//const double control_area_buf = 0.2; // 2009-07-04
}
const int SelfInterceptV13::MAX_SHORT_STEP = 5;
const double SelfInterceptV13::MIN_TURN_THR = 12.5;
//const double SelfInterceptV13::MIN_TURN_THR = 15.0;
const double SelfInterceptV13::BACK_DASH_THR_ANGLE = 100.0;
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predict( const int max_cycle,
std::vector< InterceptInfo > & self_cache ) const
{
#ifdef DEBUG_PROFILE
rcsc::Timer timer;
#endif
// #ifdef DEBUG_PRINT
// dlog.addText( Logger::INTERCEPT,
// __FILE__": ------------- predict self ---------------" );
// #endif
if ( M_ball_pos_cache.size() < 2 )
{
dlog.addText( Logger::INTERCEPT,
__FILE__": no ball position cache." );
std::cerr << M_world.self().unum() << ' '
<< M_world.time()
<< " no ball position cache." << std::endl;
return;
}
const bool save_recovery = ( M_world.self().staminaModel().capacity() == 0.0
? false
: true );
predictOneStep( self_cache );
predictShortStep( max_cycle, save_recovery, self_cache );
predictLongStep( max_cycle, save_recovery, self_cache );
#ifdef SELF_INTERCEPT_USE_NO_SAVE_RECEVERY
predictLongStep( max_cycle, false, self_cache );
#endif
std::sort( self_cache.begin(), self_cache.end(), InterceptInfo::Cmp() );
#ifdef DEBUG_PROFILE
dlog.addText( Logger::INTERCEPT,
__FILE__" (predict) elapsed %f [ms]",
timer.elapsedReal() );
#endif
#ifdef DEBUG_PRINT
dlog.addText( Logger::INTERCEPT,
"(SelfIntercept) solution size = %d",
self_cache.size() );
const std::vector< InterceptInfo >::iterator end = self_cache.end();
for ( std::vector< InterceptInfo >::iterator it = self_cache.begin();
it != end;
++it )
{
Vector2D bpos = M_world.ball().inertiaPoint( it->reachCycle() );
dlog.addText( Logger::INTERCEPT,
"(SelfIntercept) type=%d cycle=%d (turn=%d dash=%d)"
" power=%.2f angle=%.1f"
" self_pos=(%.2f %.2f) bdist=%.3f stamina=%.1f",
it->mode(),
it->reachCycle(),
it->turnCycle(),
it->dashCycle(),
it->dashPower(),
it->dashAngle().degree(),
it->selfPos().x, it->selfPos().y,
it->ballDist(),
it->stamina() );
}
#endif
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictOneStep( std::vector< InterceptInfo > & self_cache ) const
{
const Vector2D ball_next = M_world.ball().pos() + M_world.ball().vel();
const bool goalie_mode
= ( M_world.self().goalie()
&& M_world.lastKickerSide() != M_world.ourSide()
&& ball_next.x < ServerParam::i().ourPenaltyAreaLineX()
&& ball_next.absY() < ServerParam::i().penaltyAreaHalfWidth()
);
const double control_area = ( goalie_mode
? ServerParam::i().catchableArea()
: M_world.self().playerType().kickableArea() );
///////////////////////////////////////////////////////////
// current distance is too far. never reach by one dash
if ( M_world.ball().distFromSelf()
> ( ServerParam::i().ballSpeedMax()
+ M_world.self().playerType().realSpeedMax()
+ control_area ) )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"__1 dash: too far. never reach" );
#endif
return;
}
if ( predictNoDash( self_cache ) )
{
// player can get the ball without any action.
// -> player can turn to next target point.
return;
}
predictOneDash( self_cache );
}
/*-------------------------------------------------------------------*/
/*!
*/
bool
SelfInterceptV13::predictNoDash( std::vector< InterceptInfo > & self_cache ) const
{
const ServerParam & SP = ServerParam::i();
const SelfObject & self = M_world.self();
const Vector2D my_next = self.pos() + self.vel();
const Vector2D ball_next = M_world.ball().pos() + M_world.ball().vel();
const bool goalie_mode
= ( self.goalie()
&& M_world.lastKickerSide() != M_world.ourSide()
&& ball_next.x < ServerParam::i().ourPenaltyAreaLineX()
&& ball_next.absY() < ServerParam::i().penaltyAreaHalfWidth()
);
const double control_area = ( goalie_mode
? ServerParam::i().catchableArea()
: self.playerType().kickableArea() );
const Vector2D next_ball_rel = ( ball_next - my_next ).rotatedVector( - self.body() );
const double ball_noise = M_world.ball().vel().r() * ServerParam::i().ballRand();
const double next_ball_dist = next_ball_rel.r();
//
// out of control area
//
if ( next_ball_dist > control_area - 0.15 - ball_noise )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"____No dash, out of control area. area=%.3f ball_dist=%.3f noise=%.3f",
control_area,
next_ball_dist,
ball_noise );
#endif
return false;
}
//
// if goalie, immediately success.
// <--it is not necessary to avoid collision or to adjust kick rate.
//
if ( goalie_mode )
{
StaminaModel stamina_model = self.staminaModel();
stamina_model.simulateWait( self.playerType() );
self_cache.push_back( InterceptInfo( InterceptInfo::NORMAL,
1, 0,
0.0, 0.0,
my_next,
next_ball_dist,
stamina_model.stamina() ) ); // 1 turn
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"--->Success! No dash goalie mode: nothing to do. next_dist=%f",
next_ball_dist );
#endif
return true;
}
//
// check kick effectiveness
//
const PlayerType & ptype = M_world.self().playerType();
if ( next_ball_dist > ptype.playerSize() + SP.ballSize() )
{
double kick_rate = ptype.kickRate( next_ball_dist,
next_ball_rel.th().degree() );
Vector2D next_ball_vel = M_world.ball().vel() * SP.ballDecay();
if ( SP.maxPower() * kick_rate
<= next_ball_vel.r() * SP.ballDecay() * 1.1 )
{
// it has possibility that player cannot stop the ball
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"____No dash, kickable, but maybe no control" );
#endif
return false;
}
}
//
// at least, player can stop the ball
//
StaminaModel stamina_model = self.staminaModel();
stamina_model.simulateWait( self.playerType() );
self_cache.push_back( InterceptInfo( InterceptInfo::NORMAL,
1, 0, // 1 turn
0.0, 0.0,
my_next,
next_ball_dist,
stamina_model.stamina() ) );
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"-->Sucess! No dash, next_dist=%.3f",
next_ball_dist );
#endif
return true;
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictOneDash( std::vector< InterceptInfo > & self_cache ) const
{
static std::vector< InterceptInfo > tmp_cache;
const ServerParam & SP = ServerParam::i();
const BallObject & ball = M_world.ball();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
const Vector2D ball_next = ball.pos() + ball.vel();
const bool goalie_mode
= ( self.goalie()
&& M_world.lastKickerSide() != M_world.ourSide()
&& ball_next.x < SP.ourPenaltyAreaLineX()
&& ball_next.absY() < SP.penaltyAreaHalfWidth()
);
const double control_area = ( goalie_mode
? SP.catchableArea()
: ptype.kickableArea() );
const double dash_angle_step = std::max( 5.0, SP.dashAngleStep() );
const double min_dash_angle = ( -180.0 < SP.minDashAngle() && SP.maxDashAngle() < 180.0
? SP.minDashAngle()
: dash_angle_step * static_cast< int >( -180.0 / dash_angle_step ) );
const double max_dash_angle = ( -180.0 < SP.minDashAngle() && SP.maxDashAngle() < 180.0
? SP.maxDashAngle() + dash_angle_step * 0.5
: dash_angle_step * static_cast< int >( 180.0 / dash_angle_step ) - 1.0 );
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"(predictOneDash) min_angle=%.1f max_angle=%.1f",
min_dash_angle, max_dash_angle );
#endif
tmp_cache.clear();
for ( double dir = min_dash_angle;
dir < max_dash_angle;
dir += dash_angle_step )
{
const AngleDeg dash_angle = self.body() + SP.discretizeDashAngle( SP.normalizeDashAngle( dir ) );
const double dash_rate = self.dashRate() * SP.dashDirRate( dir );
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"(predictOneDash) dir=%.1f angle=%.1f dash_rate=%f",
dir, dash_angle.degree(), dash_rate );
#endif
//
// check receovery save dash
//
const double forward_dash_power
= bound( 0.0,
self.stamina() - SP.recoverDecThrValue() - 1.0,
SP.maxDashPower() );
const double back_dash_power
= bound( SP.minDashPower(),
( self.stamina() - SP.recoverDecThrValue() - 1.0 ) * -0.5,
0.0 );
Vector2D max_forward_accel
= Vector2D::polar2vector( forward_dash_power * dash_rate,
dash_angle );
Vector2D max_back_accel
= Vector2D::polar2vector( back_dash_power * dash_rate,
dash_angle );
ptype.normalizeAccel( self.vel(), &max_forward_accel );
ptype.normalizeAccel( self.vel(), &max_back_accel );
{
InterceptInfo info;
if ( predictOneDashAdjust( dash_angle,
max_forward_accel,
max_back_accel,
control_area,
&info ) )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"****>Register 1 dash intercept(1) mode=%d power=%.1f dir=%.1f pos=(%.1f %.1f) stamina=%.1f",
info.mode(),
info.dashPower(),
info.dashAngle().degree(),
info.selfPos().x, info.selfPos().y,
info.stamina() );
#endif
tmp_cache.push_back( info );
continue;
}
}
//
// check max_power_dash
//
if ( std::fabs( forward_dash_power - SP.maxDashPower() ) < 1.0
&& std::fabs( back_dash_power - SP.minDashPower() ) < 1.0 )
{
continue;
}
max_forward_accel
= Vector2D::polar2vector( SP.maxDashPower() * dash_rate,
dash_angle );
max_back_accel
= Vector2D::polar2vector( SP.minDashPower() * dash_rate,
dash_angle );
ptype.normalizeAccel( self.vel(), &max_forward_accel );
ptype.normalizeAccel( self.vel(), &max_back_accel );
{
InterceptInfo info;
if ( predictOneDashAdjust( dash_angle,
max_forward_accel,
max_back_accel,
control_area,
&info ) )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"****>Register 1 dash intercept(2) mode=%d power=%.1f dir=%.1f pos=(%.1f %.1f) stamina=%.1f",
info.mode(),
info.dashPower(),
info.dashAngle().degree(),
info.selfPos().x, info.selfPos().y,
info.stamina() );
#endif
tmp_cache.push_back( info );
continue;
}
}
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"____(predictOneDash) failed. dash_angle=%.1f",
dash_angle.degree() );
#endif
}
if ( tmp_cache.empty() )
{
return;
}
const double safety_ball_dist = std::max( control_area - 0.2 - ball.vel().r() * SP.ballRand(),
ptype.playerSize() + SP.ballSize() + ptype.kickableMargin() * 0.4 );
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"decide best 1 step interception. size=%d safety_ball_dist=%.3f",
tmp_cache.size(), safety_ball_dist );
#endif
const InterceptInfo * best = &(tmp_cache.front());
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"____ turn=%d dash=%d power=%.1f dir=%.1f ball_dist=%.3f stamina=%.1f",
best->turnCycle(), best->dashCycle(),
best->dashPower(), best->dashAngle().degree(),
best->ballDist(), best->stamina() );
#endif
const std::vector< InterceptInfo >::iterator end = tmp_cache.end();
std::vector< InterceptInfo >::iterator it = tmp_cache.begin();
++it;
for ( ; it != end; ++it )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"____ turn=%d dash=%d power=%.1f dir=%.1f ball_dist=%.3f stamina=%.1f",
it->turnCycle(), it->dashCycle(),
it->dashPower(), it->dashAngle().degree(),
it->ballDist(), it->stamina() );
#endif
if ( best->ballDist() < safety_ball_dist
&& it->ballDist() < safety_ball_dist )
{
if ( best->stamina() < it->stamina() )
{
best = &(*it);
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"--> updated(1)" );
#endif
}
}
else
{
if ( best->ballDist() > it->ballDist()
|| ( std::fabs( best->ballDist() - it->ballDist() ) < 0.001
&& best->stamina() < it->stamina() ) )
{
best = &(*it);
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"--> updated(2)" );
#endif
}
}
}
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"<<<<< Register best cycle=%d(t=%d d=%d) my_pos=(%.2f %.2f) ball_dist=%.3f stamina=%.1f",
best->reachCycle(), best->turnCycle(), best->dashCycle(),
best->ballDist(),
best->selfPos().x, best->selfPos().y,
best->stamina() );
#endif
self_cache.push_back( *best );
}
/*-------------------------------------------------------------------*/
/*!
*/
bool
SelfInterceptV13::predictOneDashAdjust( const AngleDeg & dash_angle,
const Vector2D & max_forward_accel,
const Vector2D & max_back_accel,
const double & control_area,
InterceptInfo * info ) const
{
const ServerParam & SP = ServerParam::i();
const SelfObject & self = M_world.self();
const double control_buf = control_area - 0.075;
const AngleDeg dash_dir = dash_angle - M_world.self().body();
const Vector2D ball_next = M_world.ball().pos() + M_world.ball().vel();
const Vector2D self_next = self.pos() + self.vel();
const Vector2D ball_rel = ( ball_next - self_next ).rotatedVector( -dash_angle );
const Vector2D forward_accel_rel = max_forward_accel.rotatedVector( -dash_angle );
const Vector2D back_accel_rel = max_back_accel.rotatedVector( -dash_angle );
const double dash_rate = self.dashRate() * SP.dashDirRate( dash_dir.degree() );
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"(predictOneDashAdjust) dir=%.1f angle=%.1f ball_rel=(%.3f %.3f)",
dash_dir.degree(),
dash_angle.degree(),
ball_rel.x, ball_rel.y );
dlog.addText( Logger::INTERCEPT,
"_____ max_forward_accel=(%.3f %.3f) rel=(%.3f %.3f)",
max_forward_accel.x, max_forward_accel.y,
forward_accel_rel.x, forward_accel_rel.y );
dlog.addText( Logger::INTERCEPT,
"_____ max_back_accel=(%.3f %.3f) rel=(%.3f %.3f)",
max_back_accel.x, max_back_accel.y,
back_accel_rel.x, back_accel_rel.y );
#endif
if ( ball_rel.absY() > control_buf
|| Segment2D( forward_accel_rel, back_accel_rel ).dist( ball_rel ) > control_buf )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"__(predictOneDashAdjust) out of control area=%.3f"
" ball_absY=%.3f forward_dist=%.3f back_dist=%.3f",
control_buf, ball_rel.absY(),
ball_rel.dist( forward_accel_rel ),
ball_rel.dist( back_accel_rel ) );
#endif
return false;
}
double dash_power = -1000.0;
//
// small x difference
// player can put the ball on his side.
//
if ( back_accel_rel.x < ball_rel.x
&& ball_rel.x < forward_accel_rel.x )
{
dash_power = getOneStepDashPower( ball_rel,
dash_angle,
forward_accel_rel.x,
back_accel_rel.x );
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"__(predictOneDashAdjust) (1). dash power=%.1f",
dash_power );
#endif
}
//
// big x difference (>0)
//
if ( dash_power < -999.0
&& forward_accel_rel.x < ball_rel.x )
{
double enable_ball_dist = ball_rel.dist( forward_accel_rel );
if ( enable_ball_dist < control_buf )
{
// at least, reach the controllale distance
dash_power = forward_accel_rel.x / dash_rate;
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"__(predictOneDashAdjust) (2). Not Best. next_ball_dist=%.3f power=%.1f",
enable_ball_dist, dash_power );
#endif
}
}
//
// big x difference (<0)
//
if ( dash_power < -999.0
&& ball_rel.x < back_accel_rel.x )
{
double enable_ball_dist = ball_rel.dist( back_accel_rel );
if ( enable_ball_dist < control_buf )
{
dash_power = back_accel_rel.x / dash_rate;
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"__(predictOneDashAdjust) (3). Not Best next_ball_dist=%.3f power=%.1f",
enable_ball_dist, dash_power );
#endif
}
}
//
// check if adjustable
//
if ( dash_power < -999.0
&& back_accel_rel.x < ball_rel.x
&& ball_rel.x < forward_accel_rel.x )
{
dash_power = ball_rel.x / dash_rate;
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"__(predictOneDashAdjust) (4). Not Best. just adjust X. power=%.1f",
dash_power );
#endif
}
//
// register
//
if ( dash_power < -999.0 )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"__(predictOneDashAdjust) XXX Failed" );
#endif
return false;
}
InterceptInfo::Mode mode = InterceptInfo::NORMAL;
Vector2D accel = Vector2D::polar2vector( dash_power * dash_rate, dash_angle );
Vector2D my_vel = self.vel() + accel;
Vector2D my_pos = self.pos() + my_vel;
StaminaModel stamina_model = self.staminaModel();
stamina_model.simulateDash( self.playerType(), dash_power );
if ( stamina_model.stamina() < SP.recoverDecThrValue()
&& ! stamina_model.capacityIsEmpty() )
{
mode = InterceptInfo::EXHAUST;
}
*info = InterceptInfo( mode, 0, 1, dash_power, dash_dir,
my_pos,
my_pos.dist( ball_next ),
stamina_model.stamina() );
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"__*** (predictOneDashAdjust) --->Success! power=%.3f rel_dir=%.1f angle=%.1f"
" my_pos=(%.2f %.2f) ball_dist=%.3f stamina=%.1f",
info->dashPower(),
info->dashAngle().degree(),
dash_angle.degree(),
my_pos.x, my_pos.y,
info->ballDist(),
stamina_model.stamina() );
#endif
return true;
}
/*-------------------------------------------------------------------*/
/*!
*/
double
SelfInterceptV13::getOneStepDashPower( const Vector2D & next_ball_rel,
const AngleDeg & dash_angle,
const double & max_forward_accel_x,
const double & max_back_accel_x ) const
{
const double dash_rate = M_world.self().dashRate() * ServerParam::i().dashDirRate( dash_angle.degree() );
const PlayerType & ptype = M_world.self().playerType();
const double best_ctrl_dist_forward
= ptype.playerSize()
+ 0.5 * ptype.kickableMargin()
+ ServerParam::i().ballSize();
const double best_ctrl_dist_backward
= ptype.playerSize()
+ 0.3 * ptype.kickableMargin()
+ ServerParam::i().ballSize();
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"_______(getOneStepDashPower) best_ctrl_dist_f=%.3f best_ctrl_dist_b=%.3f next_ball_y=%.3f",
best_ctrl_dist_forward,
best_ctrl_dist_backward,
next_ball_rel.y );
#endif
// Y diff is longer than best distance.
// just put the ball on player's side
if ( next_ball_rel.absY() > best_ctrl_dist_forward )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"________(getOneStepDashPower) just put the ball on side" );
#endif
return next_ball_rel.x / dash_rate;
}
#if 1
const double forward_trap_accel_x
= next_ball_rel.x
- std::sqrt( std::pow( best_ctrl_dist_forward, 2 )
- std::pow( next_ball_rel.y, 2 ) );
const double backward_trap_accel_x
= next_ball_rel.x
+ std::sqrt( std::pow( best_ctrl_dist_backward, 2 )
- std::pow( next_ball_rel.y, 2 ) );
double best_accel_x = 10000.0;
double min_power = 10000.0;
const double x_step = ( backward_trap_accel_x - forward_trap_accel_x ) / 5.0;
for ( double accel_x = forward_trap_accel_x;
accel_x < backward_trap_accel_x + 0.01;
accel_x += x_step )
{
if ( ( accel_x >= 0.0
&& max_forward_accel_x > accel_x )
|| ( accel_x < 0.0
&& max_back_accel_x < accel_x )
)
{
double power = accel_x / dash_rate;
if ( std::fabs( power ) < std::fabs( min_power ) )
{
best_accel_x = accel_x;
min_power = power;
}
}
}
if ( min_power < 1000.0 )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"________(getOneStepDashPower) best trap."
" accel_x=%.3f power==%.3f",
best_accel_x,
min_power );
#endif
return min_power;
}
#else
double required_accel_x[2];
// case put ball front
required_accel_x[0]
= next_ball_rel.x
- std::sqrt( std::pow( best_ctrl_dist_forward, 2 )
- std::pow( next_ball_rel.y, 2 ) );
// case put ball back
required_accel_x[1]
= next_ball_rel.x
+ std::sqrt( std::pow( best_ctrl_dist_backward, 2 )
- std::pow( next_ball_rel.y, 2 ) );
if ( M_world.self().body().abs() < 45.0 )
{
// forward dash has priority if player's body face to opponent side
if ( required_accel_x[1] > required_accel_x[0] )
{
std::swap( required_accel_x[0], required_accel_x[1] );
}
}
else if ( std::fabs( required_accel_x[1] )
< std::fabs( required_accel_x[0] ) )
{
// nearest side has priority
std::swap( required_accel_x[0], required_accel_x[1] );
}
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"________(getOneStepDashPower) best_ctrl accel_x[0] = %f accel_x[1] = %f",
required_accel_x[0], required_accel_x[1] );
#endif
for ( int i = 0; i < 2; ++i )
{
if ( required_accel_x[i] >= 0.0
&& max_forward_accel_x > required_accel_x[i] )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"________(getOneStepDashPower) best trap."
" forward dash[%d]. x = %f",
i, required_accel_x[i] );
#endif
return required_accel_x[i] / dash_rate;
}
if ( required_accel_x[i] < 0.0
&& max_back_accel_x < required_accel_x[i] )
{
#ifdef DEBUG_PRINT_ONE_STEP
dlog.addText( Logger::INTERCEPT,
"________(getOneStepDashPower) best trap."
" back dash[%d]. x = %f",
i, required_accel_x[i] );
#endif
return required_accel_x[i] / dash_rate;
}
}
#endif
#ifdef DEBUG_PRINT_ONE_STEPy
dlog.addText( Logger::INTERCEPT,
"________(getOneStepDashPower) Failed" );
#endif
return -1000.0;
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictShortStep( const int max_cycle,
const bool save_recovery,
std::vector< InterceptInfo > & self_cache ) const
{
static std::vector< InterceptInfo > tmp_cache;
const int max_loop = std::min( MAX_SHORT_STEP, max_cycle );
const ServerParam & SP = ServerParam::i();
const BallObject & ball = M_world.ball();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
const double pen_area_x = SP.ourPenaltyAreaLineX() - 0.5;
const double pen_area_y = SP.penaltyAreaHalfWidth() - 0.5;
// calc Y distance from ball line
const Vector2D ball_to_self = ( self.pos() - ball.pos() ).rotatedVector( - ball.vel().th() );
int min_cycle
= static_cast< int >( std::ceil( ( ball_to_self.absY() - ptype.kickableArea() )
/ ptype.realSpeedMax() ) );
if ( min_cycle >= max_loop ) return;
if ( min_cycle < 2 ) min_cycle = 2;
Vector2D ball_pos = ball.inertiaPoint( min_cycle - 1 );
Vector2D ball_vel = ball.vel() * std::pow( SP.ballDecay(), min_cycle - 1 );
for ( int cycle = min_cycle; cycle <= max_loop; ++cycle )
{
tmp_cache.clear();
ball_pos += ball_vel;
ball_vel *= SP.ballDecay();
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"--------- cycle %d -----------", cycle );
dlog.addText( Logger::INTERCEPT,
"(predictShortStep) cycle %d: bpos(%.3f, %.3f) bvel(%.3f, %.3f)",
cycle,
ball_pos.x, ball_pos.y,
ball_vel.x, ball_vel.y );
#endif
const bool goalie_mode
= ( self.goalie()
&& M_world.lastKickerSide() != M_world.ourSide()
&& ball_pos.x < pen_area_x
&& ball_pos.absY() < pen_area_y );
const double control_area = ( goalie_mode
? SP.catchableArea()
: ptype.kickableArea() );
if ( std::pow( control_area + ptype.realSpeedMax() * cycle, 2 )
< self.pos().dist2( ball_pos ) )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"(predictShortStep) too far." );
#endif
continue;
}
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
">>>>>>>> turn dash forward, turn_margin_dist=%f",
control_area - 0.4 );
#endif
predictTurnDashShort( cycle, ball_pos, control_area, save_recovery, false, // forward dash
std::max( 0.1, control_area - 0.4 ),
tmp_cache );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
">>>>>>>> turn dash forward, turn_margin_dist=%f",
control_area - 0.1 );
#endif
predictTurnDashShort( cycle, ball_pos, control_area, save_recovery, false, // forward dash
std::max( 0.1, control_area - control_area_buf ),
tmp_cache );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
">>>>>>>> turn dash back, turn_margin_dist=%f",
control_area - 0.4 );
#endif
predictTurnDashShort( cycle, ball_pos, control_area, save_recovery, true, // back dash
std::max( 0.1, control_area - 0.4 ),
tmp_cache );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
">>>>>>>> turn dash back, turn_margin_dist=%f",
std::max( 0.1, control_area - control_area_buf ) );
#endif
predictTurnDashShort( cycle, ball_pos, control_area, save_recovery, true, // back dash
control_area - control_area_buf,
tmp_cache );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
">>>>>>>> omni dash forward" );
#endif
if ( cycle <= 2 )
{
predictOmniDashShort( cycle, ball_pos, control_area, save_recovery, false, // forward dash
tmp_cache );
//predictOmniDashShort( cycle, ball_pos, control_area, save_recovery, true, // back dash
// tmp_cache );
}
//
// register best interception
//
if ( tmp_cache.empty() )
{
continue;
}
//const double danger_ball_dist = control_area - 0.2;
const double safety_ball_dist = std::max( control_area - 0.2 - ball.pos().dist( ball_pos ) * SP.ballRand(),
ptype.playerSize() + SP.ballSize() + ptype.kickableMargin() * 0.4 );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"decide best interception. size=%d safety_ball_dist=%.3f",
tmp_cache.size(), safety_ball_dist );
#endif
const InterceptInfo * best = &(tmp_cache.front());
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"____ turn=%d dash=%d power=%.1f dir=%.1f ball_dist=%.3f stamina=%.1f",
best->turnCycle(), best->dashCycle(),
best->dashPower(), best->dashAngle().degree(),
best->ballDist(), best->stamina() );
#endif
const std::vector< InterceptInfo >::iterator end = tmp_cache.end();
std::vector< InterceptInfo >::iterator it = tmp_cache.begin();
++it;
for ( ; it != end; ++it )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"____ turn=%d dash=%d power=%.1f dir=%.1f ball_dist=%.3f stamina=%.1f",
it->turnCycle(), it->dashCycle(),
it->dashPower(), it->dashAngle().degree(),
it->ballDist(), it->stamina() );
#endif
if ( best->ballDist() < safety_ball_dist
&& it->ballDist() < safety_ball_dist )
{
if ( best->turnCycle() > it->turnCycle() )
{
best = &(*it);
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"--> updated(1)" );
#endif
}
else if ( best->turnCycle() == it->turnCycle()
&& best->stamina() < it->stamina() )
{
best = &(*it);
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"--> updated(2)" );
#endif
}
}
else
{
//if ( ( best->ballDist() > danger_ball_dist
// || ( best->turnCycle() > 0
// && best->turnCycle() >= it->turnCycle() ) )
if ( best->turnCycle() >= it->turnCycle()
&& ( best->ballDist() > it->ballDist()
|| ( std::fabs( best->ballDist() - it->ballDist() ) < 0.001
&& best->stamina() < it->stamina() ) ) )
{
best = &(*it);
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"--> updated(3)" );
#endif
}
}
}
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"<<<<< Register best cycle=%d(t=%d d=%d) my_pos=(%.2f %.2f) ball_dist=%.3f stamina=%.1f",
best->reachCycle(), best->turnCycle(), best->dashCycle(),
best->selfPos().x, best->selfPos().y,
best->ballDist(),
best->stamina() );
#endif
//self_cache.insert( self_cache.end(), tmp_cache.begin(), tmp_cache.end() );
self_cache.push_back( *best );
}
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictTurnDashShort( const int cycle,
const Vector2D & ball_pos,
const double & control_area,
const bool save_recovery,
const bool back_dash,
const double & turn_margin_control_area,
std::vector< InterceptInfo > & self_cache ) const
{
AngleDeg dash_angle = M_world.self().body();
int n_turn = predictTurnCycleShort( cycle, ball_pos, control_area, back_dash,
turn_margin_control_area,
&dash_angle );
if ( n_turn > cycle )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"(predictShortStep_cycle=%d) turn=%d over",
cycle, n_turn );
#endif
return;
}
predictDashCycleShort( cycle, n_turn, ball_pos, dash_angle, control_area, save_recovery, back_dash,
self_cache );
}
/*-------------------------------------------------------------------*/
/*!
*/
int
SelfInterceptV13::predictTurnCycleShort( const int cycle,
const Vector2D & ball_pos,
const double & /*control_area*/,
const bool back_dash,
const double & turn_margin_control_area,
AngleDeg * result_dash_angle ) const
{
const ServerParam & SP = ServerParam::i();
const double max_moment = SP.maxMoment();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
//const double dist_thr = control_area - 0.1;
const double dist_thr = turn_margin_control_area;
const Vector2D inertia_pos = self.inertiaPoint( cycle );
const double target_dist = ( ball_pos - inertia_pos ).r();
const AngleDeg target_angle = ( ball_pos - inertia_pos ).th();
int n_turn = 0;
const AngleDeg body_angle = ( back_dash
? self.body() + 180.0
: self.body() );
double angle_diff = ( target_angle - body_angle ).abs();
double turn_margin = 180.0;
if ( dist_thr < target_dist )
{
turn_margin = std::max( MIN_TURN_THR,
AngleDeg::asin_deg( dist_thr / target_dist ) );
}
if ( angle_diff > turn_margin )
{
double my_speed = self.vel().r();
while ( angle_diff > turn_margin )
{
angle_diff -= ptype.effectiveTurn( max_moment, my_speed );
my_speed *= ptype.playerDecay();
++n_turn;
}
}
*result_dash_angle = body_angle;
if ( n_turn > 0 )
{
angle_diff = std::max( 0.0, angle_diff );
if ( ( target_angle - body_angle ).degree() > 0.0 )
{
*result_dash_angle = target_angle - angle_diff;
}
else
{
*result_dash_angle = target_angle + angle_diff;
}
}
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d (predictTurnCycleShort) turn=%d",
cycle, n_turn );
dlog.addText( Logger::INTERCEPT,
"%d _______"
" turn_margin=%.1f"
" turn_moment=%.1f"
" first_angle_diff=%.1f"
" final_angle_diff=%.1f"
" dash_angle=%.1f",
cycle,
turn_margin,
( *result_dash_angle - body_angle ).degree(),
( target_angle - body_angle ).degree(),
angle_diff,
result_dash_angle->degree() );
#endif
return n_turn;
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictDashCycleShort( const int cycle,
const int n_turn,
const Vector2D & ball_pos,
const AngleDeg & dash_angle,
const double & control_area,
const bool save_recovery,
const bool back_dash,
std::vector< InterceptInfo > & self_cache ) const
{
const ServerParam & SP = ServerParam::i();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
const double recover_dec_thr = SP.recoverDecThrValue() + 1.0;
const int max_dash = cycle - n_turn;
const Vector2D my_inertia = self.inertiaPoint( cycle );
Vector2D my_pos = self.inertiaPoint( n_turn );
Vector2D my_vel = self.vel() * std::pow( ptype.playerDecay(), n_turn );
StaminaModel stamina_model = self.staminaModel();
stamina_model.simulateWaits( ptype, n_turn );
if ( my_inertia.dist2( ball_pos ) < std::pow( control_area - control_area_buf, 2 ) )
{
Vector2D my_final_pos = my_inertia;
StaminaModel tmp_stamina = stamina_model;
tmp_stamina.simulateWaits( ptype, cycle - n_turn );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d **OK** (predictDashCycleShort) can reach. turn=%d dash=0.",
cycle, n_turn );
dlog.addText( Logger::INTERCEPT,
"%d _____________________"
" bpos(%.1f %.1f) my_inertia=(%.1f %.1f) dist=%.3f stamina=%.1f",
cycle,
ball_pos.x, ball_pos.y,
my_inertia.x, my_inertia.y,
my_final_pos.dist( ball_pos ),
tmp_stamina.stamina() );
#endif
self_cache.push_back( InterceptInfo( InterceptInfo::NORMAL,
n_turn, cycle - n_turn,
0.0, 0.0,
my_final_pos,
my_final_pos.dist( ball_pos ),
tmp_stamina.stamina() ) );
}
const AngleDeg target_angle = ( ball_pos - my_inertia ).th();
if ( ( target_angle - dash_angle ).abs() > 90.0 )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d XXX (predictDashCycleShort) turn=%d.",
cycle, n_turn );
dlog.addText( Logger::INTERCEPT,
"%d ____________________"
" (target_angle(%.1f) - dash_angle(%.1f)) > 90",
cycle,
target_angle.degree(), dash_angle.degree() );
#endif
return;
}
const Vector2D accel_unit = Vector2D::polar2vector( 1.0, dash_angle );
double first_dash_power = 0.0;
for ( int n_dash = 1; n_dash <= max_dash; ++n_dash )
{
#if 0
dlog.addText( Logger::INTERCEPT,
"__ dash %d: max_dash=%d", n_dash, max_dash );
#endif
Vector2D ball_rel = ( ball_pos - my_pos ).rotatedVector( -dash_angle );
double first_speed = calc_first_term_geom_series( ball_rel.x,
ptype.playerDecay(),
max_dash - n_dash + 1 );
Vector2D rel_vel = my_vel.rotatedVector( -dash_angle );
double required_accel = first_speed - rel_vel.x;
double dash_power = required_accel / ( ptype.dashRate( stamina_model.effort() ) );
if ( back_dash ) dash_power = -dash_power;
double available_stamina = ( save_recovery
? std::max( 0.0, stamina_model.stamina() - recover_dec_thr )
: stamina_model.stamina() + ptype.extraStamina() );
//double dash_power = 0.0;
if ( back_dash )
{
dash_power = bound( SP.minDashPower(), dash_power, 0.0 );
dash_power = std::max( dash_power, available_stamina * -0.5 );
}
else
{
dash_power = bound( 0.0, dash_power, SP.maxDashPower() );
dash_power = std::min( available_stamina, dash_power );
}
if ( n_dash == 1 )
{
first_dash_power = dash_power;
}
double accel_mag = std::fabs( dash_power * ptype.dashRate( stamina_model.effort() ) );
Vector2D accel = accel_unit * accel_mag;
my_vel += accel;
my_pos += my_vel;
my_vel *= ptype.playerDecay();
stamina_model.simulateDash( ptype, dash_power );
#if 0
dlog.addText( Logger::INTERCEPT,
"____ pos=(%.2f %.2f) vel=(%.2f %.2f)r=%.3f th=%.1f",
my_pos.x, my_pos.y,
my_vel.x, my_vel.y,
my_vel.r(), my_vel.th().degree() );
dlog.addText( Logger::INTERCEPT,
"____ required first_speed=%.3f accel=%.3f dash_power=%.1f",
first_speed, required_accel, dash_power );
#endif
}
if ( my_pos.dist2( ball_pos ) < std::pow( control_area - control_area_buf, 2 )
|| self.pos().dist2( my_pos ) > self.pos().dist2( ball_pos ) )
{
InterceptInfo::Mode mode = ( stamina_model.stamina() < SP.recoverDecThrValue()
&& ! stamina_model.capacityIsEmpty()
? InterceptInfo::EXHAUST
: InterceptInfo::NORMAL );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d **OK** (predictDashCycleShort) controllable turn=%d dash=%d",
cycle, n_turn, cycle - n_turn );
dlog.addText( Logger::INTERCEPT,
"%d __"
" bpos(%.1f %.1f) my_pos=(%.1f %.1f) ball_dist=%.3f"
" first_dash_power=%.1f stamina=%.1f",
cycle,
ball_pos.x, ball_pos.y,
my_pos.x, my_pos.y,
my_pos.dist( ball_pos ),
first_dash_power, stamina_model.stamina() );
dlog.addText( Logger::INTERCEPT,
"%d __"
" first_dash_power=%.1f stamina=%.1f",
cycle,
first_dash_power, stamina_model.stamina() );
#endif
self_cache.push_back( InterceptInfo( mode, n_turn, cycle - n_turn,
first_dash_power, 0.0,
my_pos,
my_pos.dist( ball_pos ),
stamina_model.stamina() ) );
return;
}
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d XXX (predictDashCycleShort) turn=%d dash=%d.",
cycle, n_turn, max_dash );
dlog.addText( Logger::INTERCEPT,
"%d __ bpos(%.2f %.2f) mypos=(%.2f %.2f)",
cycle,
ball_pos.x, ball_pos.y,
my_pos.x, my_pos.y );
dlog.addText( Logger::INTERCEPT,
"%d __ ball_dist=%.3f control_area=%.3f(real:%.3f buf=%.3f",
cycle,
my_pos.dist( ball_pos ),
control_area - control_area_buf,
control_area,
control_area_buf );
dlog.addText( Logger::INTERCEPT,
"%d __ my_dash_move=%.3f first_ball_dist=%.3f",
cycle,
self.pos().dist( my_pos ),
self.pos().dist( ball_pos ) );
#endif
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictOmniDashShort( const int cycle,
const Vector2D & ball_pos,
const double & control_area,
const bool save_recovery,
const bool back_dash,
std::vector< InterceptInfo > & self_cache ) const
{
const ServerParam & SP = ServerParam::i();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
const AngleDeg body_angle = ( back_dash
? self.body() + 180.0
: self.body() );
const Vector2D my_inertia = self.inertiaPoint( cycle );
const Line2D target_line( ball_pos, body_angle );
if ( target_line.dist( my_inertia ) < control_area - 0.4 )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d (predictOmniDashShort) already on line. no need to omnidash. target_line_dist=%.3f",
cycle, target_line.dist( my_inertia ) );
#endif
return;
}
const double recover_dec_thr = SP.recoverDecThrValue() + 1.0;
const double dash_angle_step = std::max( 15.0, SP.dashAngleStep() );
const double min_dash_angle = ( -180.0 < SP.minDashAngle() && SP.maxDashAngle() < 180.0
? SP.minDashAngle()
: dash_angle_step * static_cast< int >( -180.0 / dash_angle_step ) );
const double max_dash_angle = ( -180.0 < SP.minDashAngle() && SP.maxDashAngle() < 180.0
? SP.maxDashAngle() + dash_angle_step * 0.5
: dash_angle_step * static_cast< int >( 180.0 / dash_angle_step ) - 1.0 );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d (predictOmniDashShort) min_angle=%.1f max_angle=%.1f",
cycle, min_dash_angle, max_dash_angle );
#endif
const AngleDeg target_angle = ( ball_pos - my_inertia ).th();
for ( double dir = min_dash_angle;
dir < max_dash_angle;
dir += dash_angle_step )
{
if ( std::fabs( dir ) < 1.0 ) continue;
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d ===== (predictOmniDashShort) dir=%.1f",
cycle, dir );
#endif
const AngleDeg dash_angle = body_angle + SP.discretizeDashAngle( SP.normalizeDashAngle( dir ) );
if ( ( dash_angle - target_angle ).abs() > 91.0 )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d XXX angle over. target_angle=%.1f dash_angle=%.1f",
cycle,
target_angle.degree(), dash_angle.degree() );
#endif
continue;
}
double first_dash_power = 0.0;
Vector2D my_pos = self.pos();
Vector2D my_vel = self.vel();
StaminaModel stamina_model = self.staminaModel();
int n_omni_dash = predictAdjustOmniDash( cycle,
ball_pos,
control_area,
save_recovery,
back_dash,
dir,
&my_pos,
&my_vel,
&stamina_model,
&first_dash_power );
if ( n_omni_dash < 0 )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d XXX no adjustable",
cycle );
#endif
continue;
}
if ( n_omni_dash == 0 )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d XXX not need to adjust",
cycle );
#endif
continue;
}
//
// check target point direction
//
{
Vector2D inertia_pos = ptype.inertiaPoint( my_pos, my_vel, cycle - n_omni_dash );
Vector2D target_rel = ( ball_pos - inertia_pos ).rotatedVector( -body_angle );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d ____after omni dash. inertia_pos=(%.3f %.3f) ball_pos=(%.3f %.3f) body_angle=%.1f target_rel=(%.3f %.3f)",
cycle,
inertia_pos.x, inertia_pos.y,
ball_pos.x, ball_pos.y,
body_angle.degree(),
target_rel.x, target_rel.y );
#endif
if ( ( back_dash && target_rel.x > 0.0 )
|| ( ! back_dash && target_rel.x < 0.0 ) )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d XXX invalid dash direction. dash=%d target_rel.x=%.3f",
cycle, n_omni_dash,
target_rel.x );
#endif
continue;
}
}
//
// dash to the body direction
//
const Vector2D body_accel_unit = Vector2D::polar2vector( 1.0, body_angle );
for ( int n_dash = n_omni_dash + 1 ; n_dash <= cycle; ++n_dash )
{
double first_speed = calc_first_term_geom_series( ( ball_pos - my_pos ).rotatedVector( -body_angle ).x,
ptype.playerDecay(),
cycle - n_dash + 1 );
Vector2D rel_vel = my_vel.rotatedVector( -body_angle );
double required_accel = first_speed - rel_vel.x;
double dash_power = required_accel / ( ptype.dashRate( stamina_model.effort() ) );
if ( back_dash ) dash_power = -dash_power;
double available_stamina = ( save_recovery
? std::max( 0.0, stamina_model.stamina() - recover_dec_thr )
: stamina_model.stamina() + ptype.extraStamina() );
if ( back_dash )
{
dash_power = bound( SP.minDashPower(), dash_power, 0.0 );
dash_power = std::max( dash_power, available_stamina * -0.5 );
}
else
{
dash_power = bound( 0.0, dash_power, SP.maxDashPower() );
dash_power = std::min( available_stamina, dash_power );
}
double accel_mag = std::fabs( dash_power ) * ptype.dashRate( stamina_model.effort() );
Vector2D accel = body_accel_unit * accel_mag;
my_vel += accel;
my_pos += my_vel;
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d __ body_dash=%d pos=(%.2f %.2f) vel=(%.2f %.2f)r=%.3f",
cycle, n_dash - n_omni_dash,
my_pos.x, my_pos.y,
my_vel.x, my_vel.y, my_vel.r() );
#endif
my_vel *= ptype.playerDecay();
stamina_model.simulateDash( ptype, dash_power );
}
const Vector2D my_move = my_pos - self.pos();
if ( my_pos.dist2( ball_pos ) < std::pow( control_area - control_area_buf, 2 )
|| my_move.r() > ( ball_pos - self.pos() ).rotatedVector( - my_move.th() ).absX() )
{
InterceptInfo::Mode mode = ( stamina_model.recovery() < M_world.self().recovery()
&& ! stamina_model.capacityIsEmpty()
? InterceptInfo::EXHAUST
: InterceptInfo::NORMAL );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d **OK** can reach, after body dir dash.", cycle );
dlog.addText( Logger::INTERCEPT,
"%d ____ omni_dash=%d body_dash=%d",
cycle,
n_omni_dash, cycle - n_omni_dash );
dlog.addText( Logger::INTERCEPT,
"%d ____ final_pos=(%.1f %.1f) ball_dist=%.3f ctrl_area=%.3f",
cycle,
my_pos.x, my_pos.y,
my_pos.dist( ball_pos ), control_area );
dlog.addText( Logger::INTERCEPT,
"%d ____ my_move_dist=%.3f ball_rel_x=%.3f",
cycle,
my_move.r(),
( ball_pos - self.pos() ).rotatedVector( - my_move.th() ).x );
dlog.addText( Logger::INTERCEPT,
"%d ____ 1st_dash_power=%.1f stamina=%.1f",
cycle,
first_dash_power, stamina_model.stamina() );
#endif
self_cache.push_back( InterceptInfo( mode,
0, cycle,
first_dash_power, dir,
my_pos,
my_pos.dist( ball_pos ),
stamina_model.stamina() ) );
}
}
}
/*-------------------------------------------------------------------*/
/*!
*/
int
SelfInterceptV13::predictAdjustOmniDash( const int cycle,
const Vector2D & ball_pos,
const double & control_area,
const bool save_recovery,
const bool back_dash,
const double & dash_rel_dir,
Vector2D * my_pos,
Vector2D * my_vel,
StaminaModel * stamina_model,
double * first_dash_power ) const
{
const ServerParam & SP = ServerParam::i();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
const double recover_dec_thr = SP.recoverDecThrValue() + 1.0;
const int max_omni_dash = std::min( 2, cycle );
const AngleDeg body_angle = ( back_dash
? self.body() + 180.0
: self.body() );
const Line2D target_line( ball_pos, body_angle );
const Vector2D my_inertia = self.inertiaPoint( cycle );
if ( target_line.dist( my_inertia ) < control_area - 0.4 )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d (predictAdjustOmniDash) no dash required. line_dist=%.3f < control_buf=%.3f(%.3f)",
cycle, target_line.dist( my_inertia ), control_area - 0.4, control_area );
#endif
*first_dash_power = 0.0;
return 0;
}
const AngleDeg dash_angle = body_angle
+ SP.discretizeDashAngle( SP.normalizeDashAngle( dash_rel_dir ) );
const Vector2D accel_unit = Vector2D::polar2vector( 1.0, dash_angle );
const double dash_dir_rate = SP.dashDirRate( dash_rel_dir );
//
// dash simulation
//
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d (predictAdjustOmniDash) dir=%.1f angle=%.1f",
cycle, dash_rel_dir, dash_angle.degree() );
#endif
for ( int n_omni_dash = 1; n_omni_dash <= max_omni_dash; ++n_omni_dash )
{
double first_speed = calc_first_term_geom_series( std::max( 0.0, target_line.dist( *my_pos ) ),
ptype.playerDecay(),
cycle - n_omni_dash + 1 );
Vector2D rel_vel = my_vel->rotatedVector( -dash_angle );
double required_accel = first_speed - rel_vel.x;
if ( std::fabs( required_accel ) < 0.01 )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d *** adjustable without dash. omni_dash_loop=%d",
cycle, n_omni_dash );
dlog.addText( Logger::INTERCEPT,
"%d __ first_speed=%.3f rel_vel=(%.3f %.3f) required_accel=%.3f",
cycle,
rel_vel.x, rel_vel.y,
first_speed, required_accel );
#endif
return n_omni_dash - 1;
}
double dash_power = required_accel
/ ( ptype.dashRate( stamina_model->effort() ) * dash_dir_rate );
double available_stamina = ( save_recovery
? std::max( 0.0, stamina_model->stamina() - recover_dec_thr )
: stamina_model->stamina() + ptype.extraStamina() );
if ( back_dash )
{
dash_power = bound( SP.minDashPower(), dash_power, 0.0 );
dash_power = std::max( dash_power, available_stamina * -0.5 );
}
else
{
dash_power = bound( 0.0, dash_power, SP.maxDashPower() );
dash_power = std::min( available_stamina, dash_power );
}
if ( n_omni_dash == 1 )
{
*first_dash_power = dash_power;
}
double accel_mag
= std::fabs( dash_power )
* ptype.dashRate( stamina_model->effort() )
* dash_dir_rate;
Vector2D accel = accel_unit * accel_mag;
*my_vel += accel;
*my_pos += *my_vel;
*my_vel *= ptype.playerDecay();
stamina_model->simulateDash( ptype, dash_power );
Vector2D inertia_pos = ptype.inertiaPoint( *my_pos, *my_vel, cycle - n_omni_dash );
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d ____ omni_dash=%d"
" accel=(%.3f %.3f)r=%.3f inertia_line_dist=%.3f",
cycle, n_omni_dash,
accel.x, accel.y, accel.r(),
target_line.dist( inertia_pos ) );
#endif
if ( target_line.dist( inertia_pos ) < control_area - control_area_buf )
{
#ifdef DEBUG_PRINT_SHORT_STEP
dlog.addText( Logger::INTERCEPT,
"%d *** adjustable. omni_dash=%d first_dash_power=%.1f line_dist=%.3f ctrl_dist=%.3f",
cycle, n_omni_dash,
*first_dash_power,
target_line.dist( inertia_pos ),
control_area );
#endif
return n_omni_dash;
}
}
return -1;
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictLongStep( const int max_cycle,
const bool save_recovery,
std::vector< InterceptInfo > & self_cache ) const
{
static std::vector< InterceptInfo > tmp_cache;
const ServerParam & SP = ServerParam::i();
const BallObject & ball = M_world.ball();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
// calc Y distance from ball line
Vector2D ball_to_self = self.pos() - ball.pos();
ball_to_self.rotate( - ball.vel().th() );
int start_cycle = static_cast< int >( std::ceil( ( ball_to_self.absY()
- ptype.kickableArea()
- 0.2 )
/ ptype.realSpeedMax() ) );
if ( start_cycle <= MAX_SHORT_STEP )
{
start_cycle = MAX_SHORT_STEP + 1;
}
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
dlog.addText( Logger::INTERCEPT,
"(predictLongStep) start_cycle=%d max_cycle=%d",
start_cycle, max_cycle );
#endif
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
if ( max_cycle <= start_cycle )
{
dlog.addText( Logger::INTERCEPT,
"(predictLongStep) Too big Y difference = %f."
" start_cycle = %d. max_cycle = %d",
ball_to_self.y, start_cycle, max_cycle );
}
#endif
Vector2D ball_pos = ball.inertiaPoint( start_cycle - 1 );
Vector2D ball_vel = ball.vel() * std::pow( SP.ballDecay(), start_cycle - 1 );
bool found = false;
int max_loop = max_cycle;
tmp_cache.clear();
for ( int cycle = start_cycle; cycle < max_loop; ++cycle )
{
ball_pos += ball_vel;
ball_vel *= SP.ballDecay();
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
dlog.addText( Logger::INTERCEPT,
"---------- cycle %d ----------", cycle );
dlog.addText( Logger::INTERCEPT,
"bpos(%.3f, %.3f) bvel(%.3f, %.3f)",
ball_pos.x, ball_pos.y,
ball_vel.x, ball_vel.y );
#endif
// // ball is stopped
// if ( ball_vel.r2() < 0.0001 )
// {
// #ifdef DEBUG_PRINT
// dlog.addText( Logger::INTERCEPT,
// "____ball speed reach ZERO" );
// #endif
// break;
// }
if ( ball_pos.absX() > SP.pitchHalfLength() + 10.0
|| ball_pos.absY() > SP.pitchHalfWidth() + 10.0
)
{
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ____ball is out of pitch", cycle );
#endif
break;
}
const bool goalie_mode
= ( self.goalie()
&& M_world.lastKickerSide() != M_world.ourSide()
&& ball_pos.x < SP.ourPenaltyAreaLineX()
&& ball_pos.absY() < SP.penaltyAreaHalfWidth()
);
const double control_area = ( goalie_mode
? SP.catchableArea()
: ptype.kickableArea() );
///////////////////////////////////////////////////////////
// reach point is too far. never reach
if ( control_area + ( ptype.realSpeedMax() * cycle )
< self.pos().dist( ball_pos ) )
{
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ____ball is too far. never reach", cycle );
#endif
continue;
}
///////////////////////////////////////////////////////////
bool back_dash = false;
int n_turn = 0;
double result_recovery = 0.0;
if ( canReachAfterTurnDash( cycle,
ball_pos,
control_area,
save_recovery, // save recovery
&n_turn, &back_dash, &result_recovery,
self_cache ) )
{
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d --> can reach. cycle=%d, turn=%d, %s recovery=%f",
cycle, cycle, n_turn,
( back_dash ? "back" : "forward" ),
result_recovery );
#endif
if ( ! found )
{
max_loop = std::min( max_cycle, cycle + 10 );
}
found = true;
}
///////////////////////////////////////////////////////////
#if 0
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
">>>>>>>> turn dash long forward <<<<<<<<<<" );
#endif
predictTurnDashLong( cycle, ball_pos, control_area, save_recovery, false, // forward dash
tmp_cache );
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
">>>>>>>> turn dash long back <<<<<<<<<<" );
#endif
predictTurnDashLong( cycle, ball_pos, control_area, save_recovery, true, // back dash
tmp_cache );
#endif
}
// not registered any interception
if ( ! found
&& save_recovery )
{
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
dlog.addText( Logger::INTERCEPT,
__FILE__": SelfInterceptV13. failed to predict? register ball final point" );
#endif
predictFinal( max_cycle, self_cache );
}
if ( self_cache.empty() )
{
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
dlog.addText( Logger::INTERCEPT,
__FILE__": SelfInterceptV13. not found. retry predictFinal()" );
#endif
predictFinal( max_cycle, self_cache );
}
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictFinal( const int max_cycle,
std::vector< InterceptInfo > & self_cache ) const
{
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
const Vector2D my_final_pos = self.inertiaPoint( 100 );
const Vector2D ball_final_pos = M_world.ball().inertiaPoint( 100 );
const bool goalie_mode =
( self.goalie()
&& M_world.lastKickerSide() != M_world.ourSide()
&& ball_final_pos.x < ServerParam::i().ourPenaltyAreaLineX()
&& ball_final_pos.absY() < ServerParam::i().penaltyAreaHalfWidth()
);
const double control_area = ( goalie_mode
? ServerParam::i().catchableArea() - 0.15
: ptype.kickableArea() );
AngleDeg dash_angle = self.body();
bool back_dash = false; // dummy
int n_turn = predictTurnCycle( 100,
ball_final_pos,
control_area,
&dash_angle, &back_dash );
double dash_dist = my_final_pos.dist( ball_final_pos );
dash_dist -= control_area;
int n_dash = ptype.cyclesToReachDistance( dash_dist );
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
dlog.addText( Logger::INTERCEPT,
"(predictFinal) register ball final point. max_cycle=%d, turn=%d, dash=%d",
max_cycle,
n_turn, n_dash );
#endif
if ( max_cycle > n_turn + n_dash )
{
n_dash = max_cycle - n_turn;
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
dlog.addText( Logger::INTERCEPT,
"__Final(2) dash step is changed by max_cycle. max=%d turn=%d dash=%d",
max_cycle,
n_turn, n_dash );
#endif
}
StaminaModel stamina_model = self.staminaModel();
stamina_model.simulateWaits( ptype, n_turn );
stamina_model.simulateDashes( ptype, n_dash, ServerParam::i().maxDashPower() );
self_cache.push_back( InterceptInfo( InterceptInfo::NORMAL,
n_turn, n_dash,
ServerParam::i().maxDashPower(), 0.0,
ball_final_pos,
0.0,
stamina_model.stamina() ) );
}
/*-------------------------------------------------------------------*/
/*!
\param ball_pos ball position after 'cycle'.
*/
bool
SelfInterceptV13::canReachAfterTurnDash( const int cycle,
const Vector2D & ball_pos,
const double & control_area,
const bool save_recovery,
int * n_turn,
bool * back_dash,
double * result_recovery,
std::vector< InterceptInfo > & self_cache ) const
{
AngleDeg dash_angle = M_world.self().body();
*n_turn = predictTurnCycle( cycle,
ball_pos,
control_area,
&dash_angle, back_dash );
if ( *n_turn > cycle )
{
return false;
}
return canReachAfterDash( *n_turn, std::max( 0, cycle - (*n_turn) ),
ball_pos, control_area,
save_recovery,
dash_angle, *back_dash,
result_recovery,
self_cache );
}
/*-------------------------------------------------------------------*/
/*!
predict & get teammate's ball gettable cycle
*/
int
SelfInterceptV13::predictTurnCycle( const int cycle,
const Vector2D & ball_pos,
const double & control_area,
AngleDeg * dash_angle,
bool * back_dash ) const
{
const PlayerType & ptype = M_world.self().playerType();
int n_turn = 0;
///////////////////////////////////////////////////
// prepare variables
const Vector2D inertia_pos = M_world.self().inertiaPoint( cycle );
const Vector2D target_rel = ball_pos - inertia_pos;
const AngleDeg target_angle = target_rel.th();
double angle_diff = ( target_angle - (*dash_angle) ).degree();
const bool diff_is_positive = ( angle_diff > 0.0 ? true : false );
angle_diff = std::fabs( angle_diff );
// atan version
const double target_dist = target_rel.r();
double turn_margin = 180.0;
double control_buf = control_area - 0.25;
//- M_world.ball().vel().r() * ServerParam::i().ballRand() * 0.5
//- target_dist * ServerParam::i().playerRand() * 0.5;
control_buf = std::max( 0.5, control_buf );
if ( control_buf < target_dist )
{
// turn_margin = AngleDeg::atan2_deg( control_buf, target_dist );
turn_margin = AngleDeg::asin_deg( control_buf / target_dist );
}
turn_margin = std::max( turn_margin, MIN_TURN_THR );
/* case buf == 1.085 - 0.15, asin_deg(buf / dist), atan2_deg(buf, dist)
dist = 1.0 asin_deg = 69.23 atan2_deg = 43.08
dist = 2.0 asin_deg = 27.87 atan2_deg = 25.06
dist = 3.0 asin_deg = 18.16 atan2_deg = 17.31
dist = 4.0 asin_deg = 13.52 atan2_deg = 13.16
dist = 5.0 asin_deg = 10.78 atan2_deg = 10.59
dist = 6.0 asin_deg = 8.97 atan2_deg = 8.86
dist = 7.0 asin_deg = 7.68 atan2_deg = 7.61
dist = 8.0 asin_deg = 6.71 atan2_deg = 6.67
dist = 9.0 asin_deg = 5.96 atan2_deg = 5.93
dist = 10.0 asin_deg = 5.36 atan2_deg = 5.34
dist = 11.0 asin_deg = 4.88 atan2_deg = 4.86
dist = 12.0 asin_deg = 4.47 atan2_deg = 4.46
dist = 13.0 asin_deg = 4.12 atan2_deg = 4.11
dist = 14.0 asin_deg = 3.83 atan2_deg = 3.82
dist = 15.0 asin_deg = 3.57 atan2_deg = 3.57
dist = 16.0 asin_deg = 3.35 atan2_deg = 3.34
dist = 17.0 asin_deg = 3.15 atan2_deg = 3.15
dist = 18.0 asin_deg = 2.98 atan2_deg = 2.97
dist = 19.0 asin_deg = 2.82 atan2_deg = 2.82
dist = 20.0 asin_deg = 2.68 atan2_deg = 2.68
*/
///////////////////////////////////////////////////
// check back dash possibility
if ( canBackDashChase( cycle, target_dist, angle_diff ) )
{
*back_dash = true;
*dash_angle += 180.0;
angle_diff = 180.0 - angle_diff;
}
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ______control_buf=%.2f turn_margin=%.1f angle_diff=%.1f",
cycle, control_buf, turn_margin, angle_diff );
#endif
///////////////////////////////////////////////////
// predict turn cycles
const double max_moment
= ServerParam::i().maxMoment()
* ( 1.0 - ServerParam::i().playerRand() );
double player_speed = M_world.self().vel().r();
while ( angle_diff > turn_margin )
{
double max_turnable
= ptype.effectiveTurn( max_moment, player_speed );
angle_diff -= max_turnable;
player_speed *= ptype.playerDecay();
++n_turn;
}
///////////////////////////////////////////////////
// update dash angle
if ( n_turn > 0 )
{
angle_diff = std::max( 0.0, angle_diff );
*dash_angle = target_angle + ( diff_is_positive
? + angle_diff
: - angle_diff );
}
return n_turn;
}
/*-------------------------------------------------------------------*/
/*!
predict & get teammate's ball gettable cycle
*/
bool
SelfInterceptV13::canBackDashChase( const int cycle,
const double & /*target_dist*/,
const double & angle_diff ) const
{
///////////////////////////////////////////////
// check angle threshold
if ( angle_diff < BACK_DASH_THR_ANGLE )
{
return false;
}
if ( ( ! M_world.self().goalie()
|| M_world.lastKickerSide() == M_world.ourSide() )
&& cycle >= 5 )
{
return false;
}
if ( M_world.self().goalie()
&& M_world.lastKickerSide() != M_world.ourSide()
&& cycle >= 5 )
{
if ( cycle >= 15 )
{
return false;
}
Vector2D goal( - ServerParam::i().pitchHalfLength(), 0.0 );
Vector2D bpos = M_world.ball().inertiaPoint( cycle );
if ( goal.dist( bpos ) > 21.0 )
{
return false;
}
}
///////////////////////////////////////////////
// check stamina threshold
// consumed stamina by one step
double total_consume = - ServerParam::i().minDashPower() * 2.0 * cycle;
double total_recover
= M_world.self().playerType().staminaIncMax() * M_world.self().recovery()
* ( cycle - 1 );
double result_stamina
= M_world.self().stamina()
- total_consume
+ total_recover;
if ( result_stamina < ServerParam::i().recoverDecThrValue() + 205.0 )
{
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ______ goalie no stamina. no back. stamina=%f",
cycle, result_stamina );
#endif
return false;
}
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ______try back dash. result stamina=%.1f",
cycle, result_stamina );
#endif
return true;
}
/*-------------------------------------------------------------------*/
/*!
assume that players's dash angle is directed to ball reach point
\param ball_pos ball position after 'cycle'.
*/
bool
SelfInterceptV13::canReachAfterDash( const int n_turn,
const int n_dash,
const Vector2D & ball_pos,
const double & control_area,
const bool save_recovery,
const AngleDeg & dash_angle,
const bool back_dash,
double * result_recovery,
std::vector< InterceptInfo > & self_cache ) const
{
static const double PLAYER_NOISE_RATE
//= ( 1.0 - ServerParam::i().playerRand() * 0.25 );
= ( 1.0 - ServerParam::i().playerRand() * 0.01 );
static const double MAX_POWER = ServerParam::i().maxDashPower();
const ServerParam & SP = ServerParam::i();
const PlayerType & ptype = M_world.self().playerType();
const Vector2D my_inertia = M_world.self().inertiaPoint( n_turn + n_dash );
const double recover_dec_thr = SP.recoverDecThr() * SP.staminaMax();
//////////////////////////////////////////////////////////////
const AngleDeg dash_angle_minus = -dash_angle;
const Vector2D ball_rel
= ( ball_pos - M_world.self().pos() ).rotatedVector( dash_angle_minus );
const double ball_noise
= M_world.ball().pos().dist( ball_pos )
* SP.ballRand()
* 0.5;
const double noised_ball_x = ball_rel.x + ball_noise;
//////////////////////////////////////////////////////////////
// prepare loop variables
// ORIGIN: first player pos.
// X-axis: dash angle
//Vector2D tmp_pos = ptype.inertiaPoint( M_world.self().pos(), M_world.self().vel(), n_turn );
//tmp_pos -= M_world.self().pos();
Vector2D tmp_pos = ptype.inertiaTravel( M_world.self().vel(), n_turn );
tmp_pos.rotate( dash_angle_minus );
Vector2D tmp_vel = M_world.self().vel();
tmp_vel *= std::pow( ptype.playerDecay(), n_turn );
tmp_vel.rotate( dash_angle_minus );
StaminaModel stamina_model = M_world.self().staminaModel();
stamina_model.simulateWaits( ptype, n_turn );
double prev_effort = stamina_model.effort();
double dash_power_abs = MAX_POWER;
// only consider about x of dash accel vector,
// because current orientation is player's dash angle (included back dash case)
// NOTE: dash_accel_x must be positive value.
double dash_accel_x = dash_power_abs * ptype.dashRate( stamina_model.effort() );
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ______Try %d turn: %d dash:"
" angle=%.1f first_accel=%.2f first_vel=(%.2f %.2f)",
n_turn + n_dash,
n_turn, n_dash,
dash_angle.degree(), dash_accel_x, tmp_vel.x, tmp_vel.y );
#endif
//////////////////////////////////////////////////////////////
bool can_over_speed_max = ptype.canOverSpeedMax( dash_power_abs,
stamina_model.effort() );
double first_dash_power = dash_power_abs * ( back_dash ? -1.0 : 1.0 );
for ( int i = 0; i < n_dash; ++i )
{
/////////////////////////////////////////////////////////
// update dash power & accel
double available_power = ( save_recovery
? std::max( 0.0, stamina_model.stamina() - recover_dec_thr )
: stamina_model.stamina() + ptype.extraStamina() );
if ( back_dash ) available_power *= 0.5;
available_power = min_max( 0.0, available_power, MAX_POWER );
bool must_update_power = false;
if ( available_power < dash_power_abs // no enough stamina
|| stamina_model.effort() < prev_effort // effort decreased.
|| ( ! can_over_speed_max // can inclease dash power
&& dash_power_abs < available_power )
)
{
must_update_power = true;
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_3
dlog.addText( Logger::INTERCEPT,
"%d ________dash %d/%d: no enough? stamina=%.1f extra=%.1f"
" cur_pow=%.1f available_pow=%.1f",
n_turn + n_dash,
i, n_dash,
stamina_model.stamina(), ptype.extraStamina(),
dash_power_abs, available_power );
dlog.addText( Logger::INTERCEPT,
"%d ________dash %d/%d: effort decayed? %f -> %f",
n_turn + n_dash,
i, n_dash, prev_effort, stamina_model.effort() );
dlog.addText( Logger::INTERCEPT,
"%d ________dash %d/%d: reset max power?. curr_pow=%.1f"
" available=%.1f",
n_turn + n_dash,
i, n_dash, dash_power_abs, available_power );
#endif
}
if ( must_update_power )
{
dash_power_abs = available_power;
dash_accel_x = dash_power_abs * ptype.dashRate( stamina_model.effort() );
can_over_speed_max = ptype.canOverSpeedMax( dash_power_abs,
stamina_model.effort() );
if ( i == 0 )
{
first_dash_power = dash_power_abs * ( back_dash ? -1.0 : 1.0 );
}
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_3
dlog.addText( Logger::INTERCEPT,
"%d ________dash %d/%d: update dash_power_abs=%.1f accel_x=%f",
n_turn + n_dash,
i, n_dash, dash_power_abs, dash_accel_x );
#endif
}
/////////////////////////////////////////////////////////
// update vel
tmp_vel.x += dash_accel_x;
// power conservation, update accel magnitude & dash_power
if ( can_over_speed_max
&& tmp_vel.r2() > ptype.playerSpeedMax2() )
{
tmp_vel.x -= dash_accel_x;
// conserve power & reduce accel
// sqr(rel_vel.y) + sqr(max_dash_x) == sqr(max_speed);
// accel_mag = dash_x - rel_vel.x;
double max_dash_x = std::sqrt( ptype.playerSpeedMax2()
- ( tmp_vel.y * tmp_vel.y ) );
dash_accel_x = max_dash_x - tmp_vel.x;
dash_power_abs = std::fabs( dash_accel_x / ptype.dashRate( stamina_model.effort() ) );
// re-update vel
tmp_vel.x += dash_accel_x;
can_over_speed_max = ptype.canOverSpeedMax( dash_power_abs,
stamina_model.effort() );
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_3
dlog.addText( Logger::INTERCEPT,
"%d ________dash %d/%d: power conserve. power=%.1f accel_x=%f",
n_turn + n_dash,
i, n_dash, dash_power_abs, dash_accel_x );
#endif
}
#if 0
/////////////////////////////////////////////////////////
// velocity reached max speed
if ( tmp_vel.x > ptype.realSpeedMax() - 0.005 )
{
tmp_vel.x = ptype.realSpeedMax();
double real_power = dash_power_abs;
if ( back_dash ) real_power *= -1.0;
int n_safety_dash
= ptype.getMaxDashCyclesSavingRecovery( real_power,
stamina_model.stamina(),
stamina_model.recovery() );
n_safety_dash = std::min( n_safety_dash, n_dash - i );
n_safety_dash = std::max( 0, n_safety_dash - 1 ); // -1 is very important
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_3
dlog.addText( Logger::INTERCEPT,
"%d ________dash %d/%d: reach real speed max. safety dash=%d",
n_turn + n_dash,
i, n_dash, n_safety_dash );
#endif
tmp_pos.x += tmp_vel.x * n_safety_dash;
double one_cycle_consume = ( real_power > 0.0
? real_power
: real_power * -2.0 );
one_cycle_consume -= ptype.staminaIncMax() * stamina_model.recovery();
tmp_stamina -= one_cycle_consume * n_safety_dash;
i += n_safety_dash;
}
#endif
/////////////////////////////////////////////////////////
// update pos & vel
tmp_pos += tmp_vel;
tmp_vel *= ptype.playerDecay();
/////////////////////////////////////////////////////////
// update stamina
stamina_model.simulateDash( ptype, dash_power_abs * ( back_dash ? -1.0 : 1.0 ) );
/////////////////////////////////////////////////////////
// check run over
// it is not necessary to consider about Y difference,
// because dash_angle is corrected for ball_reach_point
//if ( tmp_pos.x * PLAYER_NOISE_RATE > noised_ball_x )
if ( tmp_pos.x * PLAYER_NOISE_RATE + 0.1 > noised_ball_x )
{
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
dlog.addText( Logger::INTERCEPT,
"%d ____dash %d/%d: can run over. rel_move_pos=(%.2f, %.2f)"
" ball_x=%.3f over=%.3f y_diff=%.3f",
n_turn + n_dash,
i, n_dash,
tmp_pos.x, tmp_pos.y,
noised_ball_x,
//tmp_pos.x * PLAYER_NOISE_RATE - noised_ball_x,
tmp_pos.x * PLAYER_NOISE_RATE - 0.1 - noised_ball_x,
std::fabs( tmp_pos.y - ball_rel.y ) );
#endif
*result_recovery = stamina_model.recovery();
Vector2D inertia_pos = ptype.inertiaPoint( tmp_pos, tmp_vel, n_dash - ( i + 1 ) );
Vector2D my_final_pos = M_world.self().pos() + tmp_pos.rotate( dash_angle );
if ( my_inertia.dist2( my_final_pos ) > 0.01 )
{
my_final_pos = Line2D( my_inertia, my_final_pos ).projection( ball_pos );
}
stamina_model.simulateWaits( ptype, n_dash - ( i + 1 ) );
InterceptInfo::Mode mode = ( stamina_model.recovery() < M_world.self().recovery()
&& ! stamina_model.capacityIsEmpty()
? InterceptInfo::EXHAUST
: InterceptInfo::NORMAL );
self_cache.push_back( InterceptInfo( mode,
n_turn, n_dash,
first_dash_power, 0.0,
my_final_pos,
my_final_pos.dist( ball_pos ),
stamina_model.stamina() ) );
return true;
}
}
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ______dash %d: no run over. pmove=(%.2f(noised=%.2f), %.2f) ball_x=%.3f"
" x_diff=%.3f y_diff=%.3f",
n_turn + n_dash,
n_dash,
tmp_pos.x, tmp_pos.x * PLAYER_NOISE_RATE, tmp_pos.y,
noised_ball_x,
tmp_pos.x * PLAYER_NOISE_RATE - noised_ball_x,
std::fabs( tmp_pos.y - ball_rel.y ) );
#endif
//////////////////////////////////////////////////////////
// // when cycle is small, do strict check
// if ( n_turn + n_dash <= 6 )
{
// tmp_pos is relative to playerPos() --> tmp_pos.r() == player_travel
double player_travel = tmp_pos.r();
double player_noise = player_travel * SP.playerRand() * 0.5;
double last_ball_dist = ball_rel.dist( tmp_pos );
double buf = 0.2; // 0.1
//if ( n_turn > 0 ) buf += 0.3;
//if ( n_turn + n_dash >= 4 )
{
buf += player_noise;
buf += ball_noise;
}
if ( last_ball_dist < std::max( control_area - 0.225, control_area - buf ) )
// if ( std::fabs( tmp_pos.x - ball_rel.x ) < control_area - 0.15
// && std::fabs( tmp_pos.y - ball_rel.y ) < control_area - buf
// && last_ball_dist < control_area )
{
Vector2D my_final_pos = M_world.self().pos() + tmp_pos.rotate( dash_angle );
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_1
dlog.addText( Logger::INTERCEPT,
"%d ____dash %d: can reach.last ball dist=%.3f. noised_ctrl_area=%.3f/%.3f",
n_turn + n_dash,
n_dash,
last_ball_dist,
std::max( control_area - 0.225, control_area - buf ),
control_area );
dlog.addText( Logger::INTERCEPT,
"%d ____ player_noise=%f ball_noise=%f buf=%f",
n_turn + n_dash,
player_noise, ball_noise, buf );
#endif
*result_recovery = stamina_model.recovery();
InterceptInfo::Mode mode = ( stamina_model.recovery() < M_world.self().recovery()
&& ! stamina_model.capacityIsEmpty()
? InterceptInfo::EXHAUST
: InterceptInfo::NORMAL );
self_cache.push_back( InterceptInfo( mode,
n_turn, n_dash,
first_dash_power, 0.0,
my_final_pos,
my_final_pos.dist( ball_pos ),
stamina_model.stamina() ) );
return true;
}
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ______dash %d: failed. last_ball_dist=%.3f noised_ctrl_area=%.3f/%.3f",
n_turn + n_dash,
n_dash,
last_ball_dist,
std::max( control_area - 0.225, control_area - buf ),
control_area );
dlog.addText( Logger::INTERCEPT,
"%d ______player_rel=(%.3f %.3f) ball_rel=(%.3f %.3f) p_noise=%.3f b_noise=%.3f",
n_turn + n_dash,
tmp_pos.x, tmp_pos.y,
ball_rel.x, ball_rel.y,
player_noise,
ball_noise );
dlog.addText( Logger::INTERCEPT,
"%d ______noised_ball_x=%.3f bnoise=%.3f pnoise=%.3f",
n_turn + n_dash,
noised_ball_x,
ball_noise, player_noise );
#endif
return false;
}
#ifdef DEBUG_PRINT_LONG_STEP_LEVEL_2
dlog.addText( Logger::INTERCEPT,
"%d ____dash %d: cannot reach. player_rel=(%f %f) ball_rel=(%f %f)"
" noise_ball_x=%f",
n_turn + n_dash,
n_dash,
tmp_pos.x, tmp_pos.y,
ball_rel.x, ball_rel.y,
noised_ball_x );
#endif
return false;
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictTurnDashLong( const int cycle,
const Vector2D & ball_pos,
const double & control_area,
const bool save_recovery,
const bool back_dash,
std::vector< InterceptInfo > & self_cache ) const
{
AngleDeg dash_angle = M_world.self().body();
int n_turn = predictTurnCycleLong( cycle, ball_pos, control_area, back_dash, &dash_angle );
if ( n_turn > cycle )
{
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
"(predictShortStep_cycle=%d) turn=%d over",
cycle, n_turn );
#endif
return;
}
predictDashCycleLong( cycle, n_turn, ball_pos, dash_angle, control_area, save_recovery, back_dash,
self_cache );
}
/*-------------------------------------------------------------------*/
/*!
*/
int
SelfInterceptV13::predictTurnCycleLong( const int cycle,
const Vector2D & ball_pos,
const double & control_area,
const bool back_dash,
AngleDeg * result_dash_angle ) const
{
const ServerParam & SP = ServerParam::i();
const double max_moment = SP.maxMoment();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
const double dist_thr = control_area - 0.1;
const Vector2D inertia_pos = self.inertiaPoint( cycle );
const double target_dist = ( ball_pos - inertia_pos ).r();
const AngleDeg target_angle = ( ball_pos - inertia_pos ).th();
int n_turn = 0;
const AngleDeg body_angle = ( back_dash
? self.body() + 180.0
: self.body() );
double angle_diff = ( target_angle - body_angle ).abs();
double turn_margin = 180.0;
if ( dist_thr < target_dist )
{
turn_margin = std::max( MIN_TURN_THR,
AngleDeg::asin_deg( dist_thr / target_dist ) );
}
double my_speed = self.vel().r();
while ( angle_diff > turn_margin )
{
angle_diff -= ptype.effectiveTurn( max_moment, my_speed );
my_speed *= ptype.playerDecay();
++n_turn;
}
*result_dash_angle = body_angle;
if ( n_turn > 0 )
{
angle_diff = std::max( 0.0, angle_diff );
if ( ( target_angle - body_angle ).degree() > 0.0 )
{
*result_dash_angle = target_angle - angle_diff;
}
else
{
*result_dash_angle = target_angle + angle_diff;
}
}
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
"(predictTurnCycleLong) cycle=%d turn=%d"
" turn_margin=%.1f"
" turn_moment=%.1f"
" first_angle_diff=%.1f"
" final_angle_diff=%.1f"
" dash_angle=%.1f",
cycle, n_turn,
turn_margin,
( *result_dash_angle - body_angle ).degree(),
( target_angle - body_angle ).degree(),
angle_diff,
result_dash_angle->degree() );
#endif
return n_turn;
}
/*-------------------------------------------------------------------*/
/*!
*/
void
SelfInterceptV13::predictDashCycleLong( const int cycle,
const int n_turn,
const Vector2D & ball_pos,
const AngleDeg & dash_angle,
const double & control_area,
const bool save_recovery,
const bool back_dash,
std::vector< InterceptInfo > & self_cache ) const
{
const ServerParam & SP = ServerParam::i();
const SelfObject & self = M_world.self();
const PlayerType & ptype = self.playerType();
const double recover_dec_thr = SP.recoverDecThrValue() + 1.0;
const int max_dash = cycle - n_turn;
const Vector2D my_inertia = self.inertiaPoint( cycle );
Vector2D my_pos = self.inertiaPoint( n_turn );
Vector2D my_vel = self.vel() * std::pow( ptype.playerDecay(), n_turn );
StaminaModel stamina_model = self.staminaModel();
stamina_model.simulateWaits( ptype, n_turn );
if ( my_inertia.dist2( ball_pos ) < std::pow( control_area - 0.1, 2 ) )
{
Vector2D my_final_pos = my_inertia;
// if ( my_inertia.dist2( my_pos ) > 0.01 )
// {
// my_final_pos = Line2D( my_inertia, my_pos ).projection( ball_pos );
// }
StaminaModel tmp_stamina = stamina_model;
tmp_stamina.simulateWaits( ptype, cycle - n_turn );
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
"(predictDashCycleLong) **OK** can reach. cycle=%d turn=%d dash=0."
" bpos(%.1f %.1f) my_inertia=(%.1f %.1f) dist=%.3f stamina=%.1f",
cycle, n_turn,
ball_pos.x, ball_pos.y,
my_inertia.x, my_inertia.y,
my_final_pos.dist( ball_pos ),
tmp_stamina.stamina() );
#endif
self_cache.push_back( InterceptInfo( InterceptInfo::NORMAL,
n_turn, cycle - n_turn,
0.0, 0.0,
my_final_pos,
my_final_pos.dist( ball_pos ),
tmp_stamina.stamina() ) );
}
const AngleDeg target_angle = ( ball_pos - my_inertia ).th();
if ( ( target_angle - dash_angle ).abs() > 90.0 )
{
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
"(predictDashCycleLong) XXX cycle=%d turn=%d."
" (target_angle(%.1f) - dash_angle(%.1f)) > 90",
target_angle.degree(), dash_angle.degree() );
#endif
return;
}
const Vector2D accel_unit = Vector2D::polar2vector( 1.0, dash_angle );
double first_dash_power = 0.0;
for ( int n_dash = 1; n_dash <= max_dash; ++n_dash )
{
double available_stamina = ( save_recovery
? std::max( 0.0, stamina_model.stamina() - recover_dec_thr )
: stamina_model.stamina() + ptype.extraStamina() );
double dash_power = 0.0;
if ( back_dash )
{
available_stamina *= 0.5;
dash_power = bound( SP.minDashPower(), -available_stamina, 0.0 );
}
else
{
dash_power = bound( 0.0, available_stamina, SP.maxDashPower() );
}
if ( n_dash == 1 )
{
first_dash_power = dash_power;
}
double accel_mag = std::fabs( dash_power * ptype.dashRate( stamina_model.effort() ) );
Vector2D accel = accel_unit * accel_mag;
my_vel += accel;
my_pos += my_vel;
my_vel *= ptype.playerDecay();
stamina_model.simulateDash( ptype, dash_power );
Vector2D inertia_pos = ptype.inertiaPoint( my_pos, my_vel, cycle - n_turn - n_dash );
AngleDeg my_move_angle = ( inertia_pos - self.pos() ).th();
Vector2D target_rel = ( ball_pos - self.pos() ).rotatedVector( -my_move_angle );
if ( std::pow( target_rel.x, 2 ) < ( inertia_pos - self.pos() ).r2() )
{
InterceptInfo::Mode mode = ( stamina_model.stamina() < SP.recoverDecThrValue()
&& ! stamina_model.capacityIsEmpty()
? InterceptInfo::EXHAUST
: InterceptInfo::NORMAL );
Vector2D my_final_pos = inertia_pos;
if ( inertia_pos.dist2( my_inertia ) > 0.01 )
{
my_final_pos = Line2D( inertia_pos, my_inertia ).projection( ball_pos );
}
stamina_model.simulateWaits( ptype, cycle - n_turn - n_dash );
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
"(predictDashCycleLong) **OK** can run over."
" cycle=%d turn=%d dash=%d"
" bpos(%.1f %.1f) inertia_pos=(%.1f %.1f) final_pos=(%.1f %.1f)"
" target_rel.x=%.3f my_move=%.3f"
" ball_dist=%.3f"
" first_dash_power=%.1f stamina=%.1f",
cycle, n_turn, n_dash,
ball_pos.x, ball_pos.y,
inertia_pos.x, inertia_pos.y,
my_final_pos.x, my_final_pos.y,
target_rel.x, ( inertia_pos - self.pos() ).r(),
my_final_pos.dist( ball_pos ),
first_dash_power, stamina_model.stamina() );
#endif
self_cache.push_back( InterceptInfo( mode, n_turn, cycle - n_turn,
first_dash_power, 0.0,
my_final_pos,
my_final_pos.dist( ball_pos ),
stamina_model.stamina() ) );
return;
}
}
if ( my_pos.dist2( ball_pos ) < std::pow( control_area - 0.1, 2 ) )
{
InterceptInfo::Mode mode = ( stamina_model.stamina() < SP.recoverDecThrValue()
&& ! stamina_model.capacityIsEmpty()
? InterceptInfo::EXHAUST
: InterceptInfo::NORMAL );
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
"(predictDashCycleLong) **OK** controllable cycle=%d turn=%d dash=%d."
" bpos(%.1f %.1f) my_pos=(%.1f %.1f) ball_dist=%.3f"
" first_dash_power=%.1f stamina=%.1f",
cycle, n_turn, cycle - n_turn,
ball_pos.x, ball_pos.y,
my_pos.x, my_pos.y,
my_pos.dist( ball_pos ),
first_dash_power, stamina_model.stamina() );
#endif
self_cache.push_back( InterceptInfo( mode, n_turn, cycle - n_turn,
first_dash_power, 0.0,
my_pos,
my_pos.dist( ball_pos ),
stamina_model.stamina() ) );
return;
}
#ifdef DEBUG_PRINT_LONG_STEP
dlog.addText( Logger::INTERCEPT,
"(predictDashCycleLong) XXX cycle=%d turn=%d dash=%d."
" bpos(%.1f %.1f) mypos=(%.1f %.1f) ball_dist=%.3f my_dash_move=%.3f",
cycle, n_turn, max_dash,
ball_pos.x, ball_pos.y,
my_pos.x, my_pos.y,
my_pos.dist( ball_pos ),
my_inertia.dist( my_pos ) );
#endif
}
}
|
#include<bits/stdc++.h>
using namespace std;
const int N = 205, inf = 1e9;
int d[N], vis[N], par[N];
int g[N][N], ans[N * N], last[N], dp[N * N], id[N][N], W[N * N];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t, cs = 0; cin >> t;
while (t--) {
int n, m; cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
g[i][j] = inf;
}
}
for (int i = 1; i <= m; i++) {
int u, v, w; cin >> u >> v >> w;
++u; ++v;
g[u][v] = g[v][u] = w;
id[u][v] = id[v][u] = i;
ans[i] = inf;
W[i] = w;
}
for (int u = 1; u <= n; u++) {
memset(vis, 0, sizeof vis);
for (int i = 0; i <= n; i++) {
d[i] = inf; par[i] = i; last[i] = -1;
}
for (int i = 1; i <= m; i++) {
dp[i] = inf;
}
d[u] = 0;
par[u] = u;
last[u] = 0;
while (1) {
int cur = 0;
for (int i = 1; i <= n; i++) {
if (!vis[i] and d[i] < d[cur]) {
cur = i;
}
}
if (cur == 0) break;
if (vis[cur]) break;
vis[cur] = 1;
if (par[cur] != cur) {
dp[id[last[cur]][cur]] = min(dp[id[last[cur]][cur]], d[cur] + g[cur][u]);
ans[id[cur][u]] = min(ans[id[cur][u]], d[cur] + g[cur][u]);
ans[id[u][cur]] = min(ans[id[u][cur]], d[cur] + g[cur][u]);
}
for (int i = 1; i <= n; i++) {
if (i != u) {
if (vis[i]) {
if (par[i] != par[cur]) {
dp[id[last[cur]][cur]] = min(dp[id[last[cur]][cur]], d[cur] + d[i] + g[cur][i]);
dp[id[last[i]][i]] = min(dp[id[last[i]][i]], d[cur] + d[i] + g[cur][i]);
ans[id[cur][i]] = min(ans[id[cur][i]], d[cur] + d[i] + g[cur][i]);
ans[id[i][cur]] = min(ans[id[i][cur]], d[cur] + d[i] + g[cur][i]);
}
}
else if (d[cur] + g[cur][i] < d[i]) {
d[i] = d[cur] + g[cur][i];
last[i] = cur;
if (cur == u) {
par[i] = i;
}
else {
par[i] = par[cur];
}
}
}
}
}
for (int i = 1; i <= n; i++) {
if (last[i] == -1) continue;
int x = dp[id[last[i]][i]];
for (int cur = i; cur; cur = last[cur]) {
if (last[cur]) {
dp[id[last[cur]][cur]] = min(dp[id[last[cur]][cur]], x);
}
}
}
for (int i = 1; i <= m; i++) {
ans[i] = min(ans[i], dp[i]);
}
}
cout << "Case " << ++cs << ":\n";
for (int i = 1; i <= m; i++) {
if (ans[i] == inf) cout << "impossible\n";
else cout << ans[i] - W[i] + 1 << '\n';
}
}
return 0;
}
// https://lightoj.com/contest/loj-homecoming/arena/problem/14
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.